/* ═══════════════════════════════════════════════════════════
   Noir Studio — Admin Dashboard
   ═══════════════════════════════════════════════════════════ */

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

:root {
    --bg-deep: #0a0a0a;
    --bg-dark: #111111;
    --bg-card: #161616;
    --bg-surface: #1a1a1a;
    --bg-elevated: #222222;
    --text-primary: #f0ece6;
    --text-secondary: rgba(240, 236, 230, 0.6);
    --text-muted: rgba(240, 236, 230, 0.4);
    --gold: #D4B483;
    --gold-light: #e8cfa0;
    --gold-dark: #b8975e;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --danger: #dc2626;
    --danger-light: #fca5a5;
    --success: #16a34a;
    --success-light: #86efac;
    --sidebar-width: 260px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-dark);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
}

.sidebar-brand span {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--gold);
    background: rgba(212, 180, 131, 0.08);
    border-right: 3px solid var(--gold);
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg,
.nav-item:hover svg {
    opacity: 1;
}

.nav-item.logout {
    color: var(--danger-light);
}

.nav-item.logout:hover {
    background: rgba(220, 38, 38, 0.08);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.5rem 0;
}

/* ─── Main wrapper ─────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Topbar ───────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
}

.topbar-title {
    font-size: 1.2rem;
    font-weight: 500;
    flex: 1;
}

.topbar-user {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ─── Content ──────────────────────────────────────────────── */
.content {
    flex: 1;
    padding: 2rem;
}

/* ─── Cards ────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.gold { background: rgba(212, 180, 131, 0.12); color: var(--gold); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.stat-icon.green { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.stat-icon.red { background: rgba(220, 38, 38, 0.12); color: #f87171; }

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1;
}

.stat-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ─── Card / Panel ─────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 500;
}

.card-body {
    padding: 1.5rem;
}

/* ─── Tables ───────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-gold { background: rgba(212, 180, 131, 0.15); color: var(--gold); }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-red { background: rgba(220, 38, 38, 0.15); color: #f87171; }
.badge-muted { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gold);
    color: #0a0a0a;
}

.btn-primary:hover {
    background: var(--gold-light);
    color: #0a0a0a;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(220, 38, 38, 0.15);
    color: var(--danger-light);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.25);
    color: var(--danger-light);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* ─── Forms ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--gold);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* ─── File upload ──────────────────────────────────────────── */
.file-upload {
    position: relative;
    border: 2px dashed var(--border-light);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s;
}

.file-upload:hover {
    border-color: var(--gold);
}

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.file-upload .upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ─── Image preview ────────────────────────────────────────── */
.img-preview {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.img-preview-large {
    max-width: 300px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* ─── Alert ────────────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--success-light);
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: var(--danger-light);
}

/* ─── Message list ─────────────────────────────────────────── */
.message-unread td {
    font-weight: 600;
}

.message-unread td:first-child {
    position: relative;
}

.message-unread td:first-child::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* ─── Message detail ───────────────────────────────────────── */
.message-detail {
    padding: 1.5rem;
}

.message-meta {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.message-meta div {
    font-size: 0.85rem;
}

.message-meta strong {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.message-body {
    background: var(--bg-deep);
    border-radius: 8px;
    padding: 1.25rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ─── Actions bar ──────────────────────────────────────────── */
.actions-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.actions-right {
    margin-left: auto;
}

/* ─── Gallery filters ──────────────────────────────────────── */
.gallery-filter-btn {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.gallery-filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--gold-dark);
}

.gallery-filter-btn.active {
    background: var(--gold);
    color: #0a0a0a;
    border-color: var(--gold);
}

/* ─── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.3;
}

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

/* ─── Confirm delete ───────────────────────────────────────── */
.confirm-delete {
    display: inline;
}

.confirm-delete .btn-danger {
    cursor: pointer;
}

/* ─── Welcome Banner ───────────────────────────────────────── */
.welcome-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(212, 180, 131, 0.1) 0%, rgba(212, 180, 131, 0.03) 100%);
    border: 1px solid rgba(212, 180, 131, 0.15);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.welcome-text h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--gold-light);
}

.welcome-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.welcome-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: capitalize;
    white-space: nowrap;
}

/* ─── Dashboard Grid ───────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ─── Quick Actions ────────────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.82rem;
    transition: all 0.2s;
    text-decoration: none;
}

.quick-action-btn:hover {
    border-color: var(--gold-dark);
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quick-action-icon.gold { background: rgba(212, 180, 131, 0.12); color: var(--gold); }
.quick-action-icon.blue { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.quick-action-icon.red { background: rgba(220, 38, 38, 0.12); color: #f87171; }
.quick-action-icon.green { background: rgba(34, 197, 94, 0.12); color: #4ade80; }

/* ─── Category Breakdown ──────────────────────────────────── */
.category-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.category-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-bar-label {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.category-bar-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.category-bar-track {
    height: 8px;
    background: var(--bg-deep);
    border-radius: 4px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 4px;
}

/* ─── Recent Photos Grid ──────────────────────────────────── */
.recent-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.recent-photo-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    display: block;
}

.recent-photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.recent-photo-card:hover img {
    transform: scale(1.05);
}

.recent-photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.recent-photo-card:hover .recent-photo-overlay {
    opacity: 1;
}

.recent-photo-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
}

.recent-photo-cat {
    font-size: 0.65rem;
    color: var(--gold-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ─── Demo Mode ────────────────────────────────────────────── */
body.demo-mode .main-wrapper .content {
    padding-bottom: 5rem !important;
}

.demo-bottombar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 200;
    background: linear-gradient(135deg, var(--gold-dark) 0%, #a07840 100%);
    color: #0a0a0a;
    padding: 0.5rem 1.5rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.demo-bottombar svg {
    flex-shrink: 0;
    opacity: 0.8;
    color: #0a0a0a;
}

.demo-bottombar span {
    text-align: center;
}

.demo-bottombar-link {
    color: var(--gold-light);
    background: rgba(10, 10, 10, 0.25);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
}

.demo-bottombar-link:hover {
    background: rgba(10, 10, 10, 0.4);
    color: #fff;
}

.demo-badge-sm {
    background: rgba(212, 180, 131, 0.15);
    color: var(--gold);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    letter-spacing: 2px;
}

/* ─── Demo Modal ───────────────────────────────────────────── */
.demo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.demo-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.demo-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2.5rem 2rem 2rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    transform: scale(0.9) translateY(10px);
    transition: transform 0.25s ease;
}

.demo-modal-overlay.active .demo-modal {
    transform: scale(1) translateY(0);
}

.demo-modal-icon {
    color: var(--gold);
    margin-bottom: 1rem;
}

.demo-modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.demo-modal-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.demo-modal-btn {
    background: var(--gold);
    color: #0a0a0a;
    border: none;
    border-radius: 8px;
    padding: 0.65rem 2rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 0.5px;
}

.demo-modal-btn:hover {
    background: var(--gold-light);
}

/* Disable settings form in demo mode */
.demo-mode form[action*="/settings"] button[type="submit"] {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .content {
        padding: 1rem;
    }

    .topbar {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .welcome-banner {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .recent-photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .message-meta {
        gap: 1rem;
    }

    .demo-bottombar {
        left: 0;
    }
}

@media (max-width: 480px) {
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-right {
        margin-left: 0;
    }
}
