/* ─── Components ─────────────────────────────────────────────────────────────
   Status badges, data tables, modals, loaders, toast notifications
   All components reference design tokens from style.css
──────────────────────────────────────────────────────────────────────────── */

/* ── Loader ──────────────────────────────────────────────────────────────── */
.app-loader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--clr-bg);
    z-index: 9999;
    transition: opacity 0.3s ease;
}

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

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

/* ── Status Badges ────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-intake       { background: rgba(99,102,241,0.12); color: #818cf8; }
.badge-triage       { background: rgba(245,158,11,0.12);  color: #fbbf24; }
.badge-inprogress   { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.badge-waiting      { background: rgba(168,85,247,0.12);  color: #c084fc; }
.badge-blocked      { background: rgba(239,68,68,0.12);   color: #f87171; }
.badge-review       { background: rgba(20,184,166,0.12);  color: #2dd4bf; }
.badge-resolved     { background: rgba(16,185,129,0.12);  color: #34d399; }
.badge-closed       { background: rgba(161,161,170,0.12); color: #a1a1aa; }

.badge-priority-low      { background: rgba(161,161,170,0.1); color: #a1a1aa; }
.badge-priority-normal   { background: rgba(59,130,246,0.1);  color: #60a5fa; }
.badge-priority-high     { background: rgba(245,158,11,0.1);  color: #fbbf24; }
.badge-priority-critical { background: rgba(239,68,68,0.1);   color: #f87171; }

.badge-health-good      { background: rgba(16,185,129,0.1);  color: #34d399; }
.badge-health-attention { background: rgba(245,158,11,0.1);  color: #fbbf24; }
.badge-health-risk      { background: rgba(239,68,68,0.1);   color: #f87171; }
.inline-status-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    margin: -0.25rem; /* pull out to expand hitbox slightly */
    padding: 0.4rem 1.8rem 0.4rem 0.75rem; /* Extra right padding for arrow */
    border-radius: var(--radius-full);
    
    /* CSS Chevron */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-color: transparent; /* fallback */
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.inline-status-select:hover {
    filter: brightness(0.95);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

/* ── Data Table ───────────────────────────────────────────────────────────── */
.data-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--clr-border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    padding: 0.875rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
}

.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--clr-text-main);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    background: var(--clr-surface);
    transition: var(--transition);
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: var(--clr-surface-hover);
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--clr-text-muted);
    gap: 1rem;
}

.empty-state-full i {
    width: 40px;
    height: 40px;
    opacity: 0.3;
}

.empty-state-full p {
    font-size: 0.95rem;
    max-width: 320px;
    line-height: 1.6;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

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

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

.modal-header h3 {
    font-size: 1.15rem;
    font-family: var(--font-heading);
}

.modal-close {
    background: none;
    border: none;
    color: var(--clr-text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    transition: var(--transition);
}

.modal-close:hover { color: var(--clr-text-main); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--clr-border);
}

/* ── Form Controls ───────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 1.25rem; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    color: var(--clr-text-main);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

select.form-control option { background: var(--clr-surface); }

/* ── Sidebar Logout Button ───────────────────────────────────────────────── */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--clr-text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-md);
    display: flex;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-logout:hover {
    background: var(--clr-alert-bg);
    color: var(--clr-alert);
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    animation: slideIn 0.25s ease;
    max-width: 340px;
}

.toast.success { border-left: 3px solid var(--clr-success); }
.toast.error   { border-left: 3px solid var(--clr-alert); }

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Event Timeline ──────────────────────────────────────────────────────── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.25rem;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 28px;
    bottom: 0;
    width: 1px;
    background: var(--clr-border);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--clr-surface-hover);
    border: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--clr-text-muted);
}

.timeline-dot.status  { background: rgba(59,130,246,0.1); color: var(--clr-primary); }
.timeline-dot.created { background: rgba(16,185,129,0.1); color: var(--clr-success); }

.timeline-content { flex: 1; padding-top: 0.35rem; }
.timeline-meta { font-size: 0.8rem; color: var(--clr-text-muted); margin-top: 0.2rem; }

/* ── Filter Pills ─────────────────────────────────────────────────────────── */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1rem;
}
.filter-pill {
    padding: .3rem .75rem;
    border: 1px solid var(--clr-border);
    border-radius: 999px;
    background: transparent;
    color: var(--clr-text-muted);
    font-size: .8rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all .15s ease;
}
.filter-pill:hover {
    border-color: var(--clr-primary);
    color: var(--clr-primary);
}
.filter-pill.active {
    background: var(--clr-primary);
    border-color: var(--clr-primary);
    color: #fff;
    font-weight: 500;
}

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

/* ── Document Upload Zone ─────────────────────────────────────────────────── */
.doc-drop-zone {
    border: 2px dashed var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--clr-text-muted);
    font-size: 0.875rem;
    position: relative;
    margin-bottom: 1rem;
}

.doc-drop-zone:hover,
.doc-drop-zone.dragover {
    border-color: var(--clr-primary);
    background: rgba(59,130,246,0.06);
    color: var(--clr-primary);
}

.doc-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.doc-drop-zone .drop-icon {
    width: 28px;
    height: 28px;
    margin: 0 auto 0.5rem;
    opacity: 0.5;
}

.doc-drop-zone.uploading {
    pointer-events: none;
    border-color: var(--clr-primary);
    background: rgba(59,130,246,0.04);
}

.doc-upload-progress {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--clr-primary);
    margin-top: 0.4rem;
    font-style: italic;
}

/* ── Document File Row ────────────────────────────────────────────────────── */
.doc-file-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s ease;
}

.doc-file-row:last-child { border-bottom: none; }

.doc-file-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    text-transform: uppercase;
}

.doc-icon-pdf  { background: rgba(239,68,68,0.12);   color: #f87171; }
.doc-icon-doc  { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.doc-icon-xls  { background: rgba(16,185,129,0.12);  color: #34d399; }
.doc-icon-img  { background: rgba(168,85,247,0.12);  color: #c084fc; }
.doc-icon-txt  { background: rgba(161,161,170,0.12); color: #a1a1aa; }
.doc-icon-csv  { background: rgba(20,184,166,0.12);  color: #2dd4bf; }
.doc-icon-file { background: rgba(161,161,170,0.12); color: #a1a1aa; }

.doc-file-meta {
    flex: 1;
    min-width: 0;
}

.doc-file-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--clr-text-main);
}

.doc-file-sub {
    font-size: 0.775rem;
    color: var(--clr-text-muted);
    margin-top: 0.15rem;
}

.doc-file-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.doc-action-btn {
    background: none;
    border: 1px solid var(--clr-border);
    color: var(--clr-text-muted);
    border-radius: var(--radius-md);
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.15s ease;
}

.doc-action-btn:hover {
    border-color: var(--clr-primary);
    color: var(--clr-primary);
    background: rgba(59,130,246,0.06);
}

/* ── Wide Modal (document preview) ───────────────────────────────────────── */
.modal.modal-wide {
    max-width: 820px;
}

/* ── Flagged document row ─────────────────────────────────────────────────── */
.doc-file-row.doc-row-flagged {
    border-left: 3px solid rgba(239,68,68,0.5);
    padding-left: calc(0.75rem - 3px);
    background: rgba(239,68,68,0.03);
}

/* ── Scan status badge aliases ────────────────────────────────────────────── */
.badge-scan-pending { background: rgba(161,161,170,0.1); color: #a1a1aa; }
.badge-scan-clean   { background: rgba(16,185,129,0.1);  color: #34d399; }
.badge-scan-flagged { background: rgba(239,68,68,0.12);  color: #f87171; }

/* ── Text file preview pane ──────────────────────────────────────────────── */
.doc-text-preview {
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    max-height: 65vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--clr-text-main);
}


