/* ============================
   CSS VARIABLES & THEMES
   ============================ */

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --header-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;
    --primary: #16a34a;
    --primary-hover: #15803d;
    --primary-soft: rgba(22, 163, 74, 0.1);
    --accent: #ec4899;
    --accent-soft: rgba(236, 72, 153, 0.1);
    --success: #10b981;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.3);
    --overlay-bg: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] {
    --bg-primary: #16181d;
    --bg-secondary: #1c1e24;
    --bg-tertiary: #23252c;
    --header-bg: #0c0d10;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --border-color: #2a2c34;
    --border-subtle: #1e2028;
    --primary: #4ade80;
    --primary-hover: #22c55e;
    --primary-soft: rgba(74, 222, 128, 0.12);
    --accent: #f472b6;
    --accent-soft: rgba(244, 114, 182, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.6);
    --glass-bg: rgba(12, 13, 16, 0.95);
    --glass-border: rgba(255, 255, 255, 0.06);
    --overlay-bg: rgba(0, 0, 0, 0.75);
}

/* ============================
   RESET & BASE
   ============================ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

/* ============================
   HEADER
   ============================ */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
}

[data-theme="dark"] .header {
    background: var(--header-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.header-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -0.03em;
}

.logo img {
    max-height: 36px;
    vertical-align: middle;
}

/* Search Bar */
.search-bar {
    flex: 1;
    max-width: 480px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar .search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-kbd {
    position: absolute;
    right: 10px;
    font-family: inherit;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Nav */
.nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auth-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================
   BUTTONS
   ============================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.4rem 0.75rem;
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon-text {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon-text:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-icon-text.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.btn-download {
    font-weight: 600;
    padding: 0.625rem 1.25rem;
}

/* Main content area */
.main-content {
    padding-top: 1.5rem;
}

/* ============================
   TOOLBAR
   ============================ */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.category-nav {
    display: flex;
    gap: 0.375rem;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-xl);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.cat-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.cat-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.sort-controls {
    display: flex;
    align-items: center;
}

.sort-select {
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: border-color var(--transition);
}

.sort-select:focus {
    border-color: var(--primary);
}

/* ============================
   GALLERY GRID
   ============================ */

.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.wallpaper-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    cursor: pointer;
    aspect-ratio: 16/9;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.wallpaper-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.wallpaper-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.wallpaper-card:hover img {
    transform: scale(1.03);
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.1) 40%, transparent 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
}

.wallpaper-card:hover .card-overlay {
    opacity: 1;
}

.card-info {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
}

.card-title {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.card-resolution {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 2px;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.card-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: none;
    color: white;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    transition: background var(--transition);
}

.card-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.card-action-btn.liked {
    color: #f87171;
}

.card-action-btn.liked svg {
    fill: #f87171;
}

/* ============================
   LOADING & EMPTY STATES
   ============================ */

.loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    gap: 1rem;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* ============================
   PAGINATION
   ============================ */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.375rem;
    margin-top: 2.5rem;
    padding-bottom: 1rem;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}

.page-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================
   DETAIL MODAL
   ============================ */

.detail-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
}

.detail-modal.open {
    display: flex;
}

.detail-backdrop {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
}

.detail-panel {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.detail-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.detail-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-width: 0;
    background: #000;
    position: relative;
    /* Add position relative to contain the absolute nav buttons */
}

.detail-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    z-index: 10;
}

/* Image Navigation Buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
}

.detail-image-wrap:hover .nav-btn {
    opacity: 1;
    visibility: visible;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: 2rem;
}

.next-btn {
    right: 2rem;
}

.nav-btn svg {
    width: 24px;
    height: 24px;
}

/* Crop Controls (inside sidebar) */
.crop-controls {
    display: none;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding: 1rem 1.5rem;
    transition: all var(--transition);
}

.crop-controls.show {
    display: flex;
}

/* Ensure cropper container doesn't overflow modal */
.cropper-container {
    border-radius: var(--radius-md);
}

/* Custom Cropper Styles for Mobile Look */
.cropper-modal {
    opacity: 0.9 !important;
    background-color: #000 !important;
}

.cropper-view-box {
    border-radius: 8px !important;
    outline: 2px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5) !important;
}

/* Hide grid lines for a cleaner look */
.cropper-line,
.cropper-dashed,
.cropper-point,
.cropper-center {
    display: none !important;
}

.detail-sidebar {
    width: 380px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.detail-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.detail-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.detail-meta-item svg {
    width: 14px;
    height: 14px;
}

.detail-actions {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: center;
    /* Ensure vertical alignment */
}

/* Share Dropdown */
.share-container {
    position: relative;
    display: inline-block;
}

.share-dropdown {
    position: absolute;
    bottom: 100%;
    /* Show above the button */
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 0.5rem;
    min-width: 180px;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.share-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

.share-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.share-option svg {
    flex-shrink: 0;
}

.share-option:hover {
    background: var(--bg-tertiary);
}

/* Brand Colors on Hover */
.share-option.share-facebook:hover {
    color: #1877F2;
    background: rgba(24, 119, 242, 0.1);
}

.share-option.share-twitter:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.share-option.share-pinterest:hover {
    color: #E60023;
    background: rgba(230, 0, 35, 0.1);
}

.share-option.share-linkedin:hover {
    color: #0A66C2;
    background: rgba(10, 102, 194, 0.1);
}

.share-option.share-whatsapp:hover {
    color: #25D366;
    background: rgba(37, 211, 102, 0.1);
}

.share-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.share-option.share-copy:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.detail-stats {
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

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

.stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.detail-tags {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.detail-tags:empty {
    display: none;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-xl);
    text-decoration: none;
    transition: background var(--transition);
}

.tag-chip:hover {
    background: var(--primary);
    color: white;
}

.tag-chip-name {
    color: inherit;
    text-decoration: none;
}

.tag-chip-name:hover {
    text-decoration: underline;
}

.tag-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition);
    padding: 0;
    margin-left: 2px;
}

.tag-chip-remove:hover {
    opacity: 1;
}

/* Tag input */
.tag-input-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tag-add-input {
    width: 120px;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), width var(--transition);
}

.tag-add-input::placeholder {
    color: var(--text-muted);
}

.tag-add-input:focus {
    border-color: var(--primary);
    border-style: solid;
    width: 180px;
}

.tag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 200px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 300;
}

.tag-dropdown-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition);
}

.tag-dropdown-item:hover,
.tag-dropdown-item.active {
    background: var(--bg-tertiary);
}

.tag-dropdown-create {
    color: var(--primary);
    font-weight: 500;
    font-style: italic;
}

/* Comments in Detail */
.detail-comments {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    min-height: 0;
}

.comments-heading {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    max-height: 300px;
}

.comment-item {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.comment-author {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.comment-author strong {
    color: var(--text-primary);
}

.comment-author .admin-badge {
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 600;
}

.comment-body {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.5;
}

.comment-form {
    margin-top: auto;
}

.comment-form textarea {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    resize: vertical;
    min-height: 60px;
    outline: none;
    transition: border-color var(--transition);
}

.comment-form textarea:focus {
    border-color: var(--primary);
}

.comment-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

/* ============================
   FOOTER
   ============================ */

.site-footer {
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
    padding: 1.5rem 0;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--text-primary);
}

/* ============================
   STATUS MESSAGES
   ============================ */

.status-msg {
    font-size: 0.8rem;
}

.status-success {
    color: var(--success);
}

.status-error {
    color: var(--danger);
}

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

/* ============================
   ADMIN STYLES
   ============================ */

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.admin-container {
    max-width: 900px;
    margin: 0 auto;
    transition: max-width var(--transition);
}

.admin-container.wide-container {
    max-width: 1600px;
}

.admin-tabs {
    display: flex;
    gap: 0.35rem;
    border-bottom: none;
    margin-bottom: 0;
    overflow-x: auto;
    position: relative;
    z-index: 10;
    padding-left: 1rem;
    /* Slight indent from the card's left edge */
}

.tab-btn {
    padding: 0.8rem 1.5rem;
    border: 1px solid transparent;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    white-space: nowrap;
    position: relative;
    top: 1px;
    /* Overlap the card border below */
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--border-color);
}

.tab-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-bottom: 1px solid var(--bg-secondary);
    /* Hide the card's top border */
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-muted);
    gap: 0.5rem;
}

.file-label:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.file-label input[type="file"] {
    display: none;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.admin-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    gap: 0.75rem;
    transition: transform var(--transition);
}

.admin-grid .admin-item {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 1rem;
    gap: 1rem;
}

.admin-grid .admin-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary-soft);
}

.sortable-ghost {
    opacity: 0.3;
    border: 2px dashed var(--primary);
    background: var(--primary-soft);
}

.sortable-drag {
    opacity: 1;
    box-shadow: var(--shadow-xl);
    transform: scale(1.02);
    cursor: grabbing !important;
}

.admin-item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    flex: 1;
}

.admin-grid .admin-item-info {
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
}

.admin-item img {
    width: 72px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    cursor: pointer;
}

.admin-grid .admin-item img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.admin-item-text {
    overflow: hidden;
}

.admin-item-text strong {
    font-size: 0.85rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-item-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.category-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.5rem;
    margin-top: 0.25rem;
}

/* Bulk toolbar */
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.bulk-toolbar label {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-secondary);
}

.bulk-toolbar input[type="checkbox"] {
    transform: scale(1.1);
}

.tags-chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.admin-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    font-size: 0.8rem;
    transition: all var(--transition);
}

.admin-tag-chip strong {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.admin-tag-chip strong:hover {
    color: var(--primary);
    text-decoration: underline;
}

.admin-tag-chip span.count {
    color: var(--text-muted);
    font-size: 0.7rem;
    pointer-events: none;
}

.admin-tag-chip button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.125rem;
    font-size: 1rem;
    line-height: 1;
    margin-left: 0.25rem;
    opacity: 0.6;
    transition: opacity var(--transition), color var(--transition);
}

.admin-tag-chip button:hover {
    opacity: 1;
    color: var(--danger);
}

/* ============================
   LOGIN PAGE
   ============================ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* ============================
   PREMIUM AUTHENTICATION PAGE
   ============================ */

.premium-auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background: #0f172a;
    /* Deep dark fallback */
}

/* Abstract animated background elements */
.premium-auth-container::before,
.premium-auth-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 0;
    animation: drift 25s infinite alternate ease-in-out;
}

.premium-auth-container::before {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, transparent 70%);
    top: -20vh;
    left: -20vw;
}

.premium-auth-container::after {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.2) 0%, transparent 70%);
    bottom: -10vh;
    right: -10vw;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(10%, 10%) scale(1.1);
    }
}

/* Glassmorphism Card */
.glass-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 440px;
    background: rgba(20, 25, 35, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    color: #f1f5f9;
}

/* Wide layout for active flip/desktop */
.glass-card-wide {
    max-width: 880px;
    display: flex;
    gap: 3rem;
    overflow: hidden;
    padding: 0;
}

.glass-col {
    flex: 1;
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
}

.glass-divider {
    width: 1px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.1) 20%, rgba(255, 255, 255, 0.1) 80%, transparent);
}

.auth-header {
    text-align: left;
    margin-bottom: 2.5rem;
}

.auth-header h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Premium Form Elements */
.premium-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.875rem 1rem 0.875rem 2.5rem;
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.premium-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.premium-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(167, 139, 250, 0.5);
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.1);
}

.input-icon-wrap {
    position: relative;
    margin-bottom: 1.25rem;
}

.input-icon-wrap svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
    width: 18px;
    height: 18px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.premium-input:focus+svg,
.input-icon-wrap:focus-within svg {
    color: #a78bfa;
}

/* Premium Button */
.btn-premium {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
    filter: brightness(1.1);
}

.btn-premium:active {
    transform: translateY(1px);
}

/* Social Login */
.social-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.social-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.social-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.or-divider:not(:empty)::before {
    margin-right: .5em;
}

.or-divider:not(:empty)::after {
    margin-left: .5em;
}

/* Desktop layout hide/show logic */
.auth-panel-hidden {
    display: none !important;
}

@media (max-width: 800px) {
    .glass-card-wide {
        flex-direction: column;
        max-width: 440px;
        gap: 0;
    }

    .glass-divider {
        width: 100%;
        height: 1px;
        background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1), transparent);
    }

    .desktop-only {
        display: none !important;
    }
}

/* ============================
   USER PROFILE
   ============================ */

.profile-container {
    max-width: 900px;
    margin: 0 auto;
}

.profile-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
    border: 2px solid var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 3rem;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
}

.profile-username {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
    max-width: 600px;
}

.profile-stats {
    display: flex;
    gap: 1.5rem;
}

.profile-stat {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.profile-stat strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.profile-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
    overflow-x: auto;
}

.profile-content {
    min-height: 400px;
}

.status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 5;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-pending {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
}

.status-approved {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

.upload-form-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 1024px) {
    .detail-panel {
        flex-direction: column;
    }

    .detail-image-wrap {
        flex: none;
        height: 45vh;
        padding: 1rem;
    }

    .detail-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 55vh;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .header-container {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .search-bar {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
    }

    .search-kbd {
        display: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .cat-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        scrollbar-width: none;
    }

    .cat-list::-webkit-scrollbar {
        display: none;
    }

    .wallpaper-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 0.75rem;
    }

    .footer-inner {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .detail-sidebar {
        width: 100%;
    }

    .detail-image-wrap {
        flex: 1 1 auto;
        height: auto;
        min-height: 55vh;
    }

    .detail-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }

    .nav-btn {
        opacity: 0.8;
        visibility: visible;
    }

    .prev-btn {
        left: 0.5rem;
    }

    .next-btn {
        right: 0.5rem;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-stats {
        justify-content: center;
        flex-wrap: wrap;
    }

    .wallpaper-card .card-actions {
        pointer-events: none;
    }

    .nav-btn {
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .nav-btn.nav-visible {
        opacity: 0.8;
        visibility: visible;
    }
}

@media (max-width: 480px) {
    .wallpaper-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}