/*
 * WhoisFreaks Threat Feed dashboard theme.
 * Implements the Figma "ADMIN" section design: warm white surfaces, orange
 * primary (#E15315), Plus Jakarta Sans headings + Inter body, light sidebar
 * under a marketing top bar, chip-style actions and dialog modals.
 */
:root {
    --primary: #E15315;
    --primary-dark: #C24405;
    --primary-tint: #FFF5F1;
    --primary-soft-border: #F5CDB9;
    --danger: #E11515;
    --danger-border: #F2B8B5;
    --green: #319125;
    --green-bg: #F4FFF1;
    --green-border: #B7E3AE;
    --ink: #0C0C0C;
    --heading: #2A2A2A;
    --body-text: #757575;
    --muted: #AEACAB;
    --border: #EDEBEA;
    --row-border: #F5F3F3;
    --row-warm: #FFFCFB;
    --sidebar-bg: #F9F9F9;
    --radius: 10px;
    --radius-sm: 8px;
    --font-head: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: #FFFFFF;
    color: var(--heading);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3 { font-family: var(--font-head); color: var(--ink); }

/* ---- App shell: top bar + (sidebar | content) ---- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    display: flex;
    align-items: center;
    gap: 40px;
    height: 72px;
    padding: 0 28px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-logo { display: flex; align-items: center; flex-shrink: 0; }
.topbar-logo img { height: 30px; width: auto; display: block; }

.topbar-nav { display: flex; align-items: center; gap: 36px; flex: 1; }
.topbar-nav a {
    font-family: var(--font-head);
    font-size: 15px;
    color: var(--heading);
    white-space: nowrap;
}
.topbar-nav a:hover { color: var(--primary); }
.topbar-nav a.active { color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 16px; margin-left: auto; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #FFFFFF;
    color: var(--heading);
    cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary-soft-border); color: var(--primary); }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-tint);
    border: 1px solid var(--primary-soft-border);
    color: var(--primary);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
}
.user-name { font-family: var(--font-head); font-weight: 600; font-size: 15px; color: var(--ink); }

.app-body { display: flex; flex: 1; min-height: 0; }

/* ---- Sidebar ---- */
.sidebar {
    display: flex;
    flex-direction: column;
    width: 250px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
}

.side-label {
    padding: 18px 12px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--muted);
}

.sidebar-nav { list-style: none; }
.sidebar-nav li a, .sidebar-bottom a, .sidebar-bottom button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-family: var(--font-body);
    font-size: 14.5px;
    color: #444444;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav li a:hover { background: #F1EFEE; color: var(--ink); }
.sidebar-nav li a.active { background: var(--primary-tint); color: var(--primary); }
.sidebar-nav li a.active svg { stroke: var(--primary); }

.side-icon { width: 18px; height: 18px; stroke: #6B6B6B; stroke-width: 1.7; fill: none; flex-shrink: 0; }
.sidebar-nav li a.active .side-icon { stroke: var(--primary); }

.sidebar-bottom { margin-top: auto; }
.sidebar-bottom a:hover, .sidebar-bottom button:hover { background: #F1EFEE; }
.sidebar-bottom .logout-btn { color: var(--danger); }
.sidebar-bottom .logout-btn .side-icon { stroke: var(--danger); }

/* ---- Main content ---- */
.main-content { flex: 1; min-width: 0; padding: 28px 32px 48px; background: #FFFFFF; }

.page-title {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ---- Cards ---- */
.card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.card h3 { font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-header h3 { margin-bottom: 0; }

.table-card { padding: 0; overflow-x: auto; border: none; }
.table-card .data-table { margin: 0; }

/* ---- Stat cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stats-grid--small { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.stat-card {
    display: block;
    background:
        radial-gradient(120% 140% at 100% 0%, var(--primary-tint) 0%, rgba(255, 245, 241, 0) 45%),
        #FFFFFF;
    border: 1px solid #F0EDEB;
    border-radius: var(--radius);
    padding: 18px 20px;
    color: inherit;
}
.stat-label { font-size: 14px; color: var(--body-text); margin-bottom: 6px; }
.stat-value {
    font-family: var(--font-head);
    font-size: 30px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.stat-card--link:hover { border-color: var(--primary-soft-border); }
.stat-card--active { border: 1px solid var(--primary); }

/* ---- Dashboard two-column row ---- */
.dash-columns { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .dash-columns { grid-template-columns: 1fr; } }

/* Last 24 Hours metric list */
.metric-list { list-style: none; }
.metric-row { padding: 12px 0 14px; border-bottom: 1px solid #F6DFD2; }
.metric-row:last-child { border-bottom: none; }
.metric-row .metric-label { font-size: 14px; color: var(--body-text); }
.metric-row .metric-value {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-family: var(--font-head);
    font-size: 26px;
    font-weight: 600;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.metric-row .metric-trend { color: var(--primary); font-size: 16px; flex-shrink: 0; }

/* Pivots by Type bars */
.bar-list { list-style: none; }
.bar-list li { padding: 9px 0; }
.bar-head { display: flex; justify-content: space-between; font-size: 14.5px; margin-bottom: 7px; }
.bar-head .bar-name { color: var(--heading); }
.bar-head .bar-count { font-family: var(--font-head); font-weight: 600; color: var(--ink); }
.bar-track { height: 7px; border-radius: 4px; background: var(--primary-tint); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); }

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 14px;
    color: var(--heading);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--row-border);
    color: var(--body-text);
}

.data-table td:first-child { color: var(--heading); }
.data-table tbody tr:hover { background: var(--row-warm); }
.data-table tbody tr.row-selected { background: var(--primary-tint); }

.col-check { width: 40px; }
input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }

.cell-truncate {
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Clickable table cell that opens a detail dialog */
.row-link { color: var(--heading); cursor: pointer; }
.row-link:hover { color: var(--primary); text-decoration: underline; }

.actions-cell { white-space: nowrap; }

.sortable a { color: var(--heading); display: inline-flex; align-items: center; gap: 4px; }
.sortable a:hover { color: var(--primary); }
.sortable span { font-size: 10px; }

.text-center { text-align: center; }
.text-muted { color: var(--body-text); }
.text-red { color: var(--danger); }

/* ---- Badges & status chips ---- */
.badge { font-size: 14px; color: var(--body-text); }

.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    text-transform: capitalize;
}
.status-badge.valid { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.status-badge.invalid { background: #FFF3F2; border: 1px solid var(--danger-border); color: var(--danger); }
/* Report review states render as colored text, per the design */
.status-badge.pending { padding: 0; color: var(--primary); }
.status-badge.approved { padding: 0; color: var(--green); }
.status-badge.denied { padding: 0; color: var(--body-text); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-dark); color: #FFFFFF; }

.btn-outline { background: #FFFFFF; border: 1px solid #D9D6D4; color: var(--body-text); }
.btn-outline:hover { border-color: var(--body-text); color: var(--heading); }

.btn-outline-primary { background: #FFFFFF; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-tint); color: var(--primary); }

.btn-danger, .btn-outline-danger { background: #FFFFFF; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover, .btn-outline-danger:hover { background: #FFF3F2; color: var(--danger); }

.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-xs { height: 27px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---- Filter bar ---- */
.filter-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }

.filter-input {
    flex: 1;
    min-width: 220px;
    padding: 10px 2px;
    border: none;
    border-bottom: 1px solid #D9D6D4;
    background: transparent;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--heading);
    border-radius: 0;
}
.filter-input::placeholder { color: var(--muted); }
.filter-input:focus { outline: none; border-bottom-color: var(--primary); }

.filter-select, .filter-date {
    height: 44px;
    padding: 0 36px 0 16px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    color: var(--primary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23E15315' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}
.filter-date { padding-right: 16px; background-image: none; }
.filter-date::-webkit-calendar-picker-indicator { filter: invert(43%) sepia(57%) saturate(2843%) hue-rotate(357deg) brightness(94%) contrast(93%); }
.filter-select:focus, .filter-date:focus { outline: none; border-color: var(--primary-dark); }

.filter-bar .btn { height: 44px; padding: 0 34px; }

/* ---- Toolbar between filters and table ---- */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0 14px;
    font-size: 15px;
    color: var(--heading);
}
.bulk-info { color: var(--heading); }
.bulk-info .sep { color: var(--muted); margin: 0 6px; }
.bulk-actions .spacer { flex: 1; }

/* Report status filter chips */
.chip-group { display: flex; gap: 10px; margin-left: auto; }
.chip {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 16px;
    border: 1px solid #D9D6D4;
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    color: var(--body-text);
    font-size: 13.5px;
    font-weight: 500;
}
.chip:hover { border-color: var(--body-text); color: var(--heading); }
.chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-tint); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 8px; padding: 18px 0; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.pagination a, .pagination .page-prev.disabled, .pagination .page-next.disabled, .pagination .page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 14px;
    color: var(--body-text);
    background: #FFFFFF;
    border: 1px solid var(--border);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination a.active { background: var(--primary); color: #FFFFFF; border-color: var(--primary); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }
.pagination .page-ellipsis { border: none; }
.pagination .showing { margin-right: auto; color: var(--body-text); font-size: 14px; }
.pagination .showing b { color: var(--heading); }

/* ---- Alerts / banners ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: #FFF3F2; color: var(--danger); border: 1px solid var(--danger-border); }
.alert-info { background: #FFF4EF; color: var(--primary); border: 1px solid var(--primary-soft-border); }

/* ---- Modal dialogs (Figma "Dialog" spec) ---- */
.wf-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
}

.wf-modal {
    width: 516px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    background: #FFFFFF;
    border: 0.8px solid rgba(58, 16, 191, 0.12);
    border-radius: var(--radius);
    box-shadow: 0 10px 8px rgba(0, 0, 0, 0.1), 0 4px 3px rgba(0, 0, 0, 0.1);
    padding: 22px 24px;
}
.wf-modal--wide { width: 674px; }

.wf-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.wf-modal-title { font-family: var(--font-head); font-size: 18px; font-weight: 500; color: var(--ink); line-height: 1.6; }
.wf-modal-close {
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: var(--heading);
    opacity: 0.7;
    cursor: pointer;
    padding: 2px;
}
.wf-modal-close:hover { opacity: 1; }

.wf-modal-body { margin: 10px 0 26px; font-size: 16px; color: var(--body-text); line-height: 1.6; }
.wf-modal-body .wf-danger { color: var(--danger); }
.wf-modal-body .wf-highlight { color: var(--primary); }

.wf-modal-fields { display: flex; gap: 24px; margin: 16px 0; }
.wf-field { flex: 1; min-width: 0; }
.wf-field-label { font-size: 14px; color: var(--heading); margin-bottom: 4px; }
.wf-field-value {
    font-size: 14px;
    color: var(--body-text);
    padding-bottom: 6px;
    border-bottom: 1px solid #D9D6D4;
    overflow-wrap: anywhere;
}

.wf-reason-box {
    border: 1px solid #D9D6D4;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 14.5px;
    color: var(--body-text);
    line-height: 1.6;
    max-height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.wf-modal-input {
    width: 100%;
    padding: 10px 2px;
    border: none;
    border-bottom: 1px solid #D9D6D4;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--heading);
    background: transparent;
    border-radius: 0;
}
.wf-modal-input::placeholder { color: var(--muted); }
.wf-modal-input:focus { outline: none; border-bottom-color: var(--primary); }

.wf-modal-select {
    height: 44px;
    padding: 0 36px 0 16px;
    border: 1px solid #D9D6D4;
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    color: var(--heading);
    font-family: var(--font-body);
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23757575' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}
.wf-modal-select:focus { outline: none; border-color: var(--primary); }

/* Scrollable table inside a modal (e.g. a seed's pivots) */
.wf-table-scroll {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}
.wf-table-scroll .data-table { font-size: 13.5px; }
.wf-table-scroll .data-table th { position: sticky; top: 0; background: #FFFFFF; }

.wf-modal-actions { display: flex; justify-content: flex-end; gap: 14px; }
.wf-btn {
    height: 36px;
    min-width: 116px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.wf-btn-cancel { background: #FFFFFF; border: 1px solid var(--body-text); color: var(--body-text); }
.wf-btn-cancel:hover { border-color: var(--heading); color: var(--heading); }
.wf-btn-primary { background: var(--primary); border: 1px solid var(--primary); color: #FFFFFF; }
.wf-btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.wf-btn-outline-primary { background: #FFFFFF; border: 1px solid var(--primary); color: var(--primary); }
.wf-btn-outline-primary:hover { background: var(--primary-tint); }
.wf-btn:disabled { opacity: 0.55; cursor: default; }

/* ---- Right-side detail drawer (seed & pivot details) ---- */
.wf-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.32);
}

.wf-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 901;
    width: 600px;
    max-width: 95vw;
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.14);
    transform: translateX(102%);
    transition: transform 0.28s ease;
}
.wf-drawer.open { transform: none; }

.wf-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}
.wf-drawer-title {
    font-family: var(--font-head);
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.wf-drawer-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.wf-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    font-size: 14.5px;
    color: var(--body-text);
    line-height: 1.6;
}
.wf-drawer-body .wf-table-scroll { max-height: none; }

.wf-section-label {
    font-family: var(--font-head);
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink);
    margin: 20px 0 8px;
}

/* ---- Login ---- */
.login-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(90% 70% at 50% 10%, #FEF3EA 0%, rgba(254, 243, 234, 0) 60%),
        linear-gradient(180deg, #FEF9F5 0%, #F7EFEB 100%);
}

.login-logo { margin-bottom: 26px; }
.login-logo img { height: 38px; display: block; }

.login-card {
    background: #F7F0ED;
    border: 1px solid #DCD5D1;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(160, 120, 100, 0.12);
    padding: 30px 32px 34px;
    width: 100%;
    max-width: 448px;
}

.login-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-sub { font-size: 15px; color: var(--body-text); margin-bottom: 24px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }

.form-group input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    background: #FFFFFF;
    border: 1px solid #E5E0DC;
    border-radius: var(--radius-sm);
    color: var(--heading);
    font-size: 14.5px;
    font-family: var(--font-body);
}
.form-group input::placeholder { color: var(--muted); }
.form-group input:focus { outline: none; border-color: var(--primary); }

.login-submit { height: 48px; font-size: 15.5px; margin-top: 6px; }

.inline-form { display: inline; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .topbar-nav .marketing-link { display: none; }
}
@media (max-width: 860px) {
    .sidebar { display: none; }
    .main-content { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-input { min-width: 100%; }
}
