/* =========================================================
   Doctor Appointment System — Modern UI
   ========================================================= */

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

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary:       #4f46e5;
    --primary-dark:  #4338ca;
    --primary-light: #eef2ff;
    --success:       #10b981;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --info:          #0ea5e9;
    --dark:          #0f172a;
    --gray-900:      #111827;
    --gray-700:      #374151;
    --gray-500:      #6b7280;
    --gray-400:      #9ca3af;
    --gray-200:      #e5e7eb;
    --gray-100:      #f3f4f6;
    --gray-50:       #f9fafb;
    --white:         #ffffff;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.05);
    --shadow:        0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:     0 20px 50px rgba(0,0,0,.15);
}

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------- LOGIN ---------- */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(circle at 10% 20%, rgba(120, 119, 198, .35), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 119, 198, .35), transparent 40%),
        linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: var(--white);
    padding: 48px 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    animation: fadeIn .4s ease;
}

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

.login-box h2 {
    text-align: center;
    margin-bottom: 32px;
    color: var(--gray-900);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
}

/* ---------- FORM ---------- */

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ---------- BUTTONS ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 22px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    line-height: 1;
    transition: all .18s ease;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 16px rgba(79,70,229,.35); }

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

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

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #0284c7; }

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

/* ---------- ALERTS ---------- */

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid;
}

.alert-success { background: #ecfdf5; color: #065f46; border-color: var(--success); }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: var(--danger);  }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: var(--info);    }

/* ---------- DASHBOARD LAYOUT ---------- */

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

.sidebar {
    width: 270px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    color: #e0e7ff;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar h2 {
    text-align: left;
    padding: 0 24px 24px;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    letter-spacing: -.01em;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: #c7d2fe;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .18s;
    border-left: 3px solid transparent;
}

.sidebar a:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.sidebar a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: #a5b4fc;
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 36px 40px;
    max-width: 100%;
    overflow-x: auto;
}

.main-content > h1 {
    color: var(--gray-900);
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.main-content > p {
    color: var(--gray-500);
    margin-bottom: 28px;
    font-size: 14px;
}

/* ---------- STATS ---------- */

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

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.stat-card h3 {
    color: var(--gray-500);
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.stat-card .number {
    font-size: 34px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
    letter-spacing: -.03em;
}

.stat-card:nth-child(2)::before { background: var(--success); }
.stat-card:nth-child(3)::before { background: var(--warning); }
.stat-card:nth-child(4)::before { background: var(--info); }

/* ---------- TABLES ---------- */

.table-container {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow-x: auto;
}

.table-container h3 {
    color: var(--gray-900);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -.01em;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th,
table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

table th {
    background: var(--gray-50);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

table tbody tr {
    transition: background .15s;
}

table tbody tr:hover {
    background: var(--gray-50);
}

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

/* ---------- BADGES ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: capitalize;
}

.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-active    { background: #d1fae5; color: #065f46; }
.badge-inactive  { background: #fee2e2; color: #991b1b; }

/* ---------- HEADER BAR ---------- */

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.header-bar h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--gray-900);
}

.header-bar .btn-primary { width: auto; }

/* ---------- FILTER BAR (appointments page) ---------- */

.main-content > div a.btn-sm {
    margin-right: 4px;
    margin-bottom: 4px;
}

/* ---------- MODALS ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn .2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    padding: 32px;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: fadeIn .25s ease;
}

.modal h3 {
    margin-bottom: 24px;
    color: var(--gray-900);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-100);
}

.modal-actions .btn {
    width: auto;
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 900px) {
    .dashboard { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 16px 0;
    }
    .sidebar h2 {
        padding: 0 20px 16px;
        margin-bottom: 8px;
        text-align: center;
    }
    .sidebar a {
        padding: 10px 20px;
        font-size: 13px;
    }
    .main-content { padding: 24px 20px; }
    .main-content > h1 { font-size: 22px; }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    .stat-card { padding: 18px; }
    .stat-card .number { font-size: 26px; }
    table th, table td { padding: 10px 12px; font-size: 13px; }
    .table-container { padding: 16px; }
}

@media (max-width: 480px) {
    .login-box { padding: 36px 24px; }
    .main-content > h1,
    .header-bar h1 { font-size: 20px; }
    .modal { padding: 24px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
}