/* ======================================
   NPHSys — Quality Records Management
   نظام إدارة سجلات الجودة — التنسيقات
   ====================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --primary: #0d6a4e;
    --primary-dark: #094d38;
    --primary-light: #10a37f;
    --primary-gradient: linear-gradient(135deg, #0d6a4e, #094d38);
    --sidebar-bg: #f0f7f4;
    --sidebar-hover: #dceee7;
    --sidebar-active: #0d6a4e;
    --body-bg: #f0f2f5;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #6c757d;
    --text-light: #ffffff;
    --border-color: #e9ecef;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* Override Bootstrap */
.text-primary { color: var(--primary) !important; }
.bg-primary { background: var(--primary) !important; }
.btn-primary {
    background: var(--primary-gradient);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(13,106,78,0.15);
}

.nav-tabs .nav-link.active { color: var(--primary) !important; border-bottom: 3px solid var(--primary); font-weight: 700; background: transparent; }
.nav-tabs .nav-link { color: var(--text-dark); font-weight: 500; }
.nav-tabs .nav-link:hover { color: var(--primary); border-bottom: 3px solid var(--primary-light); }

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-dark);
    direction: rtl;
    min-height: 100vh;
    font-size: 14px;
    overflow-x: hidden;
}

h4, h5 { font-weight: 700; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* ======= LOGIN PAGE ======= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8f5 30%, #c8e6c9 60%, #a5d6a7 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(13,106,78,0.12) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(13,106,78,0.08) 0%, transparent 70%);
    bottom: -50px;
    left: -50px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 45px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.12);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(13,106,78,0.15);
}

.login-logo {
    width: 140px;
    height: auto;
    margin-bottom: 15px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.login-title {
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.login-card .form-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.login-card .input-group {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.login-card .input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,106,78,0.1);
}

.login-card .input-group-text {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 1.1rem;
    padding: 12px 15px;
}

.login-card .form-control {
    border: none;
    padding: 12px 10px;
    font-size: 0.95rem;
    background: transparent;
}

.login-card .form-control:focus { box-shadow: none; }

.btn-login {
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius);
    padding: 13px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    width: 100%;
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(13,106,78,0.35);
    color: #fff;
}

.login-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    text-align: center;
    padding: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ======= SIDEBAR ======= */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    box-shadow: -5px 0 20px rgba(0,0,0,0.06);
    border-left: 1px solid #c8e6c9;
}

.sidebar-brand {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid #c8e6c9;
}

.sidebar-brand img { width: 70px; height: auto; margin-bottom: 10px; }
.sidebar-brand h5 { color: var(--primary); font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.sidebar-brand small { color: #6c8e7e; font-size: 0.65rem; letter-spacing: 2px; text-transform: uppercase; }

.sidebar-section {
    padding: 15px 15px 5px;
    color: #6c8e7e;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.sidebar-menu { list-style: none; padding: 0 10px; margin: 0; }
.sidebar-menu li { margin-bottom: 3px; }
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    color: #3a5a4a;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
}
.sidebar-menu a:hover { background: var(--sidebar-hover); color: var(--primary); }
.sidebar-menu a.active {
    background: linear-gradient(135deg, rgba(13,106,78,0.2), rgba(13,106,78,0.08));
    color: var(--primary);
    font-weight: 700;
    border-right: 3px solid var(--primary);
}
.sidebar-menu a i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-menu .badge { margin-right: auto; font-size: 0.7rem; padding: 3px 8px; }

/* Sidebar Submenus */
.sidebar-submenu-section { margin: 0; }
.sidebar-submenu-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    margin: 0 10px 3px;
    color: #6c8e7e;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.5px;
}
.sidebar-submenu-toggle:hover { background: var(--sidebar-hover); color: var(--primary); }
.sidebar-submenu-toggle.open { color: var(--primary); }
.sidebar-submenu-toggle i:first-child { font-size: 1rem; width: 22px; text-align: center; }
.sidebar-submenu-toggle .sidebar-chevron { margin-right: auto; font-size: 0.65rem; transition: transform 0.3s ease; }
.sidebar-submenu-toggle.open .sidebar-chevron { transform: rotate(180deg); }
.sidebar-submenu { display: none; padding-right: 12px; }
.sidebar-submenu.show { display: block; }
.sidebar-submenu a { padding: 8px 15px; font-size: 0.85rem; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ======= TOP NAVBAR ======= */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 260px;
    height: 65px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    z-index: 999;
}

.page-title-nav { color: var(--text-dark); font-weight: 600; font-size: 0.95rem; }

.navbar-actions { display: flex; align-items: center; gap: 15px; }

.datetime-box {
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    gap: 8px;
    cursor: default;
}
.datetime-icon { color: #fff; font-size: 1rem; opacity: 0.85; }
.datetime-text { line-height: 1.15; direction: ltr; font-variant-numeric: tabular-nums; }
.datetime-time { font-size: 0.82rem; font-weight: 700; color: #fff; }
.datetime-date { font-size: 0.68rem; color: rgba(255,255,255,0.8); }

.nav-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
}
.nav-icon:hover { background: var(--body-bg); color: var(--primary); }

.notif-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Notification Dropdown */
.notification-wrapper { position: relative; }
.notification-dropdown {
    display: none;
    position: absolute;
    top: 50px;
    left: 0;
    width: 340px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    overflow: hidden;
}
.notification-dropdown.show { display: block; }
.notif-header { padding: 12px 16px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.mark-all-read { font-size: 0.8rem; color: var(--primary); text-decoration: none; }
.notif-list { max-height: 350px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-color); text-decoration: none; transition: var(--transition); }
.notif-item:hover { background: var(--body-bg); }
.notif-item.unread { background: #f0f7f4; }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.9rem; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 0.85rem; color: var(--text-dark); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 0.75rem; color: var(--text-muted); }
.notif-empty { padding: 30px; text-align: center; color: var(--text-muted); }
.notif-empty i { font-size: 2rem; margin-bottom: 8px; display: block; }

/* User Info */
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}
.user-details { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-dark); }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ======= MAIN CONTENT ======= */
.main-content {
    margin-right: 260px;
    margin-top: 65px;
    padding: 25px;
    min-height: calc(100vh - 65px);
}

/* ======= CARDS ======= */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--card-bg);
    transition: var(--transition);
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 18px 20px;
    font-weight: 700;
}

/* Stat Cards */
.stat-card {
    border-radius: var(--radius);
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 2.5rem;
    opacity: 0.2;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; }
.stat-card .stat-label { font-size: 0.85rem; opacity: 0.85; }

/* ======= TABLES ======= */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table thead th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 12px 15px;
    white-space: nowrap;
    border: none;
}
.table tbody td {
    padding: 10px 15px;
    font-size: 0.88rem;
    vertical-align: middle;
    border-color: var(--border-color);
}
.table tbody tr:hover { background: #f8fdf9; }

/* DataTables override */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 20px;
    border: 2px solid var(--border-color);
    padding: 6px 15px;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,106,78,0.1);
    outline: none;
}
.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
}
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.page-link { color: var(--primary); }

/* ======= BADGES ======= */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-draft { background: #e9ecef; color: #6c757d; }
.badge-active { background: #d4edda; color: #155724; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-rejected { background: #f8d7da; color: #721c24; }
.badge-obsolete { background: #e2e3e5; color: #383d41; }

/* ======= BUTTONS ======= */
.btn-gold, .btn-qms {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    transition: var(--transition);
}
.btn-gold:hover, .btn-qms:hover {
    background: var(--primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(13,106,78,0.3);
}

.btn-sm-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
}

/* ======= LOADING OVERLAY ======= */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.loading-overlay { display: flex; }

.spinner-qms {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(13,106,78,0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ======= SPA PAGE TRANSITIONS ======= */
.main-content {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.main-content.page-leaving {
    opacity: 0.4;
    transform: translateY(5px);
    pointer-events: none;
}
.main-content.page-entering {
    animation: pageSlideIn 0.25s ease-out;
}
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ======= ALERTS ======= */
.alert-custom {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ======= FORM RECORD ======= */
.form-record-table {
    font-size: 0.85rem;
}
.form-record-table th {
    background: var(--primary) !important;
    color: #fff;
    font-weight: 600;
    padding: 8px 10px;
    white-space: nowrap;
    font-size: 0.8rem;
}
.form-record-table td {
    padding: 6px 8px;
    vertical-align: middle;
}
.form-record-table input,
.form-record-table select,
.form-record-table textarea {
    font-size: 0.85rem;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
}
.form-record-table input:focus,
.form-record-table select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(13,106,78,0.1);
}

/* Row status colors */
.row-draft { border-left: 3px solid #6c757d; }
.row-pending { border-left: 3px solid #ffc107; background: #fffdf0; }
.row-approved { border-left: 3px solid #28a745; background: #f6fff8; }
.row-rejected { border-left: 3px solid #dc3545; background: #fff8f8; }

/* ======= SIGNATURE PAD ======= */
.signature-pad-container {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}
.signature-pad-container:hover { border-color: var(--primary); }
.signature-pad-container canvas { border: 1px solid #eee; border-radius: 4px; }

/* ======= LIBRARY CARDS ======= */
.library-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
    height: 100%;
}
.library-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(13,106,78,0.12);
    transform: translateY(-2px);
}
.library-card .library-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(13,106,78,0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 12px;
}
.library-card .library-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 5px; }
.library-card .library-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }
.library-card .library-meta { font-size: 0.75rem; color: var(--text-muted); }
.library-card .library-meta span { margin-left: 12px; }

/* ======= APPROVAL SECTION ======= */
.approval-timeline {
    position: relative;
    padding-right: 30px;
}
.approval-timeline::before {
    content: '';
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}
.approval-step {
    position: relative;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: var(--body-bg);
    border-radius: var(--radius-sm);
}
.approval-step::before {
    content: '';
    position: absolute;
    right: -25px;
    top: 15px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-color);
    border: 2px solid #fff;
}
.approval-step.done::before { background: var(--success); }
.approval-step.current::before { background: var(--warning); animation: pulse 1.5s infinite; }
.approval-step.rejected-step::before { background: var(--danger); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,193,7,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255,193,7,0); }
}

/* ======= ACTIVITY LOG STYLES ======= */
.timeline-item { transition: background 0.2s; }
.timeline-item:hover { background: rgba(13,106,78,0.03); }
.timeline-date { border-right: 3px solid var(--primary); }
.timeline-list .list-group-item:hover { background: rgba(13,106,78,0.03); }
.timeline-list .list-group-item { transition: background 0.2s; }
table .table-warning ins { text-decoration: none; background: rgba(40,167,69,0.12); padding: 1px 4px; border-radius: 3px; }
table .table-warning del { background: rgba(220,53,69,0.08); padding: 1px 4px; border-radius: 3px; }

/* ======= PRINT STYLES ======= */
@media print {
    .sidebar, .top-navbar, .sidebar-overlay, .no-print { display: none !important; }
    .main-content { margin: 0 !important; padding: 15px !important; }
    body { font-size: 11px; background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .table thead th { background: #f0f0f0 !important; color: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ======= RESPONSIVE ======= */

/* Tablet / Small Laptops */
@media (max-width: 991.98px) {
    .sidebar {
        right: -280px;
        width: 280px;
    }
    .sidebar.show { right: 0; }
    .top-navbar { right: 0; }
    .main-content { margin-right: 0; }

    /* Modals — nearly full width */
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg {
        max-width: calc(100% - 1rem);
        margin: 0.5rem auto;
    }
}

/* Mobile Phone */
@media (max-width: 575.98px) {
    /* Layout */
    .main-content {
        padding: 12px;
        margin-top: 56px;
        padding-bottom: 75px;
    }
    .top-navbar {
        padding: 0 10px;
        height: 56px;
    }
    .sidebar-toggle { font-size: 1.2rem; }

    /* Stat cards */
    .stat-card { padding: 14px 12px; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .stat-card .stat-icon { font-size: 1.8rem; top: 10px; left: 10px; }
    .stat-card .stat-label { font-size: 0.75rem; }

    /* Cards */
    .card { border-radius: 10px; }
    .card-header { padding: 12px 14px; font-size: 0.9rem; }
    .card-body { padding: 12px; }

    /* Tables */
    .table thead th { padding: 8px 6px; font-size: 0.78rem; }
    .table tbody td { padding: 7px 6px; font-size: 0.82rem; }
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length { text-align: center !important; float: none !important; margin-bottom: 8px; }
    .dataTables_wrapper .dataTables_info { text-align: center; font-size: 0.8rem; }
    .dataTables_wrapper .dataTables_paginate { text-align: center !important; margin-top: 8px; }

    /* Modals — full screen on mobile */
    .modal-dialog {
        max-width: 100% !important;
        margin: 0 !important;
        height: 100%;
    }
    .modal-content {
        min-height: 100vh;
        border-radius: 0 !important;
        border: none;
    }
    .modal-header { padding: 10px 14px; }
    .modal-body { padding: 14px; }

    /* Nav tabs — scrollable on mobile */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-item { flex-shrink: 0; }
    .nav-tabs .nav-link { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }

    /* Buttons */
    .btn { font-size: 0.88rem; }
    .btn-sm { padding: 6px 12px; font-size: 0.82rem; }
    .btn-sm-icon { width: 36px; height: 36px; font-size: 0.9rem; }

    /* Forms — prevent iOS zoom */
    .form-control, .form-select { font-size: 16px !important; }
    .form-label { font-size: 0.85rem; }

    /* Login page */
    .login-card {
        padding: 30px 20px;
        border-radius: 18px;
        max-width: calc(100% - 24px);
    }
    .login-logo { width: 100px; }
    .login-title { font-size: 1.25rem; }

    /* Notifications dropdown */
    .notification-dropdown {
        width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
        position: fixed;
        top: 60px;
    }

    /* Alerts */
    .alert-custom {
        min-width: auto !important;
        max-width: calc(100% - 24px) !important;
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
        font-size: 0.88rem;
    }

    /* Page titles */
    .d-flex.justify-content-between.align-items-center { flex-wrap: wrap; gap: 8px; }
    h5.mb-0 { font-size: 1.05rem; }

    /* Sidebar brand compact */
    .sidebar-brand { padding: 18px 15px; }
    .sidebar-brand img { width: 55px; }
    .sidebar-brand h5 { font-size: 0.85rem; }

    /* Form record table */
    .form-record-table th { font-size: 0.72rem; padding: 5px 4px; }
    .form-record-table td { padding: 4px; }
    .form-record-table input,
    .form-record-table select { font-size: 14px !important; padding: 4px 6px; }

    /* Chart containers */
    canvas { max-height: 250px !important; }

    /* Empty state */
    .empty-state { padding: 40px 15px; }
    .empty-state i { font-size: 3rem; }

    /* Signature pad */
    .signature-pad-container { padding: 6px; }
    .signature-pad-container canvas { max-width: 100%; height: auto; }

    /* Library cards */
    .library-card { padding: 14px; }
    .library-card .library-icon { width: 40px; height: 40px; font-size: 1.2rem; }
}

/* ======= MOBILE BOTTOM NAVIGATION ======= */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    box-shadow: 0 -2px 15px rgba(0,0,0,0.08);
    border-top: 1px solid var(--border-color);
    z-index: 1001;
}
.mobile-bottom-nav .nav-items {
    display: flex;
    width: 100%;
    height: 100%;
}
.mobile-bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #999;
    font-size: 0.62rem;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.mobile-bottom-nav .nav-item i { font-size: 1.15rem; margin-bottom: 2px; }
.mobile-bottom-nav .nav-item.active { color: var(--primary); font-weight: 700; }
.mobile-bottom-nav .nav-item:active { color: var(--primary); }
.mobile-bottom-nav .nav-item .mob-badge {
    position: absolute;
    top: 6px;
    right: 50%;
    transform: translateX(16px);
    font-size: 0.5rem;
    padding: 1px 5px;
    border-radius: 10px;
    background: var(--danger);
    color: #fff;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

@media (max-width: 575.98px) {
    .mobile-bottom-nav { display: block; }
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .btn-sm-icon { width: 38px; height: 38px; }
    .sidebar-menu a { padding: 13px 15px; min-height: 44px; }
    .autocomplete-item { padding: 11px 14px; }
    .list-group-item { padding: 12px 16px; }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    .main-content { padding-bottom: 70px; }
    .stat-card { padding: 10px; }
    .stat-card .stat-value { font-size: 1.2rem; }
    .modal-content { min-height: auto; }
}

/* ======= EMPTY STATE ======= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 4rem; margin-bottom: 15px; opacity: 0.3; }
.empty-state h5 { font-weight: 600; color: var(--text-dark); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* ======= AUTOCOMPLETE ======= */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.autocomplete-item:hover { background: var(--body-bg); }
.autocomplete-item.selected { background: rgba(13,106,78,0.08); color: var(--primary); }
