/* ============================================
   DESIGN SYSTEM & VARIABLES
   ============================================ */
:root {
    --primary: #1e4d7b;
    --primary-light: #2e6fa3;
    --primary-dark: #154059;
    --secondary: #00a8e8;
    --success: #06a77d;
    --danger: #d62828;
    --warning: #f77f00;
    --info: #00c6ff;
    --light: #f8f9fa;
    --dark: #2c3e50;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;

    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --box-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

/* ============================================
   GLOBAL TYPOGRAPHY & BODY
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    font-size: 0.89rem;
    line-height: 1.6;
    color: var(--gray-800);
    background-color: var(--gray-100);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.15rem;
}

h3 {
    font-size: 1rem;
}

h4 {
    font-size: 0.95rem;
}

p {
    margin-bottom: 1rem;
}

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

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

/* ============================================
   LOGIN PAGE - Split Layout with Gradient
   ============================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e4d7b 0%, #2e6fa3 50%, #00a8e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-shell {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-split-card {
    width: min(960px, 100%);
    display: flex;
    background-color: #ffffff;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow-lg);
    min-height: 500px;
}

.login-form-panel,
.login-welcome-panel {
    flex: 1;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-form-panel {
    background-color: #ffffff;
}

.login-form {
    max-width: 320px;
    width: 100%;
}

.login-input {
    height: 36px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.89rem;
    transition: var(--transition);
}

.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 77, 123, 0.1);
}

.login-submit {
    height: 36px;
    border: none;
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    border-radius: 8px;
    transition: var(--transition);
}

.login-submit:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 77, 123, 0.3);
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.login-divider {
    width: 1px;
    background: linear-gradient(to bottom,
        rgba(30, 77, 123, 0.05),
        rgba(30, 77, 123, 0.3),
        rgba(30, 77, 123, 0.05));
}

.login-welcome-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 248, 255, 0.98));
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.welcome-text {
    color: var(--gray-700);
    max-width: 340px;
    line-height: 1.8;
    font-size: 0.89rem;
}

/* Forgot Password Page */
.forgot-password-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--secondary) 100%);
}

.forgot-password-card {
    max-width: 420px;
    margin: 0 auto;
    padding: 28px 18px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
}

.form-label {
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 0.3rem;
}

/* ============================================
   SIDEBAR NAVIGATION - Main Layout
   ============================================ */
.app-shell {
    display: flex;
    height: 100vh;
    background-color: var(--gray-100);
}

.sidebar {
    width: 210px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: none;
    transition: var(--transition);
}


.sidebar-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    padding-left: 22px;
}

.sidebar-link.active {
    background-color: rgba(0, 168, 232, 0.3);
    color: white;
    border-left-color: var(--secondary);
}

.sidebar-link.disabled-link {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-box {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.user-role {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-area {
    flex: 1;
    overflow-y: auto;
}

/* ============================================
   CARDS & COMPONENTS
   ============================================ */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    background-color: white;
}

.card:hover {
    box-shadow: var(--box-shadow-lg);
}

.card-header {
    background-color: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    padding: 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

.stat-card {
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.stat-card:hover {
    border-left-color: var(--secondary);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.hero-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
}

.hero-card .h3 {
    color: white;
}

.hero-card .text-light-emphasis {
    color: rgba(255, 255, 255, 0.85);
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 10px 20px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 77, 123, 0.3);
}

.btn-secondary {
    background-color: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #0088b8;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-outline-secondary {
    border: 2px solid var(--gray-400);
    color: var(--gray-700);
}

.btn-outline-secondary:hover {
    background-color: var(--gray-100);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Tables */
.table {
    background-color: transparent;
    border-collapse: collapse;
    width: 100%;
}

.table thead {
    background-color: transparent;
    font-weight: inherit;
    color: inherit;
}

.table th {
    border-bottom: 1px solid var(--gray-200);
    padding: 12px;
    color: inherit;
    font-weight: 600;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    color: inherit;
}

.table tbody tr:hover {
    background-color: rgba(148, 163, 184, 0.06);
}

/* Forms */
.form-control {
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 10px 12px;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 77, 123, 0.1);
}

.form-select {
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 10px 12px;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
    margin-bottom: 1rem;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 60px;
        flex-direction: row;
        overflow-x: auto;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 0;
    }

    .sidebar-brand {
        padding: 12px 20px;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
        white-space: nowrap;
    }

    .sidebar-link {
        padding: 12px 16px;
    }

    .content-area {
        padding: 20px;
    }

    .login-split-card {
        flex-direction: column;
        min-height: auto;
    }

    .login-divider {
        width: 100%;
        height: 1px;
    }

    .login-form-panel,
    .login-welcome-panel {
        padding: 40px 30px;
    }

    .topbar-custom {
        padding: 15px 20px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 8px;
    }
}

@media (max-width: 576px) {
    .sidebar {
        max-height: 50px;
    }

    .sidebar-brand {
        padding: 10px 16px;
    }

    .sidebar-title {
        font-size: 1rem;
    }

    .sidebar-link {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .content-area {
        padding: 15px;
    }

    .login-form-panel,
    .login-welcome-panel {
        padding: 32px 24px;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .welcome-title {
        font-size: 1.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}


/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-muted {
    color: var(--gray-600);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-info {
    color: var(--secondary);
}

.bg-light {
    background-color: var(--light);
}

.shadow-sm {
    box-shadow: var(--box-shadow);
}

.shadow {
    box-shadow: var(--box-shadow);
}

.shadow-lg {
    box-shadow: var(--box-shadow-lg);
}

.rounded-2 {
    border-radius: 8px;
}

.rounded-3 {
    border-radius: var(--border-radius);
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

.gap-4 {
    gap: 1.5rem;
}

/* Icon support */
.icon {
    display: inline-block;
    margin-right: 6px;
    font-size: 1.1em;
    vertical-align: middle;
}

.icon-sm {
    font-size: 0.9em;
}

/* ============================================
   THEME ALIGNMENT OVERRIDES
   ============================================ */
:root {
    --primary: #0e7490;
    --primary-light: #118ab2;
    --primary-dark: #0c4a6e;
    --secondary: #d97706;
    --success: #059669;
    --danger: #e11d48;
    --warning: #f59e0b;
    --info: #38bdf8;
    --light: #f8fbfd;
    --dark: #0f172a;
    --gray-100: #f8fafc;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --border-radius: 16px;
    --box-shadow: 0 1px 3px rgba(14, 116, 144, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --box-shadow-lg: 0 14px 30px rgba(14, 116, 144, 0.12), 0 6px 12px rgba(15, 23, 42, 0.05);
}

body {
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    color: var(--gray-800);
    background:
        radial-gradient(circle at top right, rgba(14, 116, 144, 0.08), transparent 35%),
        var(--gray-100);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', 'DM Sans', sans-serif;
    color: var(--dark);
}

.card {
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.card.border-0 {
    border: 1px solid rgba(226, 232, 240, 0.95) !important;
}

.card-header {
    background: #f8fafc;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.btn {
    border-radius: 10px;
    min-height: 42px;
    padding: 0.72rem 1.05rem;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-weight: 600;
    line-height: 1.2;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-color: var(--primary);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-outline-secondary {
    border-width: 1.5px;
    border-color: var(--gray-300);
    color: var(--gray-700);
}

.btn-sm {
    min-height: 34px;
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
}

.table {
    font-size: 0.84rem;
}

.form-control,
.form-select {
    min-height: 42px;
    border-radius: 10px;
}

.alert {
    border-radius: 14px;
}

.rrs-toast-stack {
    z-index: 1095;
    max-width: min(92vw, 420px);
}

.rrs-toast {
    border: 1px solid rgba(14, 116, 144, 0.12);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 32px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(10px);
}

.rrs-toast .toast-header {
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.rrs-toast .toast-body .btn {
    min-height: 34px;
    padding: 0.45rem 0.8rem;
}

.rrs-table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
}

.rrs-table-pagination-info {
    color: var(--gray-600);
    font-size: 0.86rem;
}

.rrs-pagination-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.rrs-pagination-pages {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.rrs-pagination-btn {
    min-width: 42px;
    height: 42px;
    padding: 0 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    background: #ffffff;
    color: var(--gray-700);
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.rrs-pagination-btn:hover,
.rrs-pagination-btn:focus-visible {
    text-decoration: none;
    color: var(--primary-dark);
    border-color: rgba(14, 116, 144, 0.3);
    background: #f8fbff;
    transform: translateY(-1px);
}

.rrs-pagination-btn.is-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-color: var(--primary);
    color: #ffffff;
}

.rrs-pagination-btn.is-disabled,
.rrs-pagination-btn[aria-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
    transform: none;
}

.audit-pagination {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

@media (max-width: 576px) {
    .rrs-table-pagination,
    .audit-pagination {
        justify-content: center;
    }

    .rrs-pagination-btn,
    .audit-pagination-btn {
        min-width: 38px;
        height: 38px;
        padding: 0 0.7rem;
    }
}

.audit-pagination-pages {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.audit-pagination-btn {
    min-width: 42px;
    height: 42px;
    padding: 0 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    background: #ffffff;
    color: var(--gray-700);
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.audit-pagination-btn:hover,
.audit-pagination-btn:focus-visible {
    text-decoration: none;
    color: var(--primary-dark);
    border-color: rgba(14, 116, 144, 0.3);
    background: #f8fbff;
    transform: translateY(-1px);
}

.audit-pagination-btn.is-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-color: var(--primary);
    color: #ffffff;
}

.audit-pagination-btn.is-disabled,
.audit-pagination-btn[aria-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
    transform: none;
}

.rrs-toast.is-success .toast-header {
    background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
    color: #065f46;
}

.rrs-toast.is-danger .toast-header,
.rrs-toast.is-error .toast-header {
    background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
    color: #9f1239;
}

.rrs-toast.is-warning .toast-header {
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
    color: #92400e;
}

.rrs-toast.is-info .toast-header {
    background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
    color: #0c4a6e;
}

.error-page {
    min-height: 100vh;
    margin: 0;
    background: #f8f9fa;
}

.error-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.error-status-display {
    width: 100%;
    margin: 0 0 1.5rem;
    padding-bottom: 0.9rem;
    border-bottom: 2px solid #dc2626;
}

.error-status-code {
    display: block;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 700;
    line-height: 1;
    color: #b91c1c;
    letter-spacing: 0.04em;
}

.error-status-line {
    display: none;
}

.error-card {
    width: min(680px, 100%);
    padding: 2rem;
    border-radius: 0;
    background: #ffffff;
    border: 1px solid var(--gray-300);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.btn-export-csv,
    .btn-export-csv:hover,
    .btn-export-csv:focus,
    .btn-export-csv:active {
        background-color: #198754 !important;
        color: #ffffff !important;
        border-color: #198754 !important;
        text-decoration: none !important;
        box-shadow: none !important;
    }

    .btn-export-csv:hover {
        background-color: #145c40 !important;
        color: #ffffff !important;
    }

    .error-heading {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    line-height: 1.15;
}

.error-copy {
    max-width: 58ch;
    color: var(--gray-700);
    font-size: 1rem;
    line-height: 1.6;
}

.error-copy-muted {
    color: var(--gray-600);
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
}

.error-action-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.error-meta-group {
    padding-top: 1rem;
    border-top: 1px solid var(--gray-300);
}

.error-meta {
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.6;
}

.error-meta code {
    color: var(--gray-800);
    background: var(--gray-100);
    border-radius: 6px;
    padding: 0.12rem 0.35rem;
}

@media (max-width: 575.98px) {
    .error-shell {
        padding: 16px;
    }

    .error-status-display {
        margin-bottom: 1.25rem;
    }

    .error-card {
        padding: 1.5rem;
    }

    .error-heading {
        font-size: clamp(1.6rem, 8vw, 2rem);
    }

    .error-actions > * {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    .btn,
    .form-control,
    .form-select,
    .input-group-text,
    .rrs-pagination-btn,
    .audit-pagination-btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 40px;
    }

    .table .btn,
    .table-responsive .btn {
        min-width: 40px;
        min-height: 40px;
    }
}
