/* =============================================
   Dashboard Admin — Procurador SCW
   ============================================= */

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

:root {
    --sidebar-w: 220px;
    --header-h: 56px;
    --bg: #f4f6f9;
    --sidebar-bg: #1e2535;
    --sidebar-hover: #2d3650;
    --sidebar-active: #3b82f6;
    --text: #1f2937;
    --text-muted: #6b7280;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --purple: #8b5cf6;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.12);
    font-family: 'Segoe UI', system-ui, sans-serif;
}

body { background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* ===== SIDEBAR ===== */
#sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

#sidebar .logo {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
#sidebar .logo h1 { font-size: 16px; font-weight: 700; color: #fff; }
#sidebar .logo small { font-size: 11px; color: #64748b; }

#sidebar nav { flex: 1; padding: 12px 0; }

#sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    border-radius: 0;
    transition: background .15s, color .15s;
    cursor: pointer;
}
#sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
#sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
#sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; }

#sidebar .sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: 12px;
    color: #475569;
}

/* ===== MAIN LAYOUT ===== */
#main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== TOPBAR ===== */
#topbar {
    height: var(--header-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
#topbar h2 { font-size: 16px; font-weight: 600; color: var(--text); }
#topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
#topbar .admin-badge {
    background: #eff6ff;
    color: var(--accent);
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
}
#topbar .btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all .15s;
}
#topbar .btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ===== CONTENT ===== */
#content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ===== LOGIN PAGE ===== */
#login-page {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1e2535 0%, #2d3650 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 360px;
    box-shadow: var(--shadow-md);
}
.login-box h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-box p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-box .logo-big { font-size: 36px; margin-bottom: 12px; }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .stat-icon { font-size: 28px; flex-shrink: 0; }
.stat-card .stat-body { display: flex; flex-direction: column; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; font-weight: 600; color: var(--text-muted); background: #f9fafb; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }
.clickable-row { cursor: pointer; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}
.filter-bar select,
.filter-bar input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    background: #fff;
}
.filter-bar select:focus,
.filter-bar input:focus { outline: none; border-color: var(--accent); }

/* ===== DETAIL GRID ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.detail-item span { font-size: 14px; font-weight: 500; }

/* ===== COMMENT THREAD ===== */
.comment-thread { display: flex; flex-direction: column; gap: 12px; max-height: 400px; overflow-y: auto; padding: 4px 0; }
.comment {
    display: flex;
    gap: 10px;
}
.comment-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.comment.user .comment-avatar { background: #dbeafe; }
.comment.admin .comment-avatar { background: #fef3c7; }
.comment-body { flex: 1; }
.comment-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.comment-meta strong { color: var(--text); font-weight: 600; }
.comment-text {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}
.comment.admin .comment-text { background: #fffbeb; border-color: #fde68a; }

/* ===== BACK BUTTON ===== */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 16px;
    text-decoration: none;
    transition: color .15s;
}
.back-btn:hover { color: var(--accent); }

/* ===== BENEFIT FORM ===== */
.benefit-form {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}
.benefit-form h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: #92400e; }

/* ===== ALERT ===== */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== SECTION DIVIDER ===== */
.section-gap { margin-bottom: 20px; }

/* ===== LOADING ===== */
.loading { text-align: center; padding: 32px; color: var(--text-muted); font-size: 14px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    #sidebar { display: none; }
    #main { margin-left: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
