/* ===== CSS Variables ===== */
:root {
    --bg: #f8f9fb;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-muted: #f1f5f9;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-heading: #0f172a;
    --primary: #6366f1;
    --primary-fg: #ffffff;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --destructive: #ef4444;
    --destructive-light: rgba(239, 68, 68, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --urgent: #f97316;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
    --font-heading: 'Segoe UI', -apple-system, sans-serif;
    --sidebar-w: 256px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #1e293b;
    --bg-muted: #334155;
    --bg-hover: #334155;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-heading: #f8fafc;
    --primary: #818cf8;
    --primary-fg: #0f172a;
    --primary-hover: #6366f1;
    --primary-light: rgba(129, 140, 248, 0.15);
    --destructive-light: rgba(239, 68, 68, 0.15);
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.3);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w); background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 40;
}

.sidebar-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}

.sidebar-logo {
    width: 32px; height: 32px; background: var(--primary);
    border-radius: var(--radius); display: flex;
    align-items: center; justify-content: center;
    color: var(--primary-fg); font-weight: 700; font-size: 16px;
}

.sidebar-title { font-family: var(--font-heading); font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }

.sidebar-nav { flex: 1; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px; border-radius: var(--radius);
    color: var(--text-muted); font-size: 14px;
    transition: all 0.15s; cursor: pointer; border: none;
    background: none; width: 100%; text-align: left; text-decoration: none;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.nav-link i { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

.sidebar-user {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px; border-radius: var(--radius);
    cursor: pointer; transition: background 0.15s;
}
.sidebar-user:hover { background: var(--bg-hover); }
.sidebar-user-name { font-size: 13px; font-weight: 500; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

.theme-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-radius: var(--radius);
    background: var(--bg-muted); margin-bottom: 8px; font-size: 13px;
    color: var(--text-muted);
}
.theme-toggle-switch {
    width: 36px; height: 20px; border-radius: 10px;
    background: var(--border); cursor: pointer; position: relative;
    transition: background 0.2s; border: none;
}
.theme-toggle-switch.on { background: var(--primary); }
.theme-toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: white; transition: transform 0.2s;
}
.theme-toggle-switch.on::after { transform: translateX(16px); }

.main-content { margin-left: var(--sidebar-w); padding: 24px; flex: 1; min-height: 100vh; }

/* ===== Login / Register Pages ===== */
.auth-page {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; padding: 16px; background: var(--bg);
}

.auth-card {
    width: 100%; max-width: 420px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 32px; box-shadow: var(--shadow);
}

.auth-header { text-align: center; margin-bottom: 24px; }

.auth-icon {
    width: 48px; height: 48px; background: var(--primary);
    border-radius: var(--radius-lg); display: flex;
    align-items: center; justify-content: center;
    margin: 0 auto 16px; color: var(--primary-fg);
    font-size: 24px;
}

.auth-title { font-family: var(--font-heading); font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px; font-family: var(--font-sans);
    background: var(--bg-card); color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-input::placeholder { color: var(--text-muted); }

.form-textarea { resize: vertical; min-height: 60px; }
.form-input.mono { font-family: var(--font-mono); font-size: 20px; text-align: center; letter-spacing: 8px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 16px; border-radius: var(--radius); font-size: 14px;
    font-weight: 500; cursor: pointer; transition: all 0.15s;
    border: 1px solid transparent; font-family: var(--font-sans);
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn i { font-size: 13px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-sm i { font-size: 11px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }

.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: var(--border); background: var(--bg-card); color: var(--text); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: transparent; color: var(--destructive); }
.btn-danger:hover { background: var(--destructive-light); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Cards & Tables ===== */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-family: var(--font-heading); font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 10px 16px; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px;
    font-family: var(--font-mono); color: var(--text-muted);
    border-bottom: 1px solid var(--border); font-weight: 600;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-muted); }
tbody tr.clickable { cursor: pointer; }

/* ===== Status Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 11px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-safe { background: rgba(34,197,94,0.12); color: #16a34a; }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-urgent { background: rgba(249,115,22,0.12); color: #ea580c; }
.badge-late { background: rgba(239,68,68,0.12); color: #dc2626; }

.badge-tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 12px; background: var(--bg-muted); color: var(--text-muted);
}

/* ===== Stats Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    text-align: center; box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 32px; font-weight: 700; font-family: var(--font-heading); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.stat-safe .stat-value { color: var(--success); }
.stat-warning .stat-value { color: var(--warning); }
.stat-urgent .stat-value { color: var(--urgent); }
.stat-late .stat-value { color: var(--destructive); }

/* ===== Page Header ===== */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-family: var(--font-heading); font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.page-header p { color: var(--text-muted); margin-top: 4px; }

.page-header-row {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}

.search-box {
    position: relative; display: inline-flex; align-items: center;
}
.search-box i { position: absolute; left: 12px; color: var(--text-muted); font-size: 14px; }
.search-box input { padding-left: 36px; width: 240px; }

/* ===== Dialogs / Modals ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px); z-index: 50;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; animation: fadeIn 0.15s;
}
.modal {
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 100%;
    max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
    animation: slideUp 0.2s;
}
.modal-sm { max-width: 480px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-family: var(--font-heading); font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Grid Utils ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ===== Network Colors ===== */
.net-facebook { border-color: rgba(24,119,242,0.2); background: rgba(24,119,242,0.03); }
.net-instagram { border-color: rgba(228,64,95,0.2); background: rgba(228,64,95,0.03); }
.net-linkedin { border-color: rgba(10,102,194,0.2); background: rgba(10,102,194,0.03); }

/* ===== Mockup Previews ===== */
.mockup-card {
    background: #fff; border-radius: 8px; border: 1px solid #e5e7eb;
    overflow: hidden; margin-bottom: 12px; font-size: 11px; color: #1c1e21;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.mockup-header { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.mockup-icon {
    width: 30px; height: 30px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; color: #fff;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.mockup-icon.fb { background: #1877F2; }
.mockup-icon.ig { background: linear-gradient(135deg, #833AB4, #E4405F, #F77737); border-radius: 6px; font-size: 9px; }
.mockup-icon.li { background: #0A66C2; border-radius: 4px; font-size: 10px; }
.mockup-name { font-weight: 600; font-size: 11px; }
.mockup-time { font-size: 9px; color: #65676b; }
.mockup-text { padding: 0 10px 8px; font-size: 10px; line-height: 1.4; white-space: pre-line; }
.mockup-images { background: #f3f4f6; display: flex; gap: 2px; min-height: 60px; }
.mockup-images img { width: 100%; max-height: 140px; object-fit: contain; display: block; }
.mockup-images .img-half { width: 50%; }
.mockup-images .img-main { width: 58%; }
.mockup-images .img-side { width: 42%; display: flex; flex-direction: column; gap: 2px; }
.mockup-images .img-side img { flex: 1; min-height: 0; }
.mockup-actions {
    display: flex; border-top: 1px solid #e5e7eb; font-size: 10px;
    font-weight: 600; color: #65676b;
}
.mockup-actions span { flex: 1; text-align: center; padding: 5px 0; }

/* ===== File List ===== */
.file-item {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 8px; background: var(--bg-muted); border-radius: 4px;
    font-size: 11px; margin-bottom: 4px;
}
.file-item .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Toast ===== */
#toast-container {
    position: fixed; top: 16px; right: 16px; z-index: 100;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius); font-size: 14px;
    color: #fff; box-shadow: var(--shadow); animation: slideIn 0.3s;
    min-width: 250px; max-width: 400px;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.empty-state i { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== Spinner ===== */
.spinner {
    width: 20px; height: 20px; border: 2px solid var(--primary);
    border-top-color: transparent; border-radius: 50%;
    animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px;
}

/* ===== View Toggle ===== */
.view-toggle {
    display: inline-flex; background: var(--bg-muted); border-radius: var(--radius);
    padding: 2px; gap: 2px;
}
.view-toggle-btn {
    display: flex; align-items: center; gap: 6px; padding: 6px 14px;
    border-radius: 6px; font-size: 13px; font-weight: 500;
    cursor: pointer; border: none; background: transparent;
    color: var(--text-muted); transition: all 0.15s; font-family: var(--font-sans);
}
.view-toggle-btn.active {
    background: var(--bg-card); color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.view-toggle-btn:hover:not(.active) { color: var(--text); }
.view-toggle-btn i { font-size: 12px; }

/* ===== Excel Table ===== */
.excel-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.excel-table table { margin: 0; }
.excel-table thead th {
    background: var(--bg-muted); position: sticky; top: 0;
    font-size: 10px; padding: 8px 12px; white-space: nowrap;
}
.excel-table tbody td {
    padding: 7px 12px; font-size: 13px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.excel-table tbody tr:hover { background: var(--primary-light); }
.excel-table tbody tr.group-start td { border-top: 2px solid var(--border); }
.excel-table .cell-right { text-align: right; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page-header-row { flex-direction: column; align-items: stretch; }
    .search-box input { width: 100%; }
}

/* ===== Confirm Dialog ===== */
.confirm-dialog {
    text-align: center; padding: 20px;
}
.confirm-dialog h3 { font-size: 18px; margin-bottom: 8px; }
.confirm-dialog p { color: var(--text-muted); margin-bottom: 20px; }
.confirm-dialog .btn-group { display: flex; gap: 8px; justify-content: center; }

/* ===== Service Row ===== */
.service-row {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 12px; background: var(--bg-muted); border-radius: var(--radius);
    margin-bottom: 8px;
}
.service-row .form-group { margin-bottom: 0; flex: 1; }
.service-row .form-group.sm { flex: 0 0 80px; }
.service-row .form-group.md { flex: 0 0 110px; }

/* ===== 2FA Section ===== */
.qr-code-container { text-align: center; margin: 16px 0; }
.qr-code-container img { max-width: 200px; border: 4px solid var(--border); border-radius: var(--radius); }

/* Network block in report form */
.network-block {
    padding: 10px; border-radius: var(--radius); border: 1px solid;
    margin-bottom: 8px;
}
