/* ===========================================================
   SIPERIKSA - Sistem Pencatatan dan Pendokumentasian Hasil Pemeriksaan
   Design System v4.0 - Rebranding
=========================================================== */

:root {
    /* ============================================
       BRAND COLORS - Primary Blue Theme
       ============================================ */
    --sia-primary: #2a4970;
    --sia-primary-dark: #1f3654;
    --sia-primary-light: #3a5a80;
    --sia-primary-50: rgba(42, 73, 112, 0.05);
    --sia-primary-100: rgba(42, 73, 112, 0.1);
    --sia-primary-200: rgba(42, 73, 112, 0.15);

    /* Accent Color - Orange */
    --sia-accent: #c96300;
    --sia-accent-50: rgba(201, 99, 0, 0.05);
    --sia-accent-100: rgba(201, 99, 0, 0.1);
    --sia-accent-200: rgba(201, 99, 0, 0.2);

    /* Semantic Colors - Consistent */
    --sia-success: #10B981;
    --sia-success-50: rgba(16, 185, 129, 0.05);
    --sia-success-100: rgba(16, 185, 129, 0.1);
    --sia-success-200: rgba(16, 185, 129, 0.2);

    --sia-warning: #F59E0B;
    --sia-warning-50: rgba(245, 158, 11, 0.05);
    --sia-warning-100: rgba(245, 158, 11, 0.1);
    --sia-warning-200: rgba(245, 158, 11, 0.2);

    --sia-danger: #EF4444;
    --sia-danger-50: rgba(239, 68, 68, 0.05);
    --sia-danger-100: rgba(239, 68, 68, 0.1);
    --sia-danger-200: rgba(239, 68, 68, 0.2);

    --sia-info: #3B82F6;
    --sia-info-50: rgba(59, 130, 246, 0.05);
    --sia-info-100: rgba(59, 130, 246, 0.1);
    --sia-info-200: rgba(59, 130, 246, 0.2);

    /* Background & Surface */
    --sia-bg: #F5F7FB;
    --sia-surface: #FFFFFF;
    --sia-border: #E5E7EB;
    --sia-border-light: #F1F5F9;

    /* Text Colors */
    --sia-text: #1E293B;
    --sia-text-secondary: #64748B;
    --sia-text-muted: #94A3B8;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --navbar-height: 60px;

    /* Transitions */
    --transition: 0.2s ease;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

body.sia-body {
    margin: 0;
    padding: 0;
    border: 0;
    background: #F5F7FB;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1E293B;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

.sia-wrapper {
    display: flex;
    min-height: 100vh;
    background: transparent;
}

/* ============================================
   SIDEBAR - Toggle Sidebar Spec
   ============================================ */
.sidebar {
    width: 260px;
    height: 100vh;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: linear-gradient(180deg, var(--sia-primary) 0%, var(--sia-primary-dark) 100%);
    color: #fff;
    z-index: 1000;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: width;
}

.sidebar.collapsed {
    width: 76px;
}

/* Header - flex row, logo + toggle sejajar */
/* When collapsed, center the toggle button */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

/* Logo Area - hidden when collapsed (display:none removes from DOM flow) */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease-in-out;
}

.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
}

.sidebar-logo-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}

/* Toggle Button - white rounded button */
.sidebar-toggle {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--sia-primary);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

/* Chevron SVG icon */
.chevron-icon {
    transition: transform 0.25s ease-in-out;
}

/* When collapsed, chevron rotates 180deg */
.sidebar.collapsed .chevron-icon {
    transform: rotate(180deg);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.sidebar .nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link span {
    flex: 1;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-weight: 600;
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #fff;
    border-radius: 0 2px 2px 0;
}

/* When collapsed, nav icons centered */
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px 8px;
}

.sidebar.collapsed .nav-link i {
    font-size: 1.2rem;
}

.sidebar.collapsed .nav-link span {
    display: none;
}

/* Hide legacy elements */
.sidebar-toggle-btn,
.sidebar-toggle-fixed,
.sidebar-divider,
.sidebar-brand,
.sidebar-brand-text {
    display: none !important;
}

/* Sidebar Overlay - consolidated */
.sidebar-overlay {
    display: none;
}

/* ============================================
   MAIN CONTENT - Unified rule (removed duplicate)
   ============================================ */
.sia-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Support both body class and sidebar sibling selector */
body.sidebar-collapsed .sia-main,
.sidebar.collapsed ~ .sia-main {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #fff;
    border-radius: 0 2px 2px 0;
}

/* Hide legacy elements */
.sidebar-toggle-fixed,
.sidebar-divider {
    display: none !important;
}

.sia-main main {
    padding-top: 84px;
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 48px;
    background: #F5F7FB;
    min-height: 100vh;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 60px;
    background: #FFFFFF;
    border-bottom: 1px solid #E5E7EB;
    z-index: 999;
    transition: left 0.3s ease;
    padding: 0 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
}

/* Navbar follows sidebar collapse - MUST have same transition as sia-main */
body.sidebar-collapsed .navbar,
.sidebar.collapsed ~ .sia-main .navbar {
    left: var(--sidebar-collapsed-width);
}

/* Header Brand - kept for potential future use, no layout impact */
.header-brand {
    display: none; /* Hidden - branding moved to sidebar */
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.navbar-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #FFFFFF;
    color: #64748B;
    cursor: pointer;
    transition: all 0.2s ease;
}

.navbar-icon-btn:hover {
    border-color: #2a4970;
    color: #2a4970;
    background: rgba(42, 73, 112, 0.05);
}

/* User Dropdown Button */
.navbar-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    background: #FFFFFF;
    cursor: pointer;
    transition: all 0.2s ease;
}

.navbar-user-btn:hover {
    border-color: #2a4970;
    background: rgba(42, 73, 112, 0.03);
}

.navbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2a4970 0%, #3a5a80 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.navbar-avatar-text {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
}

.navbar-user-info {
    text-align: left;
}

.navbar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1E293B;
    line-height: 1.2;
}

.navbar-user-role {
    font-size: 0.7rem;
    color: #94A3B8;
}

.navbar-chevron {
    font-size: 0.75rem;
    color: #94A3B8;
    margin-left: 4px;
}

/* Navbar Dropdown */
.navbar-dropdown {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.navbar-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #1E293B;
    transition: all 0.15s ease;
}

.navbar-dropdown .dropdown-item:hover {
    background: #F5F7FB;
    color: #2a4970;
}

.navbar-dropdown .dropdown-item i {
    font-size: 1rem;
    color: #64748B;
}

.navbar-dropdown .dropdown-item:hover i {
    color: #2a4970;
}

.navbar-dropdown .dropdown-divider {
    margin: 8px 0;
    border-color: #E5E7EB;
}

.navbar-dropdown .dropdown-item-logout {
    color: #EF4444;
}

.navbar-dropdown .dropdown-item-logout:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #DC2626;
}

.navbar-dropdown .dropdown-item-logout i {
    color: #EF4444;
}

/* ============================================
   CARDS
   ============================================ */
.card-sia {
    background: #FFFFFF;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #F1F5F9;
    overflow: hidden;
}

.card-sia-header {
    padding: 16px 20px;
    border-bottom: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #F5F7FB;
}

.card-sia-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1E293B;
    margin: 0;
}

.card-sia-body {
    padding: 20px;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: #FFFFFF;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #F1F5F9;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #2a4970;
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.85rem;
    color: #64748B;
    margin: 4px 0 0;
}

.page-header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================
   STAT CARD
   ============================================ */
.stat-card {
    background: #FFFFFF;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #F1F5F9;
    padding: 20px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-card-icon.primary { background: rgba(42, 73, 112, 0.1); color: #2a4970; }
.stat-card-icon.success { background: rgba(16, 185, 129, 0.1); color: #10B981; }
.stat-card-icon.warning { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.stat-card-icon.danger { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.stat-card-icon.info { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }

.stat-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1E293B;
    line-height: 1;
    margin-top: 12px;
}

.stat-card-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
}

/* ============================================
   TABLES
   ============================================ */
.table {
    background: #FFFFFF;
    border-radius: 14px;
    overflow: hidden;
    margin: 0;
}

.table thead th {
    background: #F5F7FB;
    color: #64748B;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid #E5E7EB;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
    font-size: 0.875rem;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: rgba(42, 73, 112, 0.05);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.7rem;
    display: inline-block;
}

.badge-primary { background: rgba(42, 73, 112, 0.1); color: #2a4970; }
.badge-success { background: rgba(16, 185, 129, 0.1); color: #10B981; }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #B45309; }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.badge-info { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 8px 16px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.btn-primary {
    background: #2a4970;
    border-color: #2a4970;
    color: #fff;
}

.btn-primary:hover {
    background: #1f3654;
    border-color: #1f3654;
    color: #fff;
}

.btn-success {
    background: #10B981;
    border-color: #10B981;
    color: #fff;
}

.btn-outline-secondary {
    border-color: #E5E7EB;
    color: #64748B;
    background: transparent;
}

.btn-outline-secondary:hover {
    border-color: #2a4970;
    color: #2a4970;
    background: rgba(42, 73, 112, 0.05);
}

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

/* ============================================
   FORMS
   ============================================ */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #2a4970;
    box-shadow: 0 0 0 3px rgba(42, 73, 112, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: #1E293B;
    font-size: 0.85rem;
    margin-bottom: 6px;
    display: block;
}

/* ============================================
   PROGRESS
   ============================================ */
.progress {
    height: 8px;
    border-radius: 9999px;
    background: #F5F7FB;
    overflow: hidden;
}

.progress-bar {
    border-radius: 9999px;
}

.progress-bar.bg-primary { background: #2a4970 !important; }
.progress-bar.bg-success { background: #10B981 !important; }
.progress-bar.bg-warning { background: #F59E0B !important; }
.progress-bar.bg-danger { background: #EF4444 !important; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    gap: 4px;
}

.page-link {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    color: #1E293B;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.page-link:hover {
    background: #F5F7FB;
    border-color: #2a4970;
    color: #2a4970;
}

.page-item.active .page-link {
    background: #2a4970;
    border-color: #2a4970;
    color: #fff;
}

/* ============================================
   DROPDOWN
   ============================================ */
.dropdown-menu {
    border: 1px solid #F1F5F9;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
}

.dropdown-item {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: #F5F7FB;
    color: #2a4970;
}

/* ============================================
   MODAL
   ============================================ */
.modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.modal-header {
    border-bottom: 1px solid #F1F5F9;
    padding: 16px 24px;
    background: #F5F7FB;
}

.modal-title {
    font-weight: 600;
    color: #1E293B;
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid #F1F5F9;
    padding: 16px 24px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sia-main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .navbar {
        left: 0 !important;
        width: 100% !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .page-header {
        flex-direction: column;
        gap: 16px;
    }

    .page-header-actions {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .sia-main main {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card-sia-header,
    .card-sia-body {
        padding: 16px;
    }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .sidebar,
    .navbar,
    .btn {
        display: none !important;
    }

    .sia-main {
        margin-left: 0;
        width: 100%;
    }
}
