/*
 * SIMKLINIK - Hospital Management System
 * Main Stylesheet — SIMRS Guard UI Style Guide
 * Font: Plus Jakarta Sans | Colors: Dark Navy Theme
 */

/* ============================================
   0. GOOGLE FONTS IMPORT
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ============================================
   1. CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    --font-primary: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, sans-serif;
    --font-mono: Consolas, 'Courier New', monospace;

    --dark-navy: #1a252f;
    --dropdown-bg: #232f3e;
    --table-header: #2c3e50;
    --primary-blue: #2980b9;
    --accent-blue: #3498db;
    --page-bg: #f0f2f5;
    --card-bg: #ffffff;

    --success: #27ae60;
    --success-bg: #d4edda;
    --success-text: #155724;
    --danger: #e74c3c;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --warning: #f39c12;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --info: #0c5460;
    --info-bg: #d1ecf1;

    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --navbar-inactive: #b0b8c1;

    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px;
    --navbar-height: 56px;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
}

/* ============================================
   2. RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-primary);
    font-weight: 400;
    color: var(--text-primary);
    background: var(--page-bg);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

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

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul, ol {
    list-style: none;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* ============================================
   3. SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark-navy);
    color: #fff;
    z-index: 1000;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }

/* --- Header --- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.sidebar-brand i { font-size: 1.2rem; color: var(--accent-blue); flex-shrink: 0; }
.brand-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--navbar-inactive);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* --- Search box --- */
.sidebar-search {
    padding: 10px 14px 6px;
    flex-shrink: 0;
}

.sidebar-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-box i {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.sidebar-search-box input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 0.8rem;
    font-family: var(--font-primary);
    outline: none;
    transition: var(--transition);
}
.sidebar-search-box input::placeholder { color: rgba(255,255,255,0.35); }
.sidebar-search-box input:focus { background: rgba(255,255,255,0.12); border-color: var(--accent-blue); }

/* --- Nav (scrollable) --- */
.sidebar-nav {
    flex: 1;
    padding: 6px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

/* --- Collapsible section --- */
.sidebar-section { }

.sidebar-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--navbar-inactive);
    padding: 14px 16px 6px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}
.sidebar-group:hover { color: #fff; }

.group-arrow {
    font-size: 0.55rem;
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.sidebar-section.open .group-arrow { transform: rotate(180deg); }

.sidebar-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.sidebar-section.open .sidebar-group-items { max-height: 2000px; }

/* --- Link --- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    color: var(--navbar-inactive);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    text-decoration: none;
}

.sidebar-link.active {
    color: #fff;
    background: rgba(41,128,185,0.2);
    border-left-color: var(--accent-blue);
    font-weight: 600;
}

.sidebar-link i:first-child {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-link span { overflow: hidden; text-overflow: ellipsis; }

/* --- Submenu arrow --- */
.submenu-arrow {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.sidebar-item.has-children.open > .sidebar-link .submenu-arrow { transform: rotate(90deg); }

/* --- Submenu --- */
.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background: rgba(0,0,0,0.15);
}

.sidebar-item.has-children.open > .sidebar-submenu { max-height: 600px; }

.sidebar-submenu .sidebar-link {
    padding-left: 48px;
    font-size: 0.82rem;
    border-left: none;
}

.sidebar-submenu .sidebar-link:hover { background: rgba(255,255,255,0.04); }

/* --- Separator --- */
.sidebar-separator {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 6px 14px;
}

/* --- Footer --- */
.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: var(--navbar-inactive);
    flex-shrink: 0;
    text-align: center;
}
.sidebar-footer .small { font-size: 0.68rem; }

/* --- Collapsed state --- */
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .sidebar-group,
body.sidebar-collapsed .sidebar-group-items,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .submenu-arrow,
body.sidebar-collapsed .sidebar-submenu,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .sidebar-collapse-btn { display: none; }

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    border-left: none;
}
body.sidebar-collapsed .sidebar-link i:first-child { width: auto; font-size: 1.05rem; }

body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 14px 8px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; }
body.sidebar-collapsed .sidebar-section.open .sidebar-group-items { max-height: 2000px; }

/* Tooltip on hover when collapsed */
body.sidebar-collapsed .sidebar-link { position: relative; }
body.sidebar-collapsed .sidebar-link:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 6px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--table-header);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    white-space: nowrap;
    z-index: 2000;
    box-shadow: var(--shadow);
    pointer-events: none;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ============================================
   4. TOPBAR
   ============================================ */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--navbar-height);
    background: #ffffff;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 999;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid #e8e8e8;
}

body.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed-width);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-sidebar:hover {
    color: var(--text-primary);
    background: var(--page-bg);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary-blue); text-decoration: none; }
.breadcrumb-sep { color: var(--text-muted); font-size: 0.75rem; }
.breadcrumb-current { color: var(--text-primary); font-weight: 600; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* User dropdown in topbar */
.topbar-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: var(--transition);
    color: var(--text-primary);
}

.topbar-user:hover { background: var(--page-bg); }

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-blue));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.user-arrow {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-left: 2px;
    transition: transform 0.2s;
}

.topbar-user:hover .user-arrow { transform: rotate(180deg); }

/* Dropdown menu (used by topbar user dropdown) */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid #e8e8e8;
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition);
    z-index: 1100;
}

.topbar-user:hover .dropdown-menu,
.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.dropdown-menu a:hover {
    color: var(--text-primary);
    background: var(--page-bg);
    text-decoration: none;
}

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

.dropdown-menu a.text-danger:hover {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.dropdown-divider {
    height: 1px;
    background: #e8e8e8;
    margin: 4px 0;
}

/* ============================================
   5. MAIN CONTENT AREA
   ============================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: 100vh;
}

body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.content {
    margin-top: var(--navbar-height);
    padding: 24px;
    min-height: calc(100vh - var(--navbar-height));
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

/* ============================================
   6. BREADCRUMB (standalone, if used)
   ============================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

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

.breadcrumb a:hover {
    color: var(--primary-blue);
    text-decoration: none;
}

.breadcrumb .separator {
    color: var(--text-muted);
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   7. CARDS
   ============================================ */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--page-bg);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card h2 i { font-size: 0.95rem; color: var(--primary-blue); }
.card h2 .btn { margin-left: auto; }

.card h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--page-bg);
}

.card-header h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

/* ============================================
   8. BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-family: var(--font-primary);
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary:hover {
    background: #2472a4;
    color: #ffffff;
}

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

.btn-success:hover {
    background: #219a52;
    color: #ffffff;
}

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

.btn-warning:hover {
    background: #d68910;
    color: #ffffff;
}

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

.btn-danger:hover {
    background: #c0392b;
    color: #ffffff;
}

.btn-secondary {
    background: #6c757d;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #5a6268;
    color: #ffffff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
}

.btn-outline:hover {
    background: var(--primary-blue);
    color: #ffffff;
}

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

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-group {
    display: inline-flex;
    gap: 6px;
}

/* ============================================
   9. BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    line-height: 1.4;
}

.badge-ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-no {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.badge-warn {
    background: var(--warning-bg);
    color: var(--warning-text);
}

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

.badge-primary {
    background: rgba(41, 128, 185, 0.15);
    color: var(--primary-blue);
}

/* ============================================
   10. STATUS MESSAGES
   ============================================ */
.status {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status.ok {
    background: var(--success-bg);
    color: var(--success-text);
    border-left: 4px solid var(--success);
}

.status.err {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-left: 4px solid var(--danger);
}

.status.info {
    background: var(--info-bg);
    color: var(--info);
    border-left: 4px solid var(--accent-blue);
}

.status.warn {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-left: 4px solid var(--warning);
}

/* ============================================
   11. TABS
   ============================================ */
.tabs {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 20px;
    gap: 0;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-primary);
}

.tab:hover {
    color: var(--primary-blue);
}

.tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   12. STAT CARDS & GRIDS
   ============================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }

/* Tighter grids inside forms */
form .grid-2, form .grid-3, form .grid-4 { gap: 10px 14px; margin-bottom: 0; }
form .grid-2 .form-group, form .grid-3 .form-group, form .grid-4 .form-group { margin-bottom: 0; }

.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-left: 4px solid var(--primary-blue);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--accent-blue); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon {
    font-size: 2rem;
    color: var(--text-muted);
    opacity: 0.5;
}

/* ============================================
   13. TABLES
   ============================================ */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: var(--border-radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

table thead th {
    background: var(--table-header);
    color: #ffffff;
    font-weight: 600;
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
    border: none;
}

table thead th:first-child {
    border-radius: 6px 0 0 0;
}

table thead th:last-child {
    border-radius: 0 6px 0 0;
}

table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

table tbody tr:hover {
    background: rgba(41, 128, 185, 0.04);
}

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

table tbody tr:nth-child(even) {
    background: #fafbfc;
}

table tbody tr:nth-child(even):hover {
    background: rgba(41, 128, 185, 0.04);
}

table tfoot td {
    padding: 10px 14px;
    font-weight: 600;
    border-top: 2px solid var(--table-header);
}

/* ============================================
   14. FORMS
   ============================================ */
/* --- Form group (compact) --- */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 3px;
    color: var(--text-secondary);
}

.form-group label .required,
.text-danger { color: var(--danger); }

/* --- Inputs --- */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="search"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 7px 10px;
    font-family: var(--font-primary);
    font-size: 0.82rem;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.4;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.12);
}

.form-control:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    background: #f3f4f6;
    color: var(--text-muted);
    cursor: not-allowed;
}

input::placeholder,
textarea::placeholder { color: #bbb; font-size: 0.8rem; }

textarea { min-height: 60px; resize: vertical; }

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

/* --- Form layouts --- */
.form-grid { display: grid; gap: 10px 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-grid .form-group { margin-bottom: 0; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .span-full { grid-column: 1 / -1; }

.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.form-inline .form-group { margin-bottom: 0; }

/* --- Form section divider --- */
.form-section {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 14px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e8e8e8;
}

/* --- Checkbox & radio --- */
.form-check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.82rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary-blue);
    cursor: pointer;
}

.form-help {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-error {
    font-size: 0.72rem;
    color: var(--danger);
    margin-top: 2px;
}

/* --- Actions bar --- */
.form-actions {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

/* --- Checkbox group (roles, klinik) --- */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.82rem;
    padding: 3px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary-blue);
    cursor: pointer;
}

/* ============================================
   15. UTILITIES
   ============================================ */
.small { font-size: 0.8rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-primary { color: var(--primary-blue) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.mr-10 { margin-right: 10px; }
.ml-10 { margin-left: 10px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.p-10 { padding: 10px; }
.p-20 { padding: 20px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }
.flex-wrap { flex-wrap: wrap; }

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--page-bg);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading.lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.highlight {
    background: rgba(243, 156, 18, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
}

.code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 16px 20px;
    border-radius: 6px;
    overflow-x: auto;
    line-height: 1.6;
    margin-bottom: 16px;
}

.code-inline {
    background: #f0f0f0;
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--danger);
}

.hidden { display: none !important; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   16. MODAL / DIALOG
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

.modal-lg { max-width: 780px; }
.modal-sm { max-width: 400px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

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

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #eee;
}

/* ============================================
   17. DATATABLES OVERRIDES
   ============================================ */
.dataTables_wrapper {
    font-family: var(--font-primary);
    font-size: 0.88rem;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 16px;
}

.dataTables_wrapper .dataTables_length select {
    padding: 5px 28px 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: var(--font-primary);
    min-width: 60px;
}

.dataTables_wrapper .dataTables_filter input {
    padding: 7px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: var(--font-primary);
    margin-left: 8px;
    width: 200px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding-top: 12px;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 12px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db !important;
    background: #ffffff !important;
    color: var(--text-primary) !important;
    margin: 0 2px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: var(--transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-blue) !important;
    color: #ffffff !important;
    border-color: var(--primary-blue) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-blue) !important;
    color: #ffffff !important;
    border-color: var(--primary-blue) !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.dataTables_wrapper table.dataTable thead .sorting::after,
.dataTables_wrapper table.dataTable thead .sorting_asc::after,
.dataTables_wrapper table.dataTable thead .sorting_desc::after {
    opacity: 0.6;
}

.dataTables_wrapper .dataTables_empty {
    text-align: center;
    padding: 32px !important;
    color: var(--text-muted);
}

/* ============================================
   18. PERMISSION MATRIX (Tri-State Checkboxes)
   ============================================ */
.permission-matrix,
.perm-matrix {
    width: 100%;
    border-collapse: collapse;
}

.permission-matrix thead th,
.perm-matrix thead th {
    background: var(--table-header);
    color: #ffffff;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
}

.permission-matrix thead th:first-child,
.perm-matrix thead th:first-child {
    text-align: left;
    min-width: 200px;
}

.permission-matrix tbody td,
.perm-matrix tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    text-align: center;
    vertical-align: middle;
}

.permission-matrix tbody td:first-child,
.perm-matrix tbody td:first-child {
    text-align: left;
    font-weight: 500;
}

.permission-matrix tbody tr:hover,
.perm-matrix tbody tr:hover {
    background: rgba(41, 128, 185, 0.04);
}

/* Tri-state checkbox (legacy class) */
.tri-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    background: #ffffff;
    font-size: 0.75rem;
    color: transparent;
    user-select: none;
}

.tri-state:hover {
    border-color: var(--primary-blue);
}

.tri-state.checked {
    background: var(--success);
    border-color: var(--success);
    color: #ffffff;
}

.tri-state.denied {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.tri-state.partial {
    background: var(--warning);
    border-color: var(--warning);
    color: #ffffff;
}

/* Tri-check button styles (new tri-check pattern) */
.tri-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    background: #ffffff;
    font-size: 0.8rem;
    color: transparent;
    user-select: none;
    padding: 0;
    font-family: var(--font-primary);
}

.tri-check:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.15);
}

.tri-check.tri-null {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: var(--text-muted);
}

.tri-check.tri-grant {
    background: var(--success);
    border-color: var(--success);
    color: #ffffff;
}

.tri-check.tri-deny {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.permission-group-header {
    background: #f8f9fa !important;
    font-weight: 700 !important;
}

.permission-group-header td:first-child {
    padding-left: 12px;
    font-size: 0.9rem;
}

.permission-child td:first-child {
    padding-left: 32px;
    font-weight: 400;
    color: var(--text-secondary);
}

/* ============================================
   19. PAGINATION (standalone)
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid #d1d5db;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.pagination a:hover {
    background: var(--primary-blue);
    color: #ffffff;
    border-color: var(--primary-blue);
    text-decoration: none;
}

.pagination .active {
    background: var(--primary-blue);
    color: #ffffff;
    border-color: var(--primary-blue);
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================
   20. TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 420px;
    padding: 14px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: toastSlideIn 0.35s ease;
    background: var(--card-bg);
    color: var(--text-primary);
    border-left: 4px solid var(--accent-blue);
}

.toast.toast-success {
    border-left-color: var(--success);
    background: var(--success-bg);
    color: var(--success-text);
}

.toast.toast-error {
    border-left-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger-text);
}

.toast.toast-warning {
    border-left-color: var(--warning);
    background: var(--warning-bg);
    color: var(--warning-text);
}

.toast.toast-info {
    border-left-color: var(--accent-blue);
    background: var(--info-bg);
    color: var(--info);
}

.toast.toast-hide {
    animation: toastSlideOut 0.3s ease forwards;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: auto;
    padding: 0 2px;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ============================================
   21. PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .topbar,
    .btn-toggle-sidebar,
    .btn,
    .no-print {
        display: none !important;
    }

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

    .content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    body {
        background: #ffffff;
    }
}

/* ============================================
   22. RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 768px) {
    /* Sidebar collapses off-screen on mobile */
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

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

    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .topbar {
        left: 0 !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .content {
        padding: 16px;
    }

    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

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

    .modal {
        width: 95%;
        max-height: 90vh;
    }

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    /* Mobile sidebar overlay */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 140px;
    }

    table {
        font-size: 0.82rem;
    }

    table thead th,
    table tbody td {
        padding: 8px 10px;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .card {
        padding: 16px;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    .btn {
        padding: 7px 14px;
        font-size: 0.82rem;
    }

    .topbar {
        padding: 0 12px;
    }

    .user-info,
    .user-arrow,
    .breadcrumb-current {
        display: none;
    }
}

/* ============================================
   23. KLINIK SWITCHER
   ============================================ */
.klinik-switcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ebf5fb, #e8f8f5);
    border: 1px solid #d5e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--table-header);
    transition: var(--transition);
    max-width: 260px;
}

.klinik-switcher:hover { background: linear-gradient(135deg, #d4e8f5, #d1f0e8); }
.klinik-switcher i:first-child { color: var(--primary-blue); font-size: 0.95rem; }
.klinik-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.klinik-dropdown {
    min-width: 280px !important;
    right: 0;
    left: auto;
}

.klinik-dropdown a {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.klinik-dropdown a.active-klinik {
    background: #ebf5fb;
    font-weight: 600;
    color: var(--primary-blue);
}

.klinik-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #ebf5fb;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-blue);
}

/* ============================================
   24. SWEETALERT2 + TOASTR OVERRIDES
   ============================================ */
.swal-simklinik {
    font-family: var(--font-primary) !important;
    border-radius: 12px !important;
}

.swal-simklinik .swal2-title {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
    color: var(--table-header) !important;
}

.swal-simklinik .swal2-html-container {
    font-size: 0.9rem !important;
    color: var(--text-secondary) !important;
}

.swal-simklinik .btn {
    margin: 0 4px;
    padding: 8px 20px;
    font-size: 0.85rem;
}

/* Toastr position & style tweaks */
#toast-container > .toast {
    font-family: var(--font-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 1;
}

#toast-container > .toast-success { background-color: var(--success); }
#toast-container > .toast-error { background-color: var(--danger); }
#toast-container > .toast-warning { background-color: var(--warning); }
#toast-container > .toast-info { background-color: var(--primary-blue); }

#toast-container > .toast .toast-progress {
    opacity: 0.3;
}

/* ============================================
   24. TARIF MATRIX TABLE
   ============================================ */
.tarif-matrix {
    width: 100%;
    border-collapse: collapse;
}

.tarif-matrix thead th {
    background: var(--table-header);
    color: #fff;
    padding: 12px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
}

.tarif-matrix thead th:first-child {
    text-align: left;
}

.tarif-matrix tbody td {
    padding: 8px 10px;
    border: 1px solid #e8e8e8;
    vertical-align: middle;
}

.tarif-matrix tbody tr:hover {
    background: rgba(41,128,185,0.04);
}

.tarif-matrix .tarif-input {
    width: 100%;
    max-width: 160px;
    padding: 6px 10px;
    font-size: 0.85rem;
    text-align: right;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    transition: all 0.2s;
}

.tarif-matrix .tarif-input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(41,128,185,0.15);
    outline: none;
}

.table-responsive {
    overflow-x: auto;
    margin-bottom: 16px;
}

/* Kelas collapsible body */
.kelas-body.collapsed {
    display: none;
}
