/* ══════════════════════════════════════════════════
   NSFW Detector Dashboard — Styles
   ══════════════════════════════════════════════════ */

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3348;
    --text: #e4e6f0;
    --text-dim: #8b8fa8;
    --accent: #6c5ce7;
    --accent-hover: #7f71ef;
    --green: #00b894;
    --green-bg: rgba(0, 184, 148, 0.12);
    --red: #ff6b6b;
    --red-bg: rgba(255, 107, 107, 0.12);
    --yellow: #feca57;
    --yellow-bg: rgba(254, 202, 87, 0.12);
    --blue: #54a0ff;
    --blue-bg: rgba(84, 160, 255, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

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

/* ─── HEADER ─── */
header {
    background: linear-gradient(135deg, #1a1d27 0%, #2d1f5e 100%);
    border-bottom: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.95rem;
}

.header-auth {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-badge {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
}

.logout-btn {
    background: rgba(255, 107, 107, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 107, 107, 0.3);
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.3);
    border-color: var(--red);
}

/* ─── LOGIN PAGE ─── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1035 50%, #0f1117 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 3rem;
    margin-bottom: 0.25rem;
}

.login-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.login-field {
    margin-bottom: 1.25rem;
}

.login-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-field input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.login-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

.login-btn {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 0.5rem;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-btn:active {
    transform: scale(0.98);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 1.5rem;
}

/* ─── CONTROLS ─── */
.controls {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.control-group {
    flex: 1;
    min-width: 300px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.control-group h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

input[type="text"],
input[type="number"] {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"] {
    flex: 1;
    min-width: 180px;
}

input[type="number"] {
    width: 75px;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--accent);
}

input[type="file"] {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.threshold-label,
.checkbox-label {
    color: var(--text-dim);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

button:hover {
    background: var(--accent-hover);
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── STATUS BAR ─── */
.status-bar {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0.8rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.status-bar.done {
    animation: none;
    border-color: var(--green);
}

.status-bar.error {
    animation: none;
    border-color: var(--red);
}

.hidden {
    display: none !important;
}

/* ─── SUMMARY CARDS ─── */
.summary-section {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: transform 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card .card-number {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
}

.summary-card .card-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
    display: block;
}

.summary-card.total .card-number {
    color: var(--blue);
}

.summary-card.safe .card-number {
    color: var(--green);
}

.summary-card.nsfw .card-number {
    color: var(--red);
}

.summary-card.errors .card-number {
    color: var(--yellow);
}

/* ─── FILTER TABS ─── */
.filter-section {
    max-width: 1200px;
    margin: 1.25rem auto 0.5rem;
    padding: 0 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--surface2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    font-size: 0.82rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
}

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

/* ─── RESULTS GRID ─── */
.results-grid {
    max-width: 1200px;
    margin: 1rem auto 2rem;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.image-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.image-card .badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

.badge.safe {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid var(--green);
}

.badge.nsfw {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red);
}

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

.image-card .thumb-wrap {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-card .thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.image-card:hover .thumb-wrap img {
    transform: scale(1.05);
}

.image-card .card-info {
    padding: 0.85rem 1rem;
}

.image-card .card-info .filename {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.4rem;
}

.image-card .card-info .score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.score-bar {
    flex: 1;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    margin-left: 0.6rem;
    overflow: hidden;
}

.score-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.score-bar .fill.low {
    background: var(--green);
}

.score-bar .fill.mid {
    background: var(--yellow);
}

.score-bar .fill.high {
    background: var(--red);
}

/* Category mini bars */
.categories-mini {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.cat-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: var(--surface2);
    color: var(--text-dim);
}

/* ─── MODAL ─── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    color: var(--text-dim);
    font-size: 1.6rem;
    padding: 0.2rem 0.5rem;
    z-index: 10;
}

.modal-close:hover {
    color: var(--red);
    background: none;
}

.modal-body {
    display: flex;
    flex-wrap: wrap;
}

.modal-image-wrap {
    flex: 1;
    min-width: 280px;
    max-height: 500px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.modal-image-wrap img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.modal-details {
    flex: 1;
    min-width: 260px;
    padding: 1.5rem;
}

.modal-details h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    word-break: break-all;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.detail-row .label {
    color: var(--text-dim);
}

.detail-row .value {
    font-weight: 600;
}

.detail-row .value.nsfw-true {
    color: var(--red);
}

.detail-row .value.nsfw-false {
    color: var(--green);
}

/* Category bars in modal */
.cat-bar-group {
    margin-top: 1rem;
}

.cat-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
    font-size: 0.85rem;
}

.cat-bar-row .cat-name {
    width: 65px;
    color: var(--text-dim);
    text-align: right;
}

.cat-bar-row .cat-bar {
    flex: 1;
    height: 10px;
    background: var(--surface2);
    border-radius: 5px;
    overflow: hidden;
}

.cat-bar-row .cat-bar .cat-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.cat-bar-row .cat-val {
    width: 48px;
    text-align: right;
    font-weight: 600;
    font-size: 0.8rem;
}

/* ─── LOGS ─── */
.logs-section {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem 3rem;
}

.logs-section h2 {
    margin-bottom: 0.75rem;
}

.logs-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
}

.log-item .log-name {
    font-weight: 600;
    word-break: break-all;
}

.log-item .log-meta {
    color: var(--text-dim);
    font-size: 0.78rem;
}

.log-item a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.log-item a:hover {
    text-decoration: underline;
}

/* ─── FOOTER ─── */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-dim);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
}

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

/* ─── RESPONSIVE ─── */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.4rem;
    }

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

    .modal-body {
        flex-direction: column;
    }

    .modal-image-wrap {
        max-height: 300px;
    }
}