/* ============================================================
   main.css - ClinicFlow Smart Clinic Management System
   Medical Theme: Blue & Green Palette
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --secondary: #00897b;
    --secondary-dark: #00695c;
    --secondary-light: #e0f2f1;
    --accent: #34a853;
    --danger: #ea4335;
    --warning: #fbbc04;
    --info: #4fc3f7;

    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow: 0 4px 6px rgba(0, 0, 0, .07), 0 2px 4px rgba(0, 0, 0, .05);
    --shadow-md: 0 10px 15px rgba(0, 0, 0, .1), 0 4px 6px rgba(0, 0, 0, .05);
    --shadow-lg: 0 20px 25px rgba(0, 0, 0, .1), 0 10px 10px rgba(0, 0, 0, .04);
    --transition: all .2s ease;
}

/* ── Page Loader ── */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.loader-logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(26, 115, 232, 0.2);
    animation: loader-pulse 2s infinite ease-in-out;
}

.loader-logo svg {
    width: 30px;
    height: 30px;
    stroke: white;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(26, 115, 232, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: loader-spin 1s linear infinite;
}

.loader-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.loader-text span {
    color: var(--primary);
}

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

@keyframes loader-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

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

button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a73e8 0%, #00897b 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: rgba(255, 255, 255, .05);
    border-radius: 50%;
    top: -200px;
    right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, .05);
    border-radius: 50%;
    bottom: -150px;
    left: -100px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 48px 40px;
    position: relative;
    z-index: 1;
    animation: slideUp .4s ease;
}

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

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: 0 8px 20px rgba(26, 115, 232, .3);
}

.login-logo .logo-icon svg {
    width: 32px;
    height: 32px;
    fill: #fff;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
    transition: var(--transition);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.input-icon {
    position: relative;
}

.input-icon .form-control {
    padding-left: 42px;
}

.input-icon .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #1557b0);
    color: #fff;
    box-shadow: 0 4px 12px rgba(26, 115, 232, .3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(26, 115, 232, .4);
}

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

.btn-secondary {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 137, 123, .3);
}

.btn-secondary:hover {
    background: var(--secondary-dark);
    transform: translateY(-1px);
}

.btn-outline {
    border-color: var(--border);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

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

.btn-danger:hover {
    background: #c62828;
    transform: translateY(-1px);
}

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

.btn-success:hover {
    background: #2e7d32;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none !important;
}

.login-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: 4px 0;
    position: relative;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: none;
    animation: shake .3s ease;
}

.error-message.show {
    display: block;
}

.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--accent);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: none;
}

.success-message.show {
    display: block;
}

/* ============================================================
   APP LAYOUT (Sidebar + Main)
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

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

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.brand-text h2 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.brand-text span {
    font-size: 11px;
    color: rgba(255, 255, 255, .4);
}

.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.role-badge.admin {
    background: rgba(26, 115, 232, .3);
    color: #93c5fd;
}

.role-badge.doctor {
    background: rgba(0, 137, 123, .3);
    color: #6ee7b7;
}

.role-badge.receptionist {
    background: rgba(251, 188, 4, .3);
    color: #fde68a;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, .3);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 8px 4px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .6);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(26, 115, 232, .3), rgba(0, 137, 123, .2));
    color: #fff;
    border-left: 3px solid var(--primary);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .6);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(234, 67, 53, .15);
    color: #fca5a5;
}

.btn-logout svg {
    width: 18px;
    height: 18px;
}

/* ── Top Bar ── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    background: var(--danger);
    color: #fff;
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-area {
    flex: 1;
    padding: 24px;
}

/* ── Hamburger ── */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ============================================================
   CARDS & STAT WIDGETS
   ============================================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--surface2);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

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

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: .06;
    transform: translate(30px, -30px);
}

.stat-card.blue {
    border-top: 3px solid var(--primary);
}

.stat-card.blue .stat-icon {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-card.blue::after {
    background: var(--primary);
}

.stat-card.green {
    border-top: 3px solid var(--secondary);
}

.stat-card.green .stat-icon {
    background: var(--secondary-light);
    color: var(--secondary);
}

.stat-card.green::after {
    background: var(--secondary);
}

.stat-card.purple {
    border-top: 3px solid #8b5cf6;
}

.stat-card.purple .stat-icon {
    background: #ede9fe;
    color: #8b5cf6;
}

.stat-card.purple::after {
    background: #8b5cf6;
}

.stat-card.orange {
    border-top: 3px solid #f59e0b;
}

.stat-card.orange .stat-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.stat-card.orange::after {
    background: #f59e0b;
}

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

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-body {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stat-change {
    font-size: 11px;
    color: var(--accent);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
    overflow-x: auto;
}

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

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--surface2);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-primary);
    vertical-align: middle;
}

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

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--surface2);
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: block;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-pending::before {
    background: #f59e0b;
}

.status-confirmed {
    background: #dbeafe;
    color: #1e40af;
}

.status-confirmed::before {
    background: var(--primary);
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-completed::before {
    background: var(--accent);
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.status-cancelled::before {
    background: var(--danger);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(.95) translateY(10px);
    transition: var(--transition);
}

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

.modal.modal-lg {
    max-width: 720px;
}

.modal.modal-xl {
    max-width: 900px;
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    cursor: pointer;
}

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

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 12px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row.three {
    grid-template-columns: 1fr 1fr 1fr;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.form-control {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--surface);
    transition: var(--transition);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .12);
}

.form-control:invalid:not(:placeholder-shown) {
    border-color: var(--danger);
}

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

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    flex: 1;
    min-width: 200px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .1);
}

.search-box svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    outline: none;
    background: none;
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    padding: 9px 32px 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--surface);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    padding: 0 0 24px 20px;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .15);
}

.timeline-dot.green {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(0, 137, 123, .15);
}

.timeline-dot.orange {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
}

.timeline-content {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
}

.timeline-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================================================
   MEDICINE LIST (Prescription)
   ============================================================ */
.medicine-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 8px;
    transition: var(--transition);
    animation: slideUp .2s ease;
}

.medicine-row:hover {
    border-color: var(--border);
}

.medicine-row .btn-remove {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    background: #fee2e2;
    transition: var(--transition);
}

.medicine-row .btn-remove:hover {
    background: var(--danger);
    color: #fff;
}

/* ============================================================
   PATIENT PROFILE
   ============================================================ */
.profile-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-lg);
    padding: 28px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.profile-header::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, .08);
    border-radius: 50%;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    border: 3px solid rgba(255, 255, 255, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-info h2 {
    font-size: 22px;
    font-weight: 700;
}

.profile-info p {
    opacity: .8;
    font-size: 13px;
    margin-top: 4px;
}

.profile-meta {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.profile-meta-item {
    font-size: 12px;
    opacity: .8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.info-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.info-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* ============================================================
   LOADING & SPINNERS
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.spinner-sm {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.loading-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    background: var(--surface2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.empty-state .empty-icon svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

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

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1e293b;
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    min-width: 260px;
    max-width: 380px;
    pointer-events: auto;
    animation: slideInRight .3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success {
    border-left-color: var(--accent);
}

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

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

.toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-left h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.page-header-left p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================================
   PRESCRIPTION CARD
   ============================================================ */
.prescription-card {
    border-left: 4px solid var(--secondary);
}

.prescription-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.prescription-meta span {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.medicine-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin: 2px;
}

/* ============================================================
   QUICK ACTIONS
   ============================================================ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.quick-action-btn .qa-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-action-btn .qa-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-6px)
    }

    75% {
        transform: translateX(6px)
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 220px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

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

    .hamburger {
        display: flex;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 99;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row.three {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .medicine-row {
        grid-template-columns: 1fr 1fr;
    }

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

    .content-area {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 28px 20px;
    }

    .modal {
        margin: 0;
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-primary {
    color: var(--primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-success {
    color: var(--accent) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.fw-600 {
    font-weight: 600 !important;
}

.fs-12 {
    font-size: 12px !important;
}

.fs-13 {
    font-size: 13px !important;
}

.fs-16 {
    font-size: 16px !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-8 {
    margin-bottom: 8px !important;
}

.mb-12 {
    margin-bottom: 12px !important;
}

.mb-16 {
    margin-bottom: 16px !important;
}

.mb-24 {
    margin-bottom: 24px !important;
}

.mt-8 {
    margin-top: 8px !important;
}

.mt-16 {
    margin-top: 16px !important;
}

.mt-24 {
    margin-top: 24px !important;
}

.p-0 {
    padding: 0 !important;
}

.flex {
    display: flex !important;
}

.flex-center {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.gap-8 {
    gap: 8px !important;
}

.gap-12 {
    gap: 12px !important;
}

.gap-16 {
    gap: 16px !important;
}

.w-100 {
    width: 100% !important;
}

.hidden {
    display: none !important;
}

/* ============================================================
   SKELETON SCREENS (replace spinners with content shapes)
   ============================================================ */
@keyframes shimmer {
    0% {
        background-position: -600px 0;
    }

    100% {
        background-position: 600px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            var(--surface2) 25%,
            #e2e8f0 50%,
            var(--surface2) 75%);
    background-size: 600px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}

/* Row skeletons for tables */
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
}

.skeleton-row:last-child {
    border-bottom: none;
}

.skeleton-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-line {
    height: 13px;
    border-radius: 6px;
}

.skeleton-badge {
    height: 22px;
    border-radius: 20px;
}

/* Stat card skeleton */
.skeleton-stat {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.skeleton-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    flex-shrink: 0;
}

.skeleton-stat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Card skeleton */
.skeleton-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    overflow: hidden;
    padding: 20px;
}

/* Convenience sizes */
.sk-w-20 {
    width: 20%;
}

.sk-w-30 {
    width: 30%;
}

.sk-w-40 {
    width: 40%;
}

.sk-w-50 {
    width: 50%;
}

.sk-w-60 {
    width: 60%;
}

.sk-w-70 {
    width: 70%;
}

.sk-w-80 {
    width: 80%;
}

.sk-w-100 {
    width: 100%;
}

/* ── Page-fade on load ── */
.page-ready {
    animation: pageFade .2s ease;
}

@keyframes pageFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Instant stat counter shimmer (shows value box before data) ── */
.stat-value.loading {
    min-width: 48px;
    min-height: 28px;
    border-radius: 6px;
}

/* ── Refresh Button ── */
.btn-refresh {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
    flex-shrink: 0;
}

.btn-refresh:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-refresh svg {
    width: 16px;
    height: 16px;
}

.btn-refresh.loading svg {
    animation: rotate-360 1s linear infinite;
}

@keyframes rotate-360 {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.card-header .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value.loading .skeleton {
    display: inline-block;
    width: 48px;
    height: 28px;
}
/* ── Responsiveness ── */
@media (max-width: 1024px) {
    .sidebar { position: fixed !important; transform: translateX(-100%); z-index: 1000; box-shadow: 10px 0 30px rgba(0,0,0,0.1); transition: transform .3s ease; }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .hamburger { display: flex !important; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .profile-view { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .app-layout { flex-direction: column; }
    .sidebar { position: fixed !important; transform: translateX(-100%); z-index: 1000; box-shadow: 10px 0 30px rgba(0,0,0,0.1); transition: transform .3s ease; height: 100vh; width: 260px; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; width: 100%; min-width: 0; }
    .topbar { width: 100%; padding: 0 16px; position: sticky; top: 0; z-index: 50; }
    .hamburger { display: flex !important; }
    .content-area { padding: 16px; }
    .features-grid { grid-template-columns: 1fr; }
    table.data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .profile-view { flex-direction: column; }
    .card-body { padding: 16px; }
    .topbar-title { font-size: 16px; }
}
