/* ============================================================
   br-images — BirdReel admin style
   Sidebar layout, blue accent, white cards
   ============================================================ */

:root {
    --sidebar-w: 220px;
    --accent: #3b82f6;
    --accent-strong: #2563eb;
    --accent-light: #dbeafe;
    --accent-glow: rgba(59, 130, 246, 0.12);
    --text: #1e293b;
    --text-2: #475569;
    --text-3: #64748b;
    --text-4: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --bg: #f8fafc;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body.no-sidebar { display: block; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 600; color: var(--text); margin: 0; }
h2 { font-size: 1.125rem; font-weight: 600; margin: 0 0 0.75rem; }
h3 { font-size: 0.9375rem; font-weight: 600; margin: 0 0 0.5rem; }
h4 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin: 1rem 0 0.5rem; }

/* ============================================ */
/* SIDEBAR (lifted directly from BirdReel admin) */
/* ============================================ */
.sidebar {
    width: var(--sidebar-w);
    background: #1e293b;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
    transition: width 0.2s ease;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: var(--sidebar-w);
}

.sidebar-logo {
    color: white;
    text-decoration: none;
    font-size: 1.0625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.sidebar-logo:hover { text-decoration: none; }
.sidebar-logo i { color: #60a5fa; flex-shrink: 0; }

.sidebar-toggle {
    background: none; border: none; color: #94a3b8;
    cursor: pointer; padding: 0.25rem; font-size: 1rem;
    line-height: 1; flex-shrink: 0; transition: color 0.15s;
}
.sidebar-toggle:hover { color: white; }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: var(--sidebar-w);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.8125rem;
    transition: all 0.15s;
    white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; text-decoration: none; }
.nav-item.active { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border-right: 3px solid #3b82f6; }
.nav-item i { width: 18px; text-align: center; font-size: 0.875rem; flex-shrink: 0; }

.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 0.5rem 0; }

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: var(--sidebar-w);
    overflow: hidden;
}
.user-name { font-size: 0.8125rem; font-weight: 500; color: white; white-space: nowrap; }
.user-role { font-size: 0.6875rem; color: #64748b; text-transform: capitalize; white-space: nowrap; }

body.sidebar-collapsed { --sidebar-w: 62px; }
body.sidebar-collapsed .nav-label { display: none; }
body.sidebar-collapsed .sidebar-logo span { display: none; }
body.sidebar-collapsed .user-name,
body.sidebar-collapsed .user-role { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0.625rem; gap: 0; }
body.sidebar-collapsed .nav-item i { width: auto; font-size: 1rem; }
body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 1.25rem 0; }
body.sidebar-collapsed .sidebar-toggle { margin: 0 auto; }
body.sidebar-collapsed .sidebar-footer { align-items: center; padding: 0.75rem 0; }

/* ============================================ */
/* MAIN CONTENT */
/* ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 1.5rem 1.75rem;
    min-height: 100vh;
    min-width: 0;
    max-width: calc(100vw - var(--sidebar-w));
    transition: margin-left 0.2s ease, max-width 0.2s ease;
}
.main-content.full { margin-left: 0; max-width: 100%; }

/* ============================================ */
/* PAGE HEADER */
/* ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; color: var(--text); }
.page-subtitle { color: var(--text-3); font-size: 0.8125rem; margin-top: 0.25rem; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.breadcrumbs { font-size: 0.8125rem; color: var(--text-3); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--accent-strong); }
.breadcrumbs .separator { margin: 0 0.375rem; }
.breadcrumbs .current { color: var(--text); font-weight: 500; }

/* ============================================ */
/* BUTTONS */
/* ============================================ */
.btn, .btn-primary, .btn-secondary, .btn-small, .btn-success, .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
    transition: all 0.15s;
}
.btn-primary { background: var(--accent-strong); color: white; border-color: var(--accent-strong); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; text-decoration: none; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: #f1f5f9; color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; text-decoration: none; }
.btn-secondary.disabled { opacity: 0.4; pointer-events: none; }
.btn-success { background: #dcfce7; color: #16a34a; border-color: #bbf7d0; }
.btn-success:hover { background: #bbf7d0; text-decoration: none; }
.btn-danger { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fecaca; text-decoration: none; }
.btn-small { padding: 0.3rem 0.625rem; font-size: 0.75rem; background: white; color: var(--text-2); border: 1px solid var(--border); }
.btn-small:hover { background: #f1f5f9; text-decoration: none; }

/* ============================================ */
/* CARDS / SUMMARY STATS */
/* ============================================ */
.summary-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}
.stat {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.125rem;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
    transition: box-shadow 0.15s, transform 0.15s;
}
.stat:hover { box-shadow: 0 4px 16px rgba(15,23,42,0.06); transform: translateY(-1px); }
.stat-num {
    font-size: 1.625rem; font-weight: 700;
    color: var(--text); letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat-label {
    font-size: 0.6875rem; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-top: 0.25rem; font-weight: 600;
}
.stat-mismatch .stat-num { color: #dc2626; }

@media (max-width: 1100px) { .summary-bar { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .summary-bar { grid-template-columns: repeat(2, 1fr); } }

/* ============================================ */
/* CONTROL PANEL */
/* ============================================ */
.control-panel, .control-bar {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.filter-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.filter-form select, .filter-form input[type=text] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: inherit;
    background: white;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-form select { cursor: pointer; min-width: 180px; }
.filter-form input[type=text] { min-width: 240px; }
.filter-form select:focus, .filter-form input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.action-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ============================================ */
/* JOB STATUS BAR */
/* ============================================ */
.job-status-bar {
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(180deg, #eff6ff 0%, #f5f8ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    margin-bottom: 1.25rem;
}
.job-row {
    display: flex; gap: 1rem; align-items: center;
    font-size: 0.8125rem; flex-wrap: wrap;
}
.job-label { font-weight: 600; color: #1e40af; }
.job-progress { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.job-meta { color: var(--text-3); font-size: 0.75rem; }
.job-state {
    padding: 0.2rem 0.55rem;
    background: var(--accent-strong);
    color: white;
    border-radius: 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

/* ============================================ */
/* DATA TABLE */
/* ============================================ */
.data-table {
    width: 100%;
    background: white;
    border: 1px solid var(--border);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.8125rem;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}
.data-table th {
    background: #f8fafc;
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 100ms ease; }
.data-table tbody tr:hover { background: #f8fafc; }

.image-table .thumb {
    width: 60px; height: 60px;
    object-fit: cover;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    display: block;
    transition: transform 150ms ease;
}
.image-table tbody tr:hover .thumb { transform: scale(1.06); }

.bird-name { font-size: 0.8125rem; font-weight: 500; }
.bird-name.match { color: #16a34a; }
.bird-name.match::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 0.3rem; opacity: 0.7; font-size: 0.7rem; }
.bird-name.mismatch { color: #dc2626; }
.bird-name.mismatch::before { content: "\f00d"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 0.3rem; opacity: 0.7; font-size: 0.7rem; }

.conf-line {
    font-size: 0.6875rem; color: var(--text-3);
    margin-top: 0.15rem; font-variant-numeric: tabular-nums;
}
.cred {
    font-size: 0.65rem; color: var(--text-2);
    background: #f1f5f9; padding: 0.1rem 0.45rem;
    border-radius: 3px; margin-left: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.meta-cell { font-size: 0.75rem; color: var(--text-3); line-height: 1.4; }
.muted { color: var(--text-4); font-size: 0.75rem; }
.mono {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
    font-size: 0.7rem;
    color: var(--text-3);
}

.empty { color: var(--text-3); font-style: italic; padding: 2rem; text-align: center; }
.empty-state {
    padding: 1.25rem;
    background: #fefce8;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    margin-bottom: 1rem;
    color: #78350f;
    font-size: 0.875rem;
}
.empty-state strong { color: #451a03; }
.error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-image { background: var(--accent-light); color: #1e40af; }
.badge-json { background: #dcfce7; color: #166534; }
.badge-other { background: #f1f5f9; color: var(--text-3); }
.badge-model { background: #ede9fe; color: #5b21b6; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* ============================================ */
/* PAGINATION */
/* ============================================ */
.pagination {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
}
.page-info { color: var(--text-3); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

/* ============================================ */
/* LOGIN */
/* ============================================ */
.main-content.full { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 2.25rem 2rem;
    border-radius: 14px;
    box-shadow: 0 10px 30px -10px rgba(15,23,42,0.18), 0 4px 8px -4px rgba(15,23,42,0.08);
    border: 1px solid var(--border);
}
.login-card .login-logo {
    width: 60px; height: 60px;
    margin: 0 auto 1.25rem;
    border-radius: 14px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem;
    color: #60a5fa;
    box-shadow: 0 12px 30px -8px rgba(30,41,59,0.4);
}
.login-card h1 { text-align: center; font-size: 1.375rem; margin-bottom: 0.25rem; }
.login-card .subtitle { text-align: center; color: var(--text-3); margin-bottom: 1.75rem; font-size: 0.875rem; }
.login-card form label {
    display: block;
    margin-bottom: 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-2);
    font-weight: 500;
}
.login-card input[type=text],
.login-card input[type=password] {
    display: block;
    width: 100%;
    margin-top: 0.375rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input[type=text]:focus,
.login-card input[type=password]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-card .checkbox {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: normal; font-size: 0.8125rem;
    margin-bottom: 1.25rem;
}
.login-card button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-strong);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.15s;
}
.login-card button:hover { background: #1d4ed8; transform: translateY(-1px); }

/* ============================================ */
/* VIEW PAGE (carousel + scan) */
/* ============================================ */
.view-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}
.carousel-nav { display: flex; align-items: center; gap: 0.875rem; font-size: 0.875rem; }
.carousel-nav .position {
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    background: #f1f5f9;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.key-title {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
    font-size: 0.75rem;
    color: var(--text-4);
    margin: 0 0 1rem;
    word-break: break-all;
    font-weight: normal;
}

.view-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 1.25rem;
}

.panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}
.panel-image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 480px;
    padding: 1.5rem;
    background:
        repeating-linear-gradient(45deg, #fafbfc 0 12px, #f3f5f8 12px 24px);
}
.bird-image {
    max-width: 100%;
    max-height: 70vh;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 20px 40px -16px rgba(15, 23, 42, 0.25), 0 4px 8px -4px rgba(15, 23, 42, 0.1);
    transition: transform 200ms ease;
}
.bird-image:hover { transform: scale(1.01); }

.meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-bottom: 0.875rem;
}
.meta-table tr { border-bottom: 1px solid var(--border); }
.meta-table tr:last-child { border-bottom: none; }
.meta-table th {
    text-align: left;
    padding: 0.55rem 0.5rem 0.55rem 0;
    color: var(--text-3);
    font-weight: 600;
    width: 110px;
    vertical-align: top;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.meta-table td { padding: 0.55rem 0; color: var(--text); }
.meta-table td strong { color: var(--text); font-size: 0.9375rem; }
.meta-table .mono { font-size: 0.7rem; word-break: break-all; }

.raw-json summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-3);
    padding: 0.4rem 0;
    font-weight: 500;
}
.raw-json summary:hover { color: var(--text); }
.raw-json pre {
    background: #0b1220;
    color: #d1d5db;
    padding: 0.875rem;
    border-radius: 8px;
    overflow: auto;
    max-height: 30vh;
    font-size: 0.7rem;
    margin-top: 0.5rem;
    line-height: 1.5;
    border: 1px solid #1e293b;
}

.ai-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.ai-controls {
    display: flex; align-items: end; gap: 0.75rem;
    flex-wrap: wrap; margin-bottom: 0.875rem;
}
.ai-controls label {
    font-size: 0.6875rem;
    color: var(--text-3);
    display: flex;
    flex-direction: column;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    gap: 0.25rem;
}
.ai-controls select {
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8125rem;
    background: white;
    font-family: inherit;
}
.ai-controls select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.force-label {
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.4rem !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: normal !important;
    font-size: 0.75rem !important;
    color: var(--text-3);
}

.ai-status {
    font-size: 0.8125rem;
    color: var(--text-3);
    min-height: 1.25rem;
    padding: 0.5rem 0;
}
.ai-status.error { color: #dc2626; }

.scan-card {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.875rem;
    margin-bottom: 0.625rem;
    box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}
.scan-card:hover { border-color: var(--border-strong); }
.scan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.scan-date { font-size: 0.7rem; color: var(--text-4); font-variant-numeric: tabular-nums; }
.scan-bird { font-size: 0.9375rem; color: var(--text); }
.scan-bird strong { font-weight: 600; }
.scan-bird.match strong { color: #16a34a; }
.scan-bird.mismatch strong { color: #dc2626; }
.scan-error { color: #dc2626; font-size: 0.8125rem; }
.scan-card details summary {
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-3);
    margin-top: 0.5rem;
    font-weight: 500;
}
.scan-card details pre {
    background: #0b1220;
    color: #d1d5db;
    padding: 0.625rem;
    border-radius: 6px;
    font-size: 0.7rem;
    overflow: auto;
    max-height: 200px;
    margin-top: 0.4rem;
    line-height: 1.5;
}

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */
@media (max-width: 900px) {
    .view-grid { grid-template-columns: 1fr; }
    .main-content { padding: 1rem; }
}
