/* ==========================================================================
   CSS Reset & Base Styles
   ========================================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    background: #0c0e12;
    color: #e8eaf0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    line-height: 1.6;
}

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    /* Colors */
    --color-bg: #0c0e12;
    --color-surface: #0f131a;
    --color-surface-2: #0b0e14;
    --color-surface-elevated: #1b2130;
    --color-border: #1a1f29;
    --color-border-light: rgba(255, 255, 255, 0.08);
    --color-text: #e8eaf0;
    --color-text-muted: #9aa3b2;
    --color-text-subtle: #6a7280;
    --color-accent: #7aa2ff;
    --color-accent-2: #6ee7ff;
    --color-accent-hover: #9bb5ff;
    --color-error: #ff5a5a;
    --color-error-bg: rgba(255, 90, 90, 0.08);
    --color-error-border: rgba(255, 90, 90, 0.22);
    --color-error-text: #ffd6d6;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;
    --space-5xl: 48px;
    
    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-2xl: 14px;
    
    /* Typography */
    --font-size-xs: 12px;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    --font-size-2xl: 20px;
    --font-size-3xl: 24px;
    --font-size-4xl: 28px;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 650;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 10px 30px rgba(0, 0, 0, 0.35);
    
    /* Focus */
    --focus-ring: 0 0 0 3px rgba(122, 162, 255, 0.25);
    
    /* Grid & Layout */
    --container-max-width: 1400px;
    --container-padding: var(--space-xl);
    --grid-gap: var(--space-lg);
    
    /* Gallery specific */
    --gallery-grid-min: 220px;
    --gallery-row-height: 8px;
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

/* Main layout grid */
body {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100svh;
}

/* Container component */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
    width: 100%;
}

/* Content wrapper for main sections */
.content-wrapper {
    padding: var(--space-2xl);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-lg) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2xl);
}

.header__brand {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: 0.3px;
}

.nav__list {
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav__link {
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav__link:hover {
    color: var(--color-text);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav__link--active {
    color: var(--color-accent);
    background-color: rgba(122, 162, 255, 0.1);
}

.nav__username {
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
    padding: var(--space-sm) var(--space-md);
}

.nav__link--button {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav__link--button:hover {
    color: var(--color-text);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Mobile navigation */
@media (max-width: 768px) {
    .header__container {
        flex-direction: column;
        gap: var(--space-lg);
        text-align: center;
    }
    
    .nav__list {
        gap: var(--space-lg);
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.main {
    overflow: auto;
    flex: 1;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-lg) 0;
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    color: var(--color-text);
}

h1 {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--space-2xl);
}

h2 {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--space-xl);
}

h3 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-lg);
}

h4 {
    font-size: var(--font-size-xl);
}

h5 {
    font-size: var(--font-size-lg);
}

h6 {
    font-size: var(--font-size-base);
}

p {
    margin: 0 0 var(--space-lg) 0;
    color: var(--color-text-muted);
}

/* ==========================================================================
   Card Components
   ========================================================================== */

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)), var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.card__header {
    padding: var(--space-2xl) var(--space-2xl) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.card__title {
    margin: 0 0 var(--space-sm) 0;
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
}

.card__subtitle {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.card__body {
    padding: var(--space-2xl);
}

.card__footer {
    padding: var(--space-lg) var(--space-2xl) var(--space-2xl);
    border-top: 1px solid var(--color-border);
}

/* Centered card variant */
.card--centered {
    width: min(420px, 100%);
    margin: 0 auto;
    animation: cardSlideIn 0.35s ease-out;
}

@keyframes cardSlideIn {
    from {
        transform: translateY(6px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==========================================================================
   Form Components
   ========================================================================== */

.form__group {
    margin-bottom: var(--space-lg);
}

.form__group:last-child {
    margin-bottom: 0;
}

.form__label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
}

.form__input {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-size: var(--font-size-base);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

.form__input::placeholder {
    color: var(--color-text-subtle);
}

.form__input:focus {
    border-color: var(--color-accent);
    box-shadow: var(--focus-ring);
    background-color: #111623;
}

.form__input--error {
    border-color: var(--color-error);
}

/* Password input with toggle */
.form__password-wrapper {
    position: relative;
}

.form__password-wrapper .form__input {
    padding-right: 42px;
}

/* ==========================================================================
   Button Components
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.btn:focus-visible {
    box-shadow: var(--focus-ring);
}

/* Primary button */
.btn--primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    color: #081019;
    border: none;
}

.btn--primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.btn--primary:active {
    transform: translateY(0);
}

/* Secondary button */
.btn--secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-color: var(--color-border-light);
}

.btn--secondary:hover {
    background: var(--color-surface-elevated);
    border-color: var(--color-border);
}

/* Icon button */
.btn--icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-accent-hover);
}

.btn--icon:hover {
    background: rgba(122, 162, 255, 0.08);
    border-color: rgba(122, 162, 255, 0.25);
}

.btn--icon.active {
    color: var(--color-accent-2);
}

.btn--icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Password toggle positioning */
.form__password-toggle {
    position: absolute;
    right: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
}

/* ==========================================================================
   Alert Components
   ========================================================================== */

.alert {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

.alert--error {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error-text);
}

/* ==========================================================================
   Auth Layout
   ========================================================================== */

.auth-layout {
    min-height: calc(100dvh - 72px);
    display: grid;
    place-items: center;
    padding: var(--space-4xl) var(--space-lg);
    background: 
        radial-gradient(1200px 600px at 10% 0%, rgba(110, 231, 255, 0.08), transparent 60%),
        radial-gradient(900px 500px at 90% 10%, rgba(122, 162, 255, 0.08), transparent 60%);
}

/* ==========================================================================
   Gallery Components
   ========================================================================== */

.gallery-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-2xl);
    align-items: start;
}

.gallery-sidebar {
    background: var(--color-surface-elevated);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: var(--space-xl);
}

.gallery-content {
    min-width: 0;
}

/* Gallery grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--gallery-grid-min), 1fr));
    grid-auto-rows: var(--gallery-row-height);
    gap: var(--grid-gap);
    align-content: start;
}

.gallery-item {
    display: block;
    position: relative;
    background: var(--color-surface-2);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.gallery-item img,
.gallery-item video {
    width: 100%;
    height: auto;
    display: block;
}

/* Video badge */
.gallery-item__badge {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    z-index: 2;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.gallery-item__badge svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* Download button */
.gallery-item__download-btn {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    z-index: 3;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.1s ease;
    color: var(--color-accent);
}

.gallery-item:hover .gallery-item__download-btn {
    opacity: 1;
}

.gallery-item__download-btn:hover {
    background: rgba(122, 162, 255, 0.8);
    color: #fff;
    transform: scale(1.1);
}

.gallery-item__download-btn:active {
    transform: scale(0.95);
}

.gallery-item__download-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Hide button */
.gallery-item__hide-btn {
    position: absolute;
    top: var(--space-sm);
    left: calc(var(--space-sm) + 36px);
    z-index: 3;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.1s ease;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.7);
}

.gallery-item:hover .gallery-item__hide-btn {
    opacity: 1;
}

.gallery-item__hide-btn:hover {
    background: rgba(255, 215, 0, 0.8);
    color: #000;
    transform: scale(1.1);
}

.gallery-item__hide-btn:active {
    transform: scale(0.95);
}

.gallery-item__hide-btn--revert {
    background: rgba(0, 150, 0, 0.8);
}

.gallery-item__hide-btn--revert:hover {
    background: rgba(0, 180, 0, 0.9);
}

.gallery-item__hide-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Hidden/hiding states */
.gallery-item--hiding {
    opacity: 0.6;
    position: relative;
}

.gallery-item--hiding::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
    border-radius: var(--radius-xl);
}

.gallery-item--hidden {
    opacity: 0.4;
    position: relative;
    filter: grayscale(100%);
}

.gallery-item--hidden::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(100, 100, 100, 0.5);
    z-index: 1;
    border-radius: var(--radius-xl);
}

.gallery-item--hidden .gallery-item__hide-btn {
    opacity: 1;
    z-index: 4;
}

/* ==========================================================================
   Filter Components
   ========================================================================== */

.filter-group {
    margin-bottom: var(--space-2xl);
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    font-size: var(--font-size-base);
}

.filter-input {
    width: 100%;
    padding: var(--space-md);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--font-size-base);
}

.filter-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--focus-ring);
}

/* Date range inputs */
.date-range {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.date-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.date-input-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
}

/* Radio group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.radio-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.radio-item input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
}

.radio-item label {
    color: var(--color-text);
    font-size: var(--font-size-base);
    cursor: pointer;
    margin: 0;
}

/* Filter buttons */
.filter-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
}

.filter-btn {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn--primary {
    background: var(--color-accent);
    color: #fff;
}

.filter-btn--primary:hover {
    background: var(--color-accent-hover);
}

.filter-btn--secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1px solid var(--color-border-light);
}

.filter-btn--secondary:hover {
    background: var(--color-surface-elevated);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-sm) 0 var(--space-lg);
}

.pagination__btn {
    display: inline-flex;
    min-width: 44px;
    height: 36px;
    padding: 0 var(--space-md);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--color-surface-elevated);
    color: var(--color-text);
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.pagination__btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.pagination__btn:active {
    transform: translateY(0);
}

.pagination__btn--current {
    background: var(--color-surface);
    cursor: default;
    transform: none !important;
}

.pagination__btn--disabled {
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

/* ==========================================================================
   Floating Action Button
   ========================================================================== */

.float-btn {
    position: fixed;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-xl);
    display: none; /* Hidden by default */
}

.float-btn--filters {
    bottom: var(--space-2xl);
    right: var(--space-2xl);
    background: var(--color-accent);
    color: #fff;
}

.float-btn--filters:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.float-btn--filters:active {
    transform: translateY(0);
}

.float-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.float-btn:hover svg {
    transform: scale(1.1);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --container-padding: var(--space-lg);
    }
    
    .gallery-layout {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }
    
    .gallery-sidebar {
        position: static;
        order: 2;
        max-width: 600px;
        margin: 0 auto;
    }
    
    .gallery-content {
        order: 1;
    }
    
    /* Show floating filter button on small screens */
    .float-btn--filters {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --container-padding: var(--space-lg);
        --gallery-grid-min: 200px;
    }
    
    .content-wrapper {
        padding: var(--space-lg);
    }
    
    h1 {
        font-size: var(--font-size-3xl);
    }
    
    .gallery-sidebar {
        max-width: 500px;
        padding: var(--space-xl);
    }
    
    .filter-actions {
        flex-direction: column;
        gap: var(--space-md);
    }
}

/* Small mobile */
@media (max-width: 480px) {
    :root {
        --container-padding: var(--space-md);
        --gallery-grid-min: 180px;
        --grid-gap: var(--space-md);
    }
    
    .content-wrapper {
        padding: var(--space-lg);
    }
    
    .gallery-sidebar {
        padding: var(--space-xl);
        max-width: 100%;
        margin: var(--space-lg) 0 0 0;
    }
    
    /* Adjust floating button position on small mobile */
    .float-btn--filters {
        bottom: var(--space-xl);
        right: var(--space-xl);
        width: 52px;
        height: 52px;
    }
    
    .float-btn--filters svg {
        width: 22px;
        height: 22px;
    }
    
    .pagination {
        gap: var(--space-md);
        margin: var(--space-lg) 0 var(--space-2xl);
    }
    
    .pagination__btn {
        min-width: 52px;
        height: 44px;
        padding: 0 var(--space-lg);
        font-size: var(--font-size-lg);
        border-radius: var(--radius-xl);
    }
}

/* Large desktop */
@media (min-width: 1025px) {
    :root {
        --container-max-width: 1600px;
        --container-padding: 30px;
    }
}

@media (min-width: 1441px) {
    :root {
        --container-max-width: 2000px;
        --container-padding: 40px;
    }
}

@media (min-width: 1600px) {
    :root {
        --gallery-grid-min: 200px;
        --container-max-width: 2400px;
        --container-padding: 50px;
    }
    
    .gallery-layout {
        grid-template-columns: 360px 1fr;
    }
}

@media (min-width: 1921px) {
    :root {
        --gallery-grid-min: 220px;
        --container-max-width: 2800px;
        --container-padding: 60px;
    }
    
    .gallery-layout {
        grid-template-columns: 400px 1fr;
        gap: var(--space-3xl);
    }
    
    .gallery-sidebar {
        width: 400px;
    }
}

@media (min-width: 2560px) {
    :root {
        --gallery-grid-min: 240px;
        --container-max-width: 3200px;
        --container-padding: 80px;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }
.mb-6 { margin-bottom: var(--space-2xl); }