/* ======================================
   نظام إدارة مختبر الأنسجة المرضية
   Advanced Dental Clinic Management System
   ====================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #2196F3;
    --primary-dark: #1565C0;
    --primary-light: #64B5F6;
    --primary-gradient: linear-gradient(135deg, #2196F3, #42A5F5);
    --sidebar-bg: #EBF5FB;
    --sidebar-hover: #D6EAF8;
    --sidebar-active: #2196F3;
    --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;
    --sidebar-collapsed-width: 70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-dark);
    direction: rtl;
    min-height: 100vh;
    font-size: 14px;
    overflow-x: hidden;
}

::-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(-45deg, #0D47A1, #2196F3, #42A5F5, #1565C0);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(33,150,243,0.15) 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(33,150,243,0.1) 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.15);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(33,150,243,0.2);
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #2196F3, #42A5F5, transparent);
    animation: borderAnim 3s linear infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes borderAnim {
    0% { left: -100%; }
    100% { left: 100%; }
}

.login-title { color: var(--primary-dark); font-weight: 800; font-size: 1.7rem; margin-bottom: 5px; }
.login-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 30px; }
.login-card .form-label { font-weight: 600; color: var(--text-dark); 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(33,150,243,0.15); }
.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);
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(33,150,243,0.4); 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);
}
.login-footer a { color: var(--primary-dark); font-weight: 700; text-decoration: none; }

/* ======= SIDEBAR ======= */
.sidebar {
    position: fixed; top: 0; right: 0; width: 260px; height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000; transition: width 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    box-shadow: -5px 0 20px rgba(0,0,0,0.08);
    border-left: 1px solid #B3D9F2;
}

.sidebar-brand { padding: 25px 20px; text-align: center; border-bottom: 1px solid #B3D9F2; position: relative; }
.sidebar-brand img { width: 70px; height: auto; margin-bottom: 10px; max-width: 60px; max-height: 60px; border-radius: 12px; display: block; margin: 0 auto 8px; object-fit: contain; }
.sidebar-brand h5 { color: var(--primary); font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.sidebar-brand small { color: #5B8FA8; font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase; }

.sidebar-section { padding: 15px 15px 5px; color: #5B8FA8; 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: #2C4A5C;
    text-decoration: none; border-radius: var(--radius-sm);
    transition: var(--transition); font-size: 1rem; font-weight: 500;
}
.sidebar-menu a:hover { background: var(--sidebar-hover); color: var(--primary-dark); }

.sidebar-menu a.active {
    background: linear-gradient(135deg, rgba(33,150,243,0.25), rgba(33,150,243,0.1));
    color: var(--primary-dark); 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; }

/* ======= 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;
    transition: right 0.3s ease;
}

.navbar-search { position: relative; width: 350px; }
.navbar-search input {
    width: 100%; border: 2px solid var(--border-color); border-radius: 25px;
    padding: 8px 20px 8px 45px; font-family: 'IBM Plex Sans Arabic'; font-size: 0.9rem;
    transition: var(--transition); background: var(--body-bg);
}
.navbar-search input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(33,150,243,0.1); }

.navbar-search .search-btn {
    position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
    background: var(--primary-gradient); border: none;
    width: 34px; height: 34px; border-radius: 50%;
    color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}

.navbar-actions { display: flex; align-items: center; gap: 15px; }

.navbar-actions .nav-icon {
    width: 40px; height: 40px; border-radius: 50%; background: var(--body-bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: pointer; transition: var(--transition);
    position: relative; border: none; text-decoration: none;
}
.navbar-actions .nav-icon:hover { background: var(--primary); color: #fff; }
.navbar-actions .nav-icon .badge { position: absolute; top: -2px; right: -2px; font-size: 0.6rem; padding: 2px 5px; }

.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-gradient);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.9rem; cursor: pointer;
}

/* ======= MAIN CONTENT ======= */
.main-content { margin-right: 260px; margin-top: 65px; padding: 25px; min-height: calc(100vh - 65px); transition: margin-right 0.3s ease; }

/* ======= WELCOME BANNER ======= */
.welcome-banner {
    background: linear-gradient(135deg, #0D47A1 0%, #1565C0 50%, #1E88E5 100%);
    border-radius: var(--radius); padding: 30px; color: #fff;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; position: relative; overflow: hidden;
}
.welcome-banner::after {
    content: ''; position: absolute; left: -50px; top: -50px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%); border-radius: 50%;
}
.welcome-text h3 { font-size: 1.5rem; font-weight: 700; margin-bottom: 5px; }
.welcome-text p { opacity: 0.7; font-size: 0.9rem; margin: 0; }

/* ======= STAT CARDS ======= */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 25px; }

.stat-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 24px 22px; box-shadow: var(--shadow);
    border: 1px solid var(--border-color); transition: var(--transition);
    position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; margin-bottom: 10px;
}

.stat-card .stat-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.stat-card .stat-value, .stat-card .stat-number { font-size: 1.8rem; font-weight: 800; color: var(--text-dark); margin: 5px 0; }
.stat-card .stat-detail { font-size: 0.8rem; font-weight: 500; }
.stat-card .stat-detail.text-success { color: var(--success) !important; }
.stat-card .stat-detail.text-primary { color: var(--primary) !important; }

/* ======= CARDS GENERAL ======= */
.content-card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border-color); margin-bottom: 25px;
}
.content-card > .table-responsive { padding: 0 8px 8px; }

.content-card .card-header, .content-card .card-header-custom {
    padding: 18px 22px; border-bottom: 1px solid var(--border-color);
    background: transparent; display: flex; align-items: center; justify-content: space-between;
}
.content-card .card-header h5, .content-card .card-header-custom h5 {
    font-weight: 700; font-size: 1.05rem; margin: 0;
    display: flex; align-items: center; gap: 8px;
}
.content-card .card-body { padding: 22px; }

/* ======= DATA TABLE ======= */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    background: var(--body-bg); padding: 14px 18px; font-weight: 700;
    font-size: 0.8rem; color: var(--text-muted);
    border-bottom: 2px solid var(--border-color); white-space: nowrap;
}
.data-table tbody td {
    padding: 14px 18px; border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem; vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(33,150,243,0.04); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ======= BUTTONS ======= */
.btn-gold {
    background: var(--primary-gradient); border: none; color: #fff;
    font-weight: 600; padding: 8px 20px; border-radius: var(--radius-sm);
    transition: var(--transition); display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(33,150,243,0.3); color: #fff; }

.btn-outline-gold {
    border: 2px solid var(--primary); color: var(--primary-dark);
    background: transparent; font-weight: 600; padding: 6px 18px;
    border-radius: var(--radius-sm); transition: var(--transition);
}
.btn-outline-gold:hover { background: var(--primary); color: #fff; }

/* ======= STATUS BADGES ======= */
.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
}
.status-badge.scheduled { background: #fff3cd; color: #856404; }
.status-badge.confirmed { background: #d1ecf1; color: #0c5460; }
.status-badge.waiting { background: #cce5ff; color: #004085; }
.status-badge.in_progress { background: #d4edda; color: #155724; }
.status-badge.completed { background: #e2e3e5; color: #383d41; }
.status-badge.cancelled { background: #f8d7da; color: #721c24; }
.status-badge.no_show { background: #f5c6cb; color: #721c24; }
.status-badge.pending { background: #fff3cd; color: #856404; }
.status-badge.paid { background: #d4edda; color: #155724; }
.status-badge.partial { background: #d1ecf1; color: #0c5460; }
.status-badge.overdue { background: #f8d7da; color: #721c24; }
.status-badge.draft { background: #e2e3e5; color: #383d41; }
.status-badge.active { background: #d4edda; color: #155724; }
.status-badge.inactive { background: #f8d7da; color: #721c24; }

/* ======= FORM STYLES ======= */
.form-group { margin-bottom: 18px; }
.form-group label { font-weight: 600; font-size: 0.88rem; color: var(--text-dark); margin-bottom: 6px; display: block; }
.form-group label .required { color: var(--danger); margin-right: 3px; }

.form-control, .form-select {
    border: 2px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 10px 15px; font-family: 'IBM Plex Sans Arabic'; font-size: 0.9rem; transition: var(--transition);
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(33,150,243,0.1); }

.form-section-title {
    font-weight: 700; font-size: 1rem; color: var(--primary-dark);
    padding-bottom: 10px; margin-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    display: flex; align-items: center; gap: 8px;
}

/* ======= PIPELINE CARDS ======= */
.pipeline-cards { display: flex; flex-wrap: wrap; gap: 12px; padding: 20px; }
.pipeline-cards .pipeline-card {
    flex: 1; min-width: 130px; text-align: center;
    padding: 18px 12px; border-radius: var(--radius-sm);
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-right: 3px solid var(--primary); text-decoration: none;
    color: var(--text-dark); transition: var(--transition);
}
.pipeline-cards .pipeline-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.pipeline-cards .pipeline-icon { font-size: 1.3rem; margin-bottom: 6px; }
.pipeline-cards .pipeline-count { font-size: 1.4rem; font-weight: 800; }
.pipeline-cards .pipeline-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ======= MODAL STYLES ======= */
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 18px 22px; }
.modal-header .modal-title { font-weight: 700; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 15px 22px; }

/* ======= NOTIFICATION DROPDOWN ======= */
.notification-dropdown {
    position: absolute; top: 50px; left: 0; width: 350px;
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
    z-index: 1001; display: none;
}
.notification-dropdown.show { display: block; }
.notification-dropdown .n-header { padding: 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.notification-dropdown .n-item { padding: 12px 15px; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: var(--transition); }
.notification-dropdown .n-item:hover { background: var(--body-bg); }
.notification-dropdown .n-item.unread { background: rgba(33,150,243,0.05); border-right: 3px solid var(--primary); }

/* ======= CHART CONTAINER ======= */
.chart-container { position: relative; width: 100%; height: 300px; }

/* ======= INFO BOXES ======= */
.info-box {
    display: flex; align-items: center; gap: 15px; padding: 15px;
    background: var(--body-bg); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.info-box .info-icon {
    width: 45px; height: 45px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0;
}
.info-box .info-label { font-size: 0.78rem; color: var(--text-muted); }
.info-box .info-value { font-weight: 700; font-size: 1rem; }

/* ======= SETTINGS TABS ======= */
.settings-tabs {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color); padding-bottom: 12px;
}
.settings-tabs .tab-btn {
    padding: 8px 20px; border: 2px solid var(--border-color); border-radius: 25px;
    background: transparent; color: var(--text-muted); font-family: 'IBM Plex Sans Arabic';
    font-weight: 600; font-size: 0.85rem; cursor: pointer;
    transition: var(--transition); display: flex; align-items: center; gap: 6px;
}
.settings-tabs .tab-btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.settings-tabs .tab-btn.active { background: var(--primary-gradient); border-color: var(--primary); color: #fff; }

.tab-content-section { display: none; }
.tab-content-section.active { display: block; }

/* ======= PAGE ACTION BAR ======= */
.page-action-bar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-action-bar .page-title { font-weight: 700; font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.page-action-bar .page-title i { color: var(--primary); }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-bar .form-control, .filter-bar .form-select { max-width: 220px; padding: 8px 14px; font-size: 0.85rem; }

/* ======= PAGINATION ======= */
.pagination-custom .page-link {
    border: 1px solid var(--border-color); color: var(--text-dark);
    padding: 8px 14px; font-weight: 500; border-radius: var(--radius-sm) !important; margin: 0 3px;
}
.pagination-custom .page-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-custom .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ======= EMPTY STATE ======= */
.empty-state { text-align: center; padding: 50px 20px; }
.empty-state i { font-size: 4rem; color: var(--border-color); margin-bottom: 15px; }
.empty-state h5 { color: var(--text-muted); font-weight: 600; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* ======= ALERTS ======= */
.alert-custom { border-radius: var(--radius-sm); border: none; padding: 14px 20px; font-weight: 500; }

/* ======= SEARCH DROPDOWN ======= */
.search-results-dropdown {
    position: absolute; top: 100%; right: 0; left: 0;
    background: var(--card-bg); border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
    border-top: none; z-index: 1001; max-height: 400px; overflow-y: auto; display: none;
}
.search-results-dropdown.show { display: block; }
.search-results-dropdown .search-item {
    padding: 10px 15px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border-color); text-decoration: none;
    color: var(--text-dark); transition: var(--transition);
}
.search-results-dropdown .search-item:hover { background: var(--body-bg); }

/* ======= LOADING ======= */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.85); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.spinner-gold { width: 50px; height: 50px; border: 4px solid var(--border-color); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ======= BADGE ======= */
.badge-gold { background: var(--primary-gradient); color: #fff; }

/* ======= ANIMATION ======= */
.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ======= TEETH CHART ======= */
.teeth-grid {
    display: flex; justify-content: center; gap: 4px; flex-wrap: wrap;
    padding: 20px; direction: ltr;
}
.teeth-grid.upper { margin-bottom: 30px; }
.teeth-grid.lower { margin-top: 30px; }

.tooth-item {
    width: 52px; height: 60px; border: 2px solid #ddd; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition); position: relative; font-size: 0.75rem;
}
.tooth-item:hover { transform: scale(1.1); box-shadow: var(--shadow); z-index: 2; }
.tooth-item .tooth-number { font-weight: 700; font-size: 0.85rem; }
.tooth-item .tooth-icon { font-size: 1.2rem; margin-top: 2px; }
.tooth-item.healthy { background: #D4EDDA; border-color: #28A745; }
.tooth-item.cavity { background: #FFF3CD; border-color: #FFC107; }
.tooth-item.filled { background: #CCE5FF; border-color: #007BFF; }
.tooth-item.crown { background: #E2E3E5; border-color: #6C757D; }
.tooth-item.bridge { background: #F8D7DA; border-color: #DC3545; }
.tooth-item.implant { background: #D1ECF1; border-color: #17A2B8; }
.tooth-item.extracted { background: #F8D7DA; border-color: #721C24; color: #721C24; }
.tooth-item.root_canal { background: #E6E6FA; border-color: #9370DB; }
.tooth-item.broken { background: #FFEBEE; border-color: #F44336; }
.tooth-item.veneer { background: #E8F5E9; border-color: #4CAF50; }
.tooth-item.sealant { background: #FFF8E1; border-color: #FF8F00; }
.tooth-item.missing { background: #ECEFF1; border-color: #455A64; color: #455A64; }

.teeth-divider {
    width: 2px; background: var(--primary); margin: 0 8px; border-radius: 2px; min-height: 60px;
}

.teeth-row-label {
    text-align: center; font-weight: 700; font-size: 0.9rem; color: var(--primary-dark);
    padding: 8px 0; margin-bottom: 5px;
}

.teeth-legend {
    display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
    padding: 15px; background: var(--body-bg); border-radius: var(--radius-sm); margin-top: 20px;
}
.teeth-legend .legend-item {
    display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 500;
}
.teeth-legend .legend-color {
    width: 18px; height: 18px; border-radius: 4px; border: 2px solid;
}

/* ======= CALENDAR ======= */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-header { background: var(--primary); color: #fff; padding: 10px; text-align: center; font-weight: 700; font-size: 0.85rem; }
.calendar-day { min-height: 100px; padding: 8px; border: 1px solid var(--border-color); background: #fff; position: relative; }
.calendar-day.today { background: rgba(33,150,243,0.08); border-color: var(--primary); }
.calendar-day.other-month { background: #f8f9fa; color: #ccc; }
.calendar-day .day-number { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.calendar-day .booking-dot {
    display: block; padding: 2px 6px; border-radius: 4px;
    font-size: 0.7rem; margin-bottom: 2px; color: #fff;
    cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ======= REPORT SUMMARY ======= */
.report-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.report-summary .summary-item { background: var(--body-bg); border-radius: var(--radius-sm); padding: 15px; text-align: center; }
.report-summary .summary-item .value { font-size: 1.5rem; font-weight: 800; color: var(--primary-dark); }
.report-summary .summary-item .label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

/* ======= ROLE BADGES ======= */
.role-badge { padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.role-badge.admin { background: linear-gradient(135deg, #dc3545, #e74c5e); color: #fff; }
.role-badge.dentist { background: linear-gradient(135deg, #2196F3, #42A5F5); color: #fff; }
.role-badge.receptionist { background: linear-gradient(135deg, #17a2b8, #20c997); color: #fff; }
.role-badge.assistant { background: linear-gradient(135deg, #6c757d, #adb5bd); color: #fff; }

/* ======= INVOICE PRINT ======= */
.invoice-container { max-width: 800px; margin: 0 auto; background: #fff; padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow); }
.invoice-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 30px; padding-bottom: 20px; border-bottom: 3px solid var(--primary);
}
.invoice-logo { font-size: 1.5rem; font-weight: 800; color: var(--primary-dark); }
.invoice-info { text-align: left; }
.invoice-info h4 { color: var(--primary-dark); font-weight: 800; }
.invoice-details { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.invoice-table th { background: var(--primary); color: #fff; padding: 12px 15px; font-weight: 600; }
.invoice-table td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); }
.invoice-table tfoot td { font-weight: 700; border-top: 2px solid var(--primary); }
.invoice-footer { text-align: center; padding-top: 20px; border-top: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.85rem; }

/* ======= WAITING ROOM ======= */
.waiting-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 20px; border: 1px solid var(--border-color);
    transition: var(--transition); text-align: center;
}
.waiting-card.current { border: 2px solid var(--success); background: #d4edda; }
.waiting-card .queue-number {
    font-size: 2.5rem; font-weight: 800; color: var(--primary);
    width: 70px; height: 70px; border-radius: 50%;
    background: var(--body-bg); display: flex; align-items: center; justify-content: center;
    margin: 0 auto 10px;
}

/* ======= PRESCRIPTION ======= */
.rx-symbol { font-size: 2.5rem; font-weight: 800; color: var(--primary); font-family: serif; }
.prescription-item {
    background: var(--body-bg); border-radius: var(--radius-sm);
    padding: 15px; margin-bottom: 10px;
    border-right: 3px solid var(--primary);
}

/* ======= PATIENT CARD ======= */
.patient-avatar {
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--primary-gradient); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
}
.patient-avatar.sm { width: 35px; height: 35px; font-size: 0.85rem; }
.patient-avatar.lg { width: 80px; height: 80px; font-size: 2rem; }

/* ======= FORM SWITCH ======= */
.form-switch-custom { display: flex; align-items: center; gap: 10px; }
.form-switch-custom .form-check-input { width: 42px; height: 22px; cursor: pointer; }
.form-switch-custom .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ======= RESPONSIVE ======= */
.sidebar-toggle {
    display: none; background: var(--primary-gradient); border: none;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    color: #fff; font-size: 1.2rem; cursor: pointer;
    align-items: center; justify-content: center;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }

@media (max-width: 992px) {
    html, body { overflow-x: hidden; }
    .sidebar { transform: translateX(100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .sidebar-toggle { display: flex; }
    .main-content { margin-right: 0; }
    .top-navbar { right: 0; }
    .navbar-search { width: 200px; }
    .welcome-banner { flex-direction: column; text-align: center; gap: 15px; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .modal-dialog.modal-lg { max-width: 90%; }
}

@media (max-width: 768px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .navbar-search { width: 160px; }
    .navbar-search input { font-size: 0.8rem; padding: 6px 10px; }
    .main-content { padding: 15px; }
    .content-card { border-radius: var(--radius-sm); }
    .modal .row > [class*="col-md"] { flex: 0 0 100%; max-width: 100%; }
    .btn { font-size: 0.85rem; padding: 6px 12px; }
    .btn-group-sm > .btn { padding: 4px 8px; }
    .teeth-row { gap: 2px; }
    .tooth-visual { width: 38px; padding: 2px; }
    .tooth-svg { width: 32px; height: 48px; }
    .tooth-num { font-size: 0.6rem; }
    .quadrant-label { font-size: 0.6rem; }
    .jaw-midline { margin: 0 4px; }
    .teeth-legend { gap: 6px; }
    .legend-item { font-size: 0.7rem; padding: 2px 5px; }
    .data-table { font-size: 0.82rem; }
    .data-table thead th, .data-table tbody td { padding: 8px 10px; white-space: nowrap; }
    .card-header-custom { flex-direction: column; gap: 8px; }
    .card-header-custom h5 { font-size: 1rem; }
}

@media (max-width: 576px) {
    .stat-cards { grid-template-columns: 1fr; }
    .navbar-search { display: none; }
    .top-navbar { padding: 0 10px; }
    .main-content { padding: 10px; padding-top: 70px; }
    .login-card { margin: 15px; padding: 30px 25px; }
    .data-table { font-size: 0.78rem; }
    .data-table thead th, .data-table tbody td { padding: 6px 8px; }
    .calendar-day { min-height: 60px; padding: 4px; }
    .teeth-row { gap: 1px; }
    .tooth-visual { width: 30px; padding: 1px; }
    .tooth-svg { width: 26px; height: 40px; }
    .tooth-num { font-size: 0.55rem; }
    .jaw-midline { width: 2px; margin: 0 2px; }
    .quadrant-label { display: none; }
    .modal-dialog { margin: 8px; }
    .surface-diagram { grid-template-columns: 28px 28px 28px; grid-template-rows: 28px 28px 28px; }
    .condition-option { padding: 4px !important; }
    .condition-option small { font-size: 0.62rem !important; }
    h4 { font-size: 1.1rem; }
    /* Mobile search button */
    .mobile-search-btn { display: flex !important; }
}

/* ======= TEETH CHART SVG ======= */
.dental-chart-container { max-width: 100%; }
.jaw-row { display: flex; justify-content: center; align-items: stretch; gap: 0; }
.quadrant-group { flex: 1; }
.quadrant-label { text-align: center; font-size: 0.72rem; font-weight: 600; color: var(--primary); margin: 4px 0; }
.teeth-row { display: flex; justify-content: center; gap: 4px; flex-wrap: nowrap; }
.jaw-midline { width: 3px; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); border-radius: 2px; margin: 0 8px; flex-shrink: 0; }
.jaw-separator { position: relative; display: flex; align-items: center; justify-content: center; margin: 12px 0; }
.jaw-line { flex:1; height: 2px; background: linear-gradient(90deg, transparent, var(--primary), transparent); }
.jaw-label-left, .jaw-label-right { position: absolute; font-size: 0.7rem; color: var(--primary); font-weight: 600; }
.jaw-label-left { left: 15%; }
.jaw-label-right { right: 15%; }

.tooth-visual { display: flex; flex-direction: column; align-items: center; width: 52px; cursor: pointer; position: relative; padding: 3px; border-radius: 8px; transition: all 0.2s; }
.tooth-visual:hover { transform: scale(1.15); z-index: 10; box-shadow: 0 4px 16px rgba(33,150,243,0.25); background: rgba(33,150,243,0.06); }
.tooth-visual.lower { flex-direction: column-reverse; }
.tooth-svg { width: 42px; height: 62px; }
.tooth-num { font-size: 0.7rem; font-weight: 700; color: #333; text-align: center; line-height: 1; margin: 2px 0; }
.tooth-tx-indicator { position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.5rem; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.teeth-legend { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; cursor: pointer; padding: 3px 8px; border-radius: 20px; transition: background 0.2s; }
.legend-item:hover { background: rgba(0,0,0,0.04); }
.legend-color { width: 14px; height: 14px; border-radius: 4px; border: 2px solid; flex-shrink: 0; }

.surface-selector { display: flex; align-items: center; gap: 15px; }
.surface-diagram { display: grid; grid-template-areas: ". M ." "L O B" ". D ."; grid-template-columns: 32px 32px 32px; grid-template-rows: 32px 32px 32px; gap: 2px; }
.surface-box { display: flex; align-items: center; justify-content: center; border: 2px solid #ccc; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 0.72rem; color: #666; transition: all 0.2s; user-select: none; }
.surface-M { grid-area: M; }
.surface-D { grid-area: D; }
.surface-O { grid-area: O; }
.surface-B { grid-area: B; }
.surface-L { grid-area: L; }
.surface-box:hover { border-color: var(--primary); color: var(--primary); }
.surface-box.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.condition-option:hover { background: rgba(33,150,243,0.05) !important; }

/* ======= PRINT ======= */
@media print {
    .sidebar, .top-navbar, .sidebar-toggle, .no-print, .sidebar-overlay { display: none !important; }
    .main-content { margin: 0 !important; padding: 15px !important; }
    body { background: #fff !important; }
    .content-card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .stat-card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .btn, button:not(.print-show) { display: none !important; }
    a { text-decoration: none !important; color: #333 !important; }
    .print-only { display: block !important; }
}
.print-only { display: none; }

/* ── Sidebar Collapse Button ── */
.sidebar-collapse-btn {
    position: absolute;
    left: 10px;
    top: 18px;
    background: rgba(0,0,0,0.05);
    border: none;
    color: rgba(0,0,0,0.4);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
    font-size: 12px;
}
.sidebar-collapse-btn:hover { background: rgba(0,0,0,0.1); color: var(--primary); }

@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
    body.sidebar-collapsed .main-content { margin-right: var(--sidebar-collapsed-width); }
    body.sidebar-collapsed .top-navbar { right: var(--sidebar-collapsed-width); }
    body.sidebar-collapsed .sidebar .sidebar-brand span,
    body.sidebar-collapsed .sidebar .sidebar-brand h5,
    body.sidebar-collapsed .sidebar .sidebar-brand small,
    body.sidebar-collapsed .sidebar .sidebar-brand-text,
    body.sidebar-collapsed .sidebar .sidebar-section,
    body.sidebar-collapsed .sidebar p.sidebar-section,
    body.sidebar-collapsed .sidebar .sidebar-menu a span,
    body.sidebar-collapsed .sidebar .sidebar-menu a .badge,
    body.sidebar-collapsed .sidebar .sidebar-menu .badge { display: none; }
    body.sidebar-collapsed .sidebar .sidebar-brand { padding: 15px 10px; }
    body.sidebar-collapsed .sidebar .sidebar-brand img { width: 40px; height: 40px; }
    body.sidebar-collapsed .sidebar .sidebar-brand i { font-size: 22px; }
    body.sidebar-collapsed .sidebar .sidebar-menu a { justify-content: center; padding: 12px 0; gap: 0; position: relative; display: flex; }
    body.sidebar-collapsed .sidebar .sidebar-menu a i { font-size: 17px; width: auto; margin: 0; }
    body.sidebar-collapsed .sidebar .sidebar-menu a.active { border-radius: 8px; margin: 2px 8px; }
    body.sidebar-collapsed .sidebar .sidebar-collapse-btn { position: static; margin: 8px auto 0; }
    body.sidebar-collapsed .sidebar .sidebar-menu a:hover::after {
        content: attr(data-title);
        position: absolute;
        right: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,0,0,0.85);
        color: white;
        padding: 5px 12px;
        border-radius: 6px;
        font-size: 12px;
        white-space: nowrap;
        z-index: 9999;
        pointer-events: none;
    }
}
@media (max-width: 991px) {
    .sidebar-collapse-btn { display: none !important; }
}

.topbar-clock {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
    direction: ltr;
}
.topbar-clock .clock-time { font-weight: 700; color: var(--primary); font-size: 14px; }
.topbar-clock .clock-date { font-size: 12px; }
.topbar-shortcuts { display: flex; align-items: center; gap: 3px; }
.topbar-shortcut {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    color: var(--text-muted, #6c757d);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 15px;
}
.topbar-shortcut:hover { background: var(--body-bg, #f0f2f5); color: var(--primary); }
.topbar-divider { width: 1px; height: 28px; background: var(--border-color, #e0e0e0); margin: 0 8px; }

/* Page Transition Loading Bar */
.page-loader { position: fixed; top: 0; right: 0; width: 0; height: 3px; background: linear-gradient(90deg, var(--primary, #1976D2), var(--secondary, #42A5F5)); z-index: 999999; transition: none; pointer-events: none; }
.page-loader.active { animation: pageLoad 1.8s ease-out forwards; }
@keyframes pageLoad { 0% { width: 0; opacity: 1; } 20% { width: 40%; } 50% { width: 70%; } 80% { width: 88%; } 100% { width: 95%; opacity: 1; } }
.page-loader.done { width: 100% !important; opacity: 0; transition: opacity 0.3s ease 0.1s; }
/* Page Transition Loading Bar */
.page-loader { position: fixed; top: 0; right: 0; width: 0; height: 3px; background: linear-gradient(90deg, var(--primary, #1976D2), var(--secondary, #42A5F5)); z-index: 999999; transition: none; pointer-events: none; }
.page-loader.active { animation: pageLoad 1.8s ease-out forwards; }
@keyframes pageLoad { 0% { width: 0; opacity: 1; } 20% { width: 40%; } 50% { width: 70%; } 80% { width: 88%; } 100% { width: 95%; opacity: 1; } }
.page-loader.done { width: 100% !important; opacity: 0; transition: opacity 0.3s ease 0.1s; }