:root {
    --primary: #0ea5e9; /* Light blue / Medical */
    --primary-dark: #0284c7;
    --secondary: #14b8a6; /* Teal */
    --accent: #8b5cf6; /* Purple */
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand i {
    font-size: 24px;
    color: var(--secondary);
}

.sidebar-nav {
    list-style: none;
    margin-top: 24px;
    padding: 0 16px;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.sidebar-nav a:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.sidebar-nav li.active a {
    background-color: #e0f2fe;
    color: var(--primary-dark);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.top-header {
    height: 70px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-light);
    padding: 8px 16px;
    border-radius: 20px;
    width: 300px;
}

.search-bar i {
    color: var(--text-muted);
    margin-right: 8px;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--text-main);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.notification-btn {
    position: relative;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 20px;
}

.notification-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    height: 16px;
    width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.user-profile img {
    height: 40px;
    width: 40px;
    border-radius: 50%;
    object-fit: cover;
}

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

.user-name {
    font-weight: 600;
    font-size: 14px;
}

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

/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.summary-card {
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.card-icon {
    height: 48px;
    width: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.card-icon.blue { background-color: #e0f2fe; color: #0284c7; }
.card-icon.teal { background-color: #ccfbf1; color: #0f766e; }
.card-icon.orange { background-color: #fef3c7; color: #b45309; }
.card-icon.purple { background-color: #f3e8ff; color: #7e22ce; }
.card-icon.green { background-color: #dcfce3; color: #15803d; }
.card-icon.red { background-color: #fee2e2; color: #b91c1c; }
.card-icon.indigo { background-color: #e0e7ff; color: #4338ca; }

.card-info h3 {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.card-info .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.trend {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}
.trend.positive { color: var(--success); }
.trend.negative { color: var(--danger); }

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.chart-card {
    padding: 24px;
}

.chart-card .card-header {
    margin-bottom: 20px;
}

.chart-card .card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* === Patient Module Styles === */

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 14px;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-outline { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background-color: var(--bg-light); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* Data Tables */
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.data-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table td { font-size: 14px; }
.data-table tbody tr:hover { background-color: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Table Actions */
.action-links { display: flex; gap: 12px; }
.action-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: color 0.2s;
}
.action-links a:hover { color: var(--primary-dark); text-decoration: underline; }
.action-links .danger { color: var(--danger); }

/* Badges */
.badge-tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-light);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.badge-tag.warning { background: #fef3c7; color: #b45309; border-color: #fde68a; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
}
.modal-header h2 { font-size: 20px; }
.close-modal {
    background: none; border: none; font-size: 24px;
    color: var(--text-muted); cursor: pointer;
}
.close-modal:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
}

/* Forms */
.form-section-title {
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.form-group.full-width { grid-column: span 2; }
.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}
.form-control {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background-color: var(--bg-light);
}
.form-control:focus {
    border-color: var(--primary);
    background-color: #fff;
}
textarea.form-control { resize: vertical; min-height: 80px; }

/* === Patient Profile Styles === */
.profile-header {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}
.profile-info-main {
    display: flex;
    gap: 24px;
    align-items: center;
}
.profile-avatar {
    height: 80px;
    width: 80px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
}
.profile-details h2 { font-size: 24px; color: var(--text-main); margin-bottom: 4px; }
.profile-details .patient-id { font-size: 14px; color: var(--primary); font-weight: 500; margin-bottom: 8px; }
.profile-meta { display: flex; gap: 16px; color: var(--text-muted); font-size: 14px; }
.profile-meta span { display: flex; align-items: center; gap: 6px; }

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.info-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.info-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.info-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.info-item { display: flex; flex-direction: column; gap: 4px; }
.info-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; }
.info-value { font-size: 14px; color: var(--text-main); font-weight: 500; }

/* === Appointment Status Badges === */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}
.status-pending { background-color: #fef08a; color: #854d0e; }
.status-confirmed { background-color: #bfdbfe; color: #1e40af; }
.status-arrived { background-color: #fbcfe8; color: #be185d; }
.status-waiting { background-color: #fed7aa; color: #c2410c; }
.status-intreatment { background-color: #c7d2fe; color: #3730a3; }
.status-completed { background-color: #bbf7d0; color: #166534; }
.status-cancelled { background-color: #fecaca; color: #991b1b; }
.status-noshow { background-color: #e5e7eb; color: #374151; }

.status-dropdown {
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
}

/* === Dental Chart Styles === */
.dental-chart-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-top: 24px;
}
.dental-chart-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: var(--primary);
    font-size: 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.arch-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}
.tooth {
    width: 40px;
    height: 50px;
    border: 2px solid #cbd5e1;
    border-radius: 6px 6px 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
    position: relative;
}
.arch-lower .tooth {
    border-radius: 12px 12px 6px 6px;
}
.tooth:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-color: var(--primary);
}

/* Tooth Status Colors */
.tooth.status-cavity { background-color: #fee2e2; border-color: #ef4444; color: #991b1b; }
.tooth.status-filling { background-color: #e0f2fe; border-color: #0ea5e9; color: #075985; }
.tooth.status-rootcanal { background-color: #f3e8ff; border-color: #a855f7; color: #6b21a8; }
.tooth.status-crown { background-color: #fef08a; border-color: #eab308; color: #854d0e; }
.tooth.status-missing { background-color: #f1f5f9; border-color: #94a3b8; color: #475569; opacity: 0.6; }
.tooth.status-extracted { background-color: #1e293b; border-color: #0f172a; color: #f8fafc; }
.tooth.status-implant { background-color: #ccfbf1; border-color: #14b8a6; color: #115e59; }
.tooth.status-bridge { background-color: #ffedd5; border-color: #f97316; color: #9a3412; }
.tooth.status-wisdomtooth { background-color: #e0e7ff; border-color: #6366f1; color: #3730a3; }
.tooth.status-fractured { background-color: #fce7f3; border-color: #ec4899; color: #9d174d; }

.arch-label {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 8px;
}

/* History List inside Modal */
.history-list {
    margin-top: 16px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.history-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
.history-item:last-child { border-bottom: none; }
.history-date { font-weight: 600; color: var(--primary); font-size: 12px; }
.history-title { font-weight: 600; color: var(--text-main); margin-top: 4px; }
.history-desc { color: var(--text-muted); margin-top: 4px; }

/* Legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
    justify-content: center;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.legend-box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
}

/* === Billing Styles === */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}
.invoice-items-table th, .invoice-items-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.invoice-items-table th {
    background-color: #f8fafc;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.invoice-summary {
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}
.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
    margin-top: 8px;
}
.remove-item-btn {
    color: #ef4444;
    background: transparent;
    border: none;
    cursor: pointer;
}
.remove-item-btn:hover { color: #b91c1c; }
.status-paid { background-color: #bbf7d0; color: #166534; }
.status-partial { background-color: #fef08a; color: #854d0e; }
.status-unpaid { background-color: #fecaca; color: #991b1b; }

/* === Inventory Styles === */
.alert-lowstock { background-color: #fee2e2; color: #991b1b; }
.alert-expired { background-color: #1e293b; color: #f8fafc; }
.alert-nearexpiry { background-color: #ffedd5; color: #9a3412; }
.alert-good { background-color: #bbf7d0; color: #166534; }

/* === Timeline Styles === */
.timeline-container {
    position: relative;
    padding-left: 30px;
    margin-top: 20px;
}
.timeline-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}
.timeline-item {
    position: relative;
    margin-bottom: 24px;
}
.timeline-item::before {
    content: '\\f00c'; /* checkmark */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: -38px;
    top: 4px;
    width: 18px;
    height: 18px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 3px solid white;
}
.timeline-date {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}
.timeline-content {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.timeline-title {
    font-weight: 600;
    color: var(--text-main);
}
.timeline-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === Attachment Styles === */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.attachment-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: white;
}
.attachment-preview {
    height: 120px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.attachment-preview i {
    font-size: 40px;
    color: #94a3b8;
}
.attachment-info {
    padding: 8px;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}
.attachment-info .type-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    margin-bottom: 4px;
    font-weight: 600;
}

/* === Dashboard Styles === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}
.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-right: 16px;
}
.stat-icon.revenue { background: #dcfce7; color: #16a34a; }
.stat-icon.patients { background: #dbeafe; color: #2563eb; }
.stat-icon.procedures { background: #f3e8ff; color: #9333ea; }
.stat-icon.balance { background: #fee2e2; color: #dc2626; }

.stat-details h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}
.stat-details .stat-value {
    margin: 4px 0 0 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}
.dashboard-row {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}
.dashboard-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    flex: 1;
}
.panel-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
}
.list-group-item:last-child {
    border-bottom: none;
}
.status-for-hmo-claim { background-color: #fef08a; color: #854d0e; border: 1px solid #fde047; }
