/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    line-height: 1.5;
}
a { color: #6c9fff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login ────────────────────────────────────────── */
.login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #1a1a2e; border: 1px solid #2a2a4a;
    border-radius: 12px; padding: 40px; width: 360px;
    text-align: center;
}
.login-box h1 { font-size: 24px; margin-bottom: 24px; color: #fff; }
.login-box input[type="password"] {
    width: 100%; padding: 12px 16px; border: 1px solid #3a3a5a;
    border-radius: 8px; background: #0f0f1a; color: #fff;
    font-size: 16px; margin-bottom: 16px; outline: none;
}
.login-box input[type="password"]:focus { border-color: #6c9fff; }
.login-error { color: #ff6b6b; font-size: 14px; margin-bottom: 12px; display: none; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-block; padding: 10px 20px;
    border: none; border-radius: 8px; cursor: pointer;
    font-size: 14px; font-weight: 500; transition: all 0.2s;
}
.btn-primary { background: #6c9fff; color: #000; }
.btn-primary:hover { background: #8ab4ff; }
.btn-danger { background: #ff6b6b; color: #fff; }
.btn-danger:hover { background: #ff8a8a; }
.btn-secondary { background: #2a2a4a; color: #e0e0e0; }
.btn-secondary:hover { background: #3a3a5a; }
.btn-success { background: #4ecdc4; color: #000; }
.btn-success:hover { background: #6eddd6; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ── Admin Layout ─────────────────────────────────── */
.admin-app { display: none; height: 100vh; flex-direction: column; }
.admin-app.active { display: flex; }

.admin-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px; background: #1a1a2e; border-bottom: 1px solid #2a2a4a;
}
.admin-header h1 { font-size: 18px; color: #fff; }
.admin-header .header-actions { display: flex; gap: 12px; align-items: center; }

.admin-body { display: flex; flex: 1; overflow: hidden; }

/* ── Tabs ─────────────────────────────────────────── */
.admin-tabs {
    display: flex; gap: 0; background: #1a1a2e; border-bottom: 1px solid #2a2a4a;
    padding: 0 24px;
}
.tab-btn {
    padding: 12px 20px; background: none; border: none;
    color: #888; cursor: pointer; font-size: 14px;
    border-bottom: 2px solid transparent; transition: all 0.2s;
}
.tab-btn:hover { color: #ccc; }
.tab-btn.active { color: #6c9fff; border-bottom-color: #6c9fff; }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 24px; }
.tab-content.active { display: block; }

/* ── Cards / Panels ───────────────────────────────── */
.panel {
    background: #1a1a2e; border: 1px solid #2a2a4a;
    border-radius: 12px; padding: 24px; margin-bottom: 20px;
}
.panel h2 { font-size: 18px; margin-bottom: 16px; color: #fff; }
.panel h3 { font-size: 15px; margin-bottom: 12px; color: #ccc; }

/* ── Forms ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; color: #aaa;
    margin-bottom: 6px; font-weight: 500;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="color"],
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid #3a3a5a;
    border-radius: 8px; background: #0f0f1a; color: #fff;
    font-size: 14px; outline: none; font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #6c9fff; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-inline { display: flex; gap: 8px; align-items: flex-end; }
.form-inline .form-group { flex: 1; }
.form-hint { font-size: 12px; color: #666; margin-top: 4px; }

/* ── Tables ───────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 10px 14px; text-align: left;
    border-bottom: 1px solid #2a2a4a;
}
.data-table th {
    font-size: 12px; text-transform: uppercase;
    color: #888; font-weight: 600; letter-spacing: 0.5px;
}
.data-table tr:hover { background: rgba(108,159,255,0.05); }
.data-table .thumb {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; background: #2a2a4a;
}
.data-table .thumb-failed {
    background: #3a1a1a; border: 2px solid #ff6b6b;
    position: relative;
}
.data-table .thumb-failed::after {
    content: '!'; color: #ff6b6b; font-weight: 700; font-size: 18px;
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.data-table .actions { white-space: nowrap; }
.data-table input[type="checkbox"] { cursor: pointer; }

/* ── Timeline List ────────────────────────────────── */
.timeline-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; background: #1a1a2e; border: 1px solid #2a2a4a;
    border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: all 0.2s;
}
.timeline-card:hover { border-color: #6c9fff; }
.timeline-card .tl-info h3 { color: #fff; margin-bottom: 4px; font-size: 16px; }
.timeline-card .tl-info p { color: #888; font-size: 13px; }
.timeline-card .tl-meta { display: flex; gap: 12px; align-items: center; }
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.badge-published { background: rgba(78,205,196,0.15); color: #4ecdc4; }
.badge-draft { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.badge-type {
    background: rgba(108,159,255,0.15); color: #6c9fff;
    padding: 2px 8px; border-radius: 8px; font-size: 11px;
}

/* ── Entity Form ──────────────────────────────────── */
.tag-input-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #2a2a4a; color: #ccc; padding: 4px 10px;
    border-radius: 16px; font-size: 12px;
}
.tag-chip .remove { cursor: pointer; color: #ff6b6b; font-weight: bold; }

/* ── Image Upload ─────────────────────────────────── */
.upload-zone {
    border: 2px dashed #3a3a5a; border-radius: 12px;
    padding: 30px; text-align: center; cursor: pointer;
    transition: all 0.2s; color: #888;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: #6c9fff; background: rgba(108,159,255,0.05);
}
.upload-zone img { max-width: 120px; max-height: 120px; border-radius: 8px; margin-top: 8px; }

/* ── AI Chat Panel ────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; height: 100%; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 16px;
}
.chat-msg { max-width: 90%; padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.chat-msg.user { background: #2a2a4a; align-self: flex-end; }
.chat-msg.assistant { background: #1a1a2e; border: 1px solid #2a2a4a; align-self: flex-start; }
.chat-input-area {
    padding: 16px; border-top: 1px solid #2a2a4a;
    display: flex; gap: 8px; align-items: flex-end;
}
.chat-input-area textarea {
    flex: 1; padding: 10px 14px; border: 1px solid #3a3a5a;
    border-radius: 8px; background: #0f0f1a; color: #fff;
    font-size: 14px; outline: none; resize: none;
    min-height: 44px; max-height: 120px; font-family: inherit;
}
.chat-input-area textarea:focus { border-color: #6c9fff; }

/* ── Extracted Entity Cards ───────────────────────── */
.extracted-entities { display: flex; flex-direction: column; gap: 12px; }
.extracted-card {
    background: #0f0f1a; border: 1px solid #2a2a4a;
    border-radius: 10px; padding: 16px;
}
.extracted-card .ec-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.extracted-card .ec-header h4 { color: #fff; font-size: 15px; flex: 1; }
.extracted-card .ec-thumb {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    border: 2px solid #3a3a5a; margin-right: 10px; flex-shrink: 0;
}
.extracted-card .ec-field { margin-bottom: 8px; }
.extracted-card .ec-field label { font-size: 11px; color: #888; display: block; margin-bottom: 2px; }
.extracted-card .ec-field input,
.extracted-card .ec-field textarea,
.extracted-card .ec-field select {
    width: 100%; padding: 6px 10px; border: 1px solid #3a3a5a;
    border-radius: 6px; background: #1a1a2e; color: #fff;
    font-size: 13px; outline: none; font-family: inherit;
}
.extracted-card .ec-row { display: flex; gap: 8px; }
.extracted-card .ec-row .ec-field { flex: 1; }

/* ── Modals ───────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); display: flex;
    align-items: center; justify-content: center; z-index: 1000;
}
.modal {
    background: #1a1a2e; border: 1px solid #2a2a4a;
    border-radius: 16px; padding: 32px; width: 560px;
    max-width: 95vw; max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 20px; color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ── Toolbar ──────────────────────────────────────── */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.toolbar .search-box {
    padding: 8px 14px; border: 1px solid #3a3a5a; border-radius: 8px;
    background: #0f0f1a; color: #fff; font-size: 14px; outline: none;
    width: 240px;
}
.toolbar .search-box:focus { border-color: #6c9fff; }
.toolbar .filter-group { display: flex; gap: 8px; align-items: center; }
.toolbar select {
    padding: 8px 12px; border: 1px solid #3a3a5a; border-radius: 8px;
    background: #0f0f1a; color: #fff; font-size: 13px; outline: none;
}

/* ── Loading / Spinner ────────────────────────────── */
.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid #3a3a5a; border-top-color: #6c9fff;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
    display: flex; align-items: center; justify-content: center;
    padding: 40px; color: #888;
}

/* ── Toast Notifications ──────────────────────────── */
.toast-container {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px; z-index: 2000;
}
.toast {
    padding: 12px 20px; border-radius: 10px;
    font-size: 14px; animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast-success { background: #1a3a2e; color: #4ecdc4; border: 1px solid #2a5a4a; }
.toast-error { background: #3a1a1a; color: #ff6b6b; border: 1px solid #5a2a2a; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
    .form-row { flex-direction: column; }
    .modal { width: 100%; margin: 16px; }
    .toolbar { flex-direction: column; }
    .toolbar .search-box { width: 100%; }
}
