/* Aplikasi Rekam Medis Sanjiwani Farma */
:root {
    --primary-blue: #1e88e5;
    --primary-dark: #1565c0;
    --sidebar-bg: #ffffff;
    --content-bg: #f5f5f5;
    --header-height: 56px;
    --sidebar-width: 260px;
}

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

/* Optimasi rendering - hanya untuk elemen yang benar-benar perlu */
.sidebar {
    contain: layout style paint;
}

.report-section {
    contain: layout style;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--content-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-toggle:active {
    background: rgba(255, 255, 255, 0.25);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0088ff 0%, #006ece 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.header-logo-text {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.header-user:hover {
    background: rgba(255,255,255,0.15);
}

.header-user:active {
    background: rgba(255,255,255,0.25);
}

.header-user-icon {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.chevron-down {
    font-size: 12px;
}

/* Layout */
.app-layout {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: calc(100vh - var(--header-height));
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    position: fixed;
    left: 0;
    top: var(--header-height);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.sidebar.collapsed {
    width: 0;
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px;
    position: relative;
}

.sidebar.collapsed .nav-toggle {
    display: none;
}

.sidebar.collapsed .nav-submenu {
    display: none;
}

.sidebar.collapsed .nav-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: nowrap;
    margin-left: 12px;
    font-size: 0.875rem;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
}

.sidebar.collapsed .nav-link:hover::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #333;
    margin-left: 6px;
    z-index: 1001;
    pointer-events: none;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: padding 0.3s ease;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand {
    padding: 20px 12px;
    justify-content: center;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #64b5f6 0%, #ff9800 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-item {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #555;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
    white-space: nowrap;
}

.nav-text {
    transition: opacity 0.3s ease;
    flex: 1;
}

.nav-link:hover {
    background: #f0f7ff;
    color: var(--primary-blue);
}

.nav-link.active {
    background: #e3f2fd;
    color: var(--primary-blue);
    border-left-color: var(--primary-blue);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.nav-toggle {
    margin-left: auto;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    font-size: 12px;
    color: #999;
}

.nav-toggle.expanded {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #fafafa;
}

.nav-submenu.expanded {
    max-height: 500px;
}

.nav-submenu .nav-link {
    padding-left: 56px;
    font-size: 0.9rem;
    padding-top: 10px;
    padding-bottom: 10px;
}

.nav-submenu .nav-link i {
    font-size: 16px;
    width: 20px;
}

.nav-submenu .nav-link span {
    transition: opacity 0.3s ease;
    /* Izinkan teks menu panjang menjadi dua baris agar tidak terpotong */
    white-space: normal;
    line-height: 1.3;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 0;
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left 0.3s ease;
}

/* Main content menyesuaikan saat sidebar muncul */
.main-content:not(.sidebar-collapsed) {
    margin-left: var(--sidebar-width);
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* Report Sections */
.report-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 24px;
    overflow: hidden;
}

.report-header {
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

.report-header.today {
    background: #e3f2fd;
    color: #1565c0;
}

.report-header.flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.report-header .toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-wrap {
    overflow-x: auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-grid .form-group-full {
    grid-column: 1 / -1;
}

.btn-actions-cell {
    text-align: center;
    white-space: nowrap;
}

.btn-actions-cell .btn {
    margin-right: 4px;
    width: 32px;
    height: 32px;
    padding: 4px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.btn-actions-cell .btn:last-child {
    margin-right: 0;
}

.report-header.monthly {
    background: #fff8e1;
    color: #f57c00;
}

.report-header.graph {
    background: #eceff1;
    color: #455a64;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table th {
    padding: 12px 20px;
    text-align: left;
    font-weight: 500;
    font-size: 0.9rem;
}

.report-table.today th {
    background: #ffebee;
}

.report-table.today td {
    background: #ffebee;
}

.report-table.monthly th {
    background: #e8f5e9;
}

.report-table.monthly td {
    background: #e8f5e9;
}

.report-table td {
    padding: 12px 20px;
    font-size: 0.9rem;
}

/* Zebra striping agar baris tabel mudah diikuti */
.report-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.report-table tbody tr:nth-child(odd) {
    background-color: #fff;
}

.report-table tbody tr:hover {
    background-color: #f0f7ff;
}

.report-table .value-red {
    color: #c62828;
    font-weight: 600;
}

.report-table .sort-icon {
    font-size: 10px;
    opacity: 0.6;
}

/* Chart */
.chart-container {
    padding: 24px;
    min-height: 300px;
}

.chart-legend {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 24px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.sks { background: #4fc3f7; }
.legend-color.antigen { background: #81c784; }
.legend-color.umum { background: #e57373; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-success {
    background: #2e7d32;
    color: #fff;
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-danger {
    background: #e53935;
    color: #fff;
}

.btn-danger:hover {
    background: #c62828;
}

.btn-warning {
    background: #fb8c00;
    color: #fff;
}

.btn-warning:hover {
    background: #ef6c00;
}

/* DataTables custom styling */
.dataTables_wrapper {
    padding: 16px 20px 12px;
}

.dataTables_length,
.dataTables_filter {
    font-size: 0.9rem;
    color: #555;
}

.dataTables_length label,
.dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dataTables_length select {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #ddd;
}

.dataTables_filter input {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #ddd;
    font-size: 0.9rem;
}

.dataTables_info {
    font-size: 0.85rem;
    color: #666;
    padding-top: 8px;
}

.dataTables_paginate {
    padding-top: 8px;
}

.dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    border: 1px solid #ddd !important;
    padding: 4px 10px !important;
    margin: 0 2px !important;
    font-size: 0.85rem;
    color: #1565c0 !important;
    background: #fff !important;
}

.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover {
    background: #1565c0 !important;
    color: #fff !important;
    border-color: #1565c0 !important;
}

.dataTables_paginate .paginate_button:hover {
    background: #e3f2fd !important;
    border-color: #90caf9 !important;
}

.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover {
    color: #999 !important;
    background: #f5f5f5 !important;
    border-color: #e0e0e0 !important;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Radio group - Jenis Kelamin */
.form-group-radio .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group .radio-group {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}

.form-group .radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.95rem;
    margin: 0;
    padding: 10px 12px;
    background: #fff;
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
}

.form-group .radio-option:last-child {
    border-bottom: none;
}

.form-group .radio-option:hover {
    background: #f8f9fa;
}

.form-group .radio-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary-blue);
}

.form-group .radio-option:has(input:checked) {
    background: #e3f2fd;
    border-bottom-color: #e3f2fd;
}

.form-group .radio-option:has(input:checked) + .radio-option {
    border-top: none;
}

.form-group .radio-text {
    user-select: none;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.2);
}

/* Password visibility toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-control {
    padding-right: 40px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    cursor: pointer;
    color: #888;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: #555;
}

/* Page Header & Title */
.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: #333;
    font-weight: 600;
}

.page-header .page-title {
    margin-bottom: 0;
}

/* Login Page - background bergelombang biru */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #1565c0;
}

.login-bg-waves {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.login-wave-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.login-wave-1 {
    opacity: 0.92;
}

.login-wave-2 {
    opacity: 0.7;
}

.login-wave-3 {
    opacity: 0.55;
}

.login-box {
    position: relative;
    z-index: 1;
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    color: #333;
    font-size: 1.5rem;
}

.login-error,
.alert-error {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* Kelas .alert-error = pesan error konsisten di semua halaman (sama tampilan dengan login-error) */

/* Dropdown */
.user-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    display: none !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1001;
}

.dropdown-menu.show {
    display: block !important;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background: #f5f5f5;
}

.dropdown-menu a:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-menu a:last-child {
    border-radius: 0 0 8px 8px;
}

/* Modal Pasien */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 16px;
}

.modal-backdrop.show {
    display: flex;
}

.modal-dialog {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-dialog-sm {
    max-width: 450px;
}

.modal-header {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    color: #666;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

/* SweetAlert di lapisan paling depan */
.swal2-container {
    z-index: 2000 !important;
}

/* Responsif: layar kecil */
@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }
    .header {
        padding: 0 12px;
    }
    .header-logo-text {
        font-size: 1rem;
    }
    .header-user span {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .report-table th,
    .report-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    .report-header {
        padding: 10px 14px;
    }
    .btn-actions-cell .btn,
    .btn-actions-cell form button {
        min-width: 32px;
        padding: 4px 6px !important;
    }
}

/* Aksesibilitas: focus terlihat untuk tombol */
.btn:focus-visible,
.sidebar-toggle:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}
