/* ===== RESET & ROOT ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:            #1a3c6e;
    --primary-light:      #2557a7;
    --accent:             #e8f0fe;
    --major:              #c0392b;
    --major-bg:           #fdecea;
    --major-border:       #e74c3c;
    --significant:        #d68910;
    --significant-bg:     #fef9e7;
    --significant-border: #f39c12;
    --minor:              #b7950b;
    --minor-bg:           #fefce8;
    --minor-border:       #f1c40f;
    --status-open:        #2471a3;
    --status-inprogress:  #1e8449;
    --status-closed:      #6c757d;
    --status-overdue:     #c0392b;
    --white:              #ffffff;
    --gray-50:            #f8f9fa;
    --gray-100:           #f0f2f5;
    --gray-200:           #e9ecef;
    --gray-300:           #dee2e6;
    --gray-600:           #6c757d;
    --gray-800:           #343a40;
    --text-muted:         #6c757d;
    --border:             #dee2e6;
    --shadow:             0 2px 12px rgba(0,0,0,0.10);
    --shadow-lg:          0 8px 32px rgba(0,0,0,0.14);
    --radius:             10px;
    --radius-sm:          6px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
    font-size: 14px;
}

/* ===== LOGIN PAGE ===== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a3c6e 0%, #2557a7 60%, #3b82c4 100%);
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .icon-wrap {
    font-size: 42px;
    display: block;
    margin-bottom: 12px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--primary); }
.login-logo p  { font-size: 13px; color: var(--gray-600); margin-top: 4px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--gray-800);
    font-size: 13px;
}
.form-control,
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
    color: var(--gray-800);
}
.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,87,167,0.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.18s;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}
.btn-primary   { background: var(--primary-light); color: white; }
.btn-primary:hover   { background: #1d4d9a; }
.btn-success   { background: #1e8449; color: white; }
.btn-success:hover   { background: #166035; }
.btn-danger    { background: var(--major); color: white; }
.btn-danger:hover    { background: #a93226; }
.btn-warning   { background: #d68910; color: white; }
.btn-warning:hover   { background: #b7770d; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-sm   { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    border-left: 4px solid;
}
.alert-success { background: #d4edda; border-color: #28a745; color: #155724; }
.alert-error   { background: #f8d7da; border-color: #dc3545; color: #721c24; }
.alert-info    { background: var(--accent); border-color: var(--primary-light); color: var(--primary); }

/* ===== HEADER / NAVBAR ===== */
/* dashboard.php uses class="header" */
.header {
    background: linear-gradient(90deg, #1a3c6e 0%, #2557a7 100%);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
}
.header-user {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255,255,255,0.9);
    font-size: 13px;
}
.role-tag {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
}
.logout-btn {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 13px;
    padding: 5px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    transition: all 0.18s;
}
.logout-btn:hover { background: rgba(255,255,255,0.15); color: white; }

/* ===== DASHBOARD WRAPPER ===== */
/* dashboard.php uses <div class="dashboard"> */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== SUMMARY CARDS ===== */
/* dashboard.php uses summary-grid > summary-card with classes: total, major, significant, minor, s-open, s-overdue, s-closed */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.summary-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--gray-300);
    transition: transform 0.18s;
}
.summary-card:hover { transform: translateY(-2px); }

/* dashboard uses .number and .label inside summary cards */
.summary-card .number {
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    color: var(--primary);
}
.summary-card .label {
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
}

/* Card modifier classes from dashboard */
.summary-card.total       { border-top-color: var(--primary-light); }
.summary-card.total .number { color: var(--primary-light); }
.summary-card.major       { border-top-color: var(--major-border); }
.summary-card.major .number { color: var(--major); }
.summary-card.significant { border-top-color: var(--significant-border); }
.summary-card.significant .number { color: var(--significant); }
.summary-card.minor       { border-top-color: var(--minor-border); }
.summary-card.minor .number { color: var(--minor); }
.summary-card.s-open      { border-top-color: var(--status-open); }
.summary-card.s-open .number { color: var(--status-open); }
.summary-card.s-overdue   { border-top-color: var(--status-overdue); }
.summary-card.s-overdue .number { color: var(--status-overdue); }
.summary-card.s-closed    { border-top-color: var(--status-closed); }
.summary-card.s-closed .number { color: var(--status-closed); }

/* ===== TABS ===== */
/* dashboard.php uses tab-nav > tab-btn  and  tab-content */
.tab-nav {
    display: flex;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    padding: 0 8px;
    flex-wrap: wrap;
}
.tab-btn {
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.18s;
    font-family: inherit;
}
.tab-btn:hover  { color: var(--primary-light); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== CARD (tab panels use .card) ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 12px;
    background: var(--gray-50);
}
.card-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-bar .form-control {
    width: auto;
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table thead tr {
    background: linear-gradient(90deg, #1a3c6e, #2557a7);
    color: white;
}
table thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
table tbody tr {
    border-bottom: 1px solid var(--gray-200);
    transition: background 0.15s;
}
table tbody tr:last-child { border-bottom: none; }
table tbody tr:hover { filter: brightness(0.97); }
table tbody td {
    padding: 10px 14px;
    vertical-align: top;
}

/* text-clip used inside cells */
.text-clip {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    max-width: 220px;
    display: block;
}

/* Row classification highlight */
.row-major       { background: var(--major-bg) !important;       border-left: 4px solid var(--major-border); }
.row-significant { background: var(--significant-bg) !important; border-left: 4px solid var(--significant-border); }
.row-minor       { background: var(--minor-bg) !important;       border-left: 4px solid var(--minor-border); }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Classification badges (from classificationBadge() in functions.php) */
.badge-major       { background: var(--major-bg);       color: var(--major);       border: 1px solid var(--major-border); }
.badge-significant { background: var(--significant-bg); color: var(--significant); border: 1px solid var(--significant-border); }
.badge-minor       { background: var(--minor-bg);       color: var(--minor);       border: 1px solid var(--minor-border); }

/* Role badges */
.badge.role-admin      { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.badge.role-auditor    { background: var(--accent); color: var(--primary); border: 1px solid #93c5fd; }
.badge.role-management { background: #ccfbf1; color: #065f46; border: 1px solid #6ee7b7; }

/* Status badges (from statusBadge() in functions.php) */
.badge.status-open       { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge.status-closed     { background: var(--gray-200); color: var(--gray-600); border: 1px solid var(--gray-300); }
.badge.status-overdue    { background: var(--major-bg); color: var(--major); border: 1px solid var(--major-border); }
/* in_progress is returned as a style string, cover via inline — but also provide class */
.badge.status-in_progress { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-600);
}
.empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty-state p { font-size: 15px; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.22s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--gray-600);
    line-height: 1;
    padding: 0 4px;
}
.modal-close:hover { color: var(--major); }
.modal-body   { padding: 22px 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--white);
}

/* ===== CLASS PICKER (radio buttons styled as labels) ===== */
.class-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.class-pick-input { display: none; }
.class-pick-label {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
}
.pick-major       { background: var(--major-bg);       color: var(--major);       border-color: var(--major-border); }
.pick-significant { background: var(--significant-bg); color: var(--significant); border-color: var(--significant-border); }
.pick-minor       { background: var(--minor-bg);       color: var(--minor);       border-color: var(--minor-border); }
.class-pick-input:checked + .class-pick-label { outline: 3px solid var(--primary-light); outline-offset: 2px; transform: scale(1.06); }

/* ===== USER AVATAR ===== */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a3c6e, #2557a7);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

/* ===== PRINT ===== */
@media print {
    .header, .tab-nav, .filter-bar, .btn, .modal-overlay, .no-print { display: none !important; }
    .tab-content { display: block !important; }
    .card { box-shadow: none; }
    body, .dashboard { background: white; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .summary-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
    .dashboard { padding: 12px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-btn { padding: 10px 14px; font-size: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .modal { max-width: 100%; }
}