/* ═══════════════════════════════════════════════════════
   CLINIC MANAGEMENT SYSTEM — STYLESHEET
   Font: Nunito (body) + Playfair Display (headings)
   Theme: Deep teal + white + warm accents
════════════════════════════════════════════════════════ */

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

:root {
    --primary:        #0d7377;
    --primary-dark:   #0a5a5e;
    --primary-light:  #14a085;
    --primary-xlight: #e0f5f5;
    --accent:         #f0a500;
    --accent-dark:    #d4920a;
    --danger:         #e74c3c;
    --success:        #27ae60;
    --warning:        #f39c12;
    --info:           #2980b9;
    --dark:           #1a2332;
    --gray-100:       #f8fafc;
    --gray-200:       #eef2f7;
    --gray-300:       #dee2e8;
    --gray-500:       #8a95a3;
    --gray-700:       #4a5568;
    --white:          #ffffff;
    --sidebar-w:      260px;
    --topbar-h:       65px;
    --radius:         12px;
    --radius-sm:      8px;
    --shadow:         0 4px 20px rgba(0,0,0,0.08);
    --shadow-md:      0 8px 30px rgba(0,0,0,0.12);
    --transition:     all 0.25s ease;
}

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

html { font-size: 15px; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ─── LAYOUT ─────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.page-body {
    padding: 28px 32px;
    flex: 1;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 24px 20px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-icon {
    width: 42px; height: 42px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-family: 'Playfair Display', serif;
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-brand .brand-text span {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-size: 0.72rem;
    font-weight: 400;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sidebar-nav { padding: 16px 0; flex: 1; }

.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
    margin-top: 8px;
}

.nav-item { margin: 2px 10px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.62);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.nav-link.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(13,115,119,0.4);
}

.nav-link .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-link .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-user:hover { background: rgba(255,255,255,0.07); }

.sidebar-user .user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
    font-size: 0.82rem; font-weight: 600;
    color: var(--white);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
    font-size: 0.7rem; color: rgba(255,255,255,0.4);
    text-transform: capitalize;
}

/* ─── TOPBAR ─────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-300);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 10px rgba(0,0,0,0.05);
}

.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--dark); flex: 1; }
.topbar-title span { font-weight: 400; color: var(--gray-500); font-size: 0.85rem; }

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

.topbar-btn {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--gray-700);
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}

.topbar-btn:hover { background: var(--primary-xlight); color: var(--primary); border-color: var(--primary); }

.topbar-btn .badge-dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--white);
}

/* ─── CARDS ──────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    width: 30px; height: 30px;
    background: var(--primary-xlight);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    font-size: 0.9rem;
}

.card-body { padding: 24px; }

/* ─── STAT CARDS ─────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--stat-color, var(--primary));
}

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

.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    background: var(--stat-bg, var(--primary-xlight));
    color: var(--stat-color, var(--primary));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-info { flex: 1; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 800; color: var(--dark); line-height: 1; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--gray-500); font-weight: 500; margin-top: 4px; }
.stat-card .stat-change { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }
.stat-card .stat-change.up   { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

.stat-teal   { --stat-color: var(--primary);  --stat-bg: var(--primary-xlight); }
.stat-green  { --stat-color: var(--success);  --stat-bg: #e8f8ef; }
.stat-yellow { --stat-color: var(--warning);  --stat-bg: #fef3dc; }
.stat-red    { --stat-color: var(--danger);   --stat-bg: #fde8e6; }
.stat-blue   { --stat-color: var(--info);     --stat-bg: #deeef8; }
.stat-purple { --stat-color: #8e44ad;         --stat-bg: #f3e6fa; }

/* ─── TABLES ─────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

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

thead th {
    background: var(--gray-100);
    padding: 11px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-300);
}

tbody td {
    padding: 13px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-100); }

/* ─── BADGES ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: 0.03em;
}

.badge-scheduled  { background: #deeef8; color: #2980b9; }
.badge-confirmed  { background: #d5f0e0; color: #1e8449; }
.badge-in_progress{ background: #fef3dc; color: #d4920a; }
.badge-completed  { background: #d5f0e0; color: #1e8449; }
.badge-cancelled  { background: #fde8e6; color: #c0392b; }
.badge-no_show    { background: #ede8fd; color: #6c3483; }
.badge-pending    { background: #fef3dc; color: #d4920a; }
.badge-paid       { background: #d5f0e0; color: #1e8449; }
.badge-partial    { background: #deeef8; color: #2980b9; }
.badge-admin       { background: #fde8e6; color: #c0392b; }
.badge-doctor      { background: var(--primary-xlight); color: var(--primary); }
.badge-receptionist{ background: #fef3dc; color: #d4920a; }
.badge-patient     { background: #d5f0e0; color: #1e8449; }
.badge-active      { background: #d5f0e0; color: #1e8449; }
.badge-inactive    { background: #f0f0f0; color: #666; }

/* ─── BUTTONS ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.855rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: var(--transition);
    line-height: 1;
    white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color:#fff; }

.btn-accent    { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

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

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

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

.btn-ghost     { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-200); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }

.btn-icon {
    width: 34px; height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ─── FORMS ──────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control, .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: 'Nunito', sans-serif;
    font-size: 0.875rem;
    color: var(--dark);
    background: var(--white);
    transition: var(--transition);
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,115,119,0.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: 0.78rem; margin-top: 4px; }

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

.form-row { display: grid; gap: 18px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── ALERTS ─────────────────────────────────────────── */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.875rem;
    margin-bottom: 20px;
}

.alert-success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-danger  { background: #fdf2f2; color: #c0392b; border: 1px solid #f5b7b1; }
.alert-warning { background: #fef9e7; color: #d4920a; border: 1px solid #f9e79f; }
.alert-info    { background: #eaf4fc; color: #1a6fa4; border: 1px solid #aed6f1; }

/* ─── PAGE HEADER ────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header-left .page-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--dark);
    font-family: 'Playfair Display', serif;
}

.page-header-left .breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 3px;
}

.breadcrumb a { color: var(--primary); text-decoration: none; }

/* ─── AVATAR / PROFILE ───────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-md { width: 42px; height: 42px; font-size: 0.9rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 90px; height: 90px; font-size: 1.8rem; }

.avatar-teal   { background: var(--primary); }
.avatar-green  { background: var(--success); }
.avatar-yellow { background: var(--warning); }
.avatar-blue   { background: var(--info); }
.avatar-red    { background: var(--danger); }
.avatar-purple { background: #8e44ad; }

/* ─── APPOINTMENT TIMELINE ───────────────────────────── */
.appointment-list { display: flex; flex-direction: column; gap: 10px; }

.appointment-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    transition: var(--transition);
}

.appointment-item:hover { background: var(--primary-xlight); }
.appointment-item .time { font-weight: 700; color: var(--primary); font-size: 0.9rem; min-width: 55px; }
.appointment-item .name { font-weight: 600; font-size: 0.88rem; }
.appointment-item .sub  { font-size: 0.78rem; color: var(--gray-500); }

/* ─── PAGINATION ─────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.page-link:hover, .page-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ─── SEARCH BAR ─────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-input-wrap .search-icon {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    font-size: 0.9rem;
}

.search-input-wrap input {
    width: 100%;
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: 'Nunito', sans-serif;
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.search-input-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,115,119,0.1); }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--gray-500);
}

.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 12px; opacity: 0.35; }
.empty-state h4 { font-size: 1.1rem; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.empty-state p  { font-size: 0.875rem; }

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

.login-page::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: rgba(13,115,119,0.15);
    border-radius: 50%;
    top: -150px; right: -150px;
}

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

.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 44px 42px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

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

.login-logo .logo-icon {
    width: 66px; height: 66px;
    background: var(--primary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin: 0 auto 14px;
    box-shadow: 0 8px 20px rgba(13,115,119,0.35);
}

.login-logo h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    color: var(--dark);
    margin-bottom: 4px;
}

.login-logo p { font-size: 0.82rem; color: var(--gray-500); }

/* ─── DOCTOR INFO CARD ───────────────────────────────── */
.doctor-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.doctor-card:hover { border-color: var(--primary); background: var(--primary-xlight); }

/* ─── MEDICINE ROW ───────────────────────────────────── */
.medicine-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 2fr auto;
    gap: 10px;
    align-items: start;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

/* ─── TABS ───────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}

.tab-link {
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-500);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab-link:hover   { color: var(--primary); }
.tab-link.active  { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── INVOICE PRINT ──────────────────────────────────── */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-body { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-body { padding: 16px; }
    .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .medicine-row { grid-template-columns: 1fr 1fr; }
}

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

/* ─── UTILITIES ──────────────────────────────────────── */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--gray-500); }
.text-dark    { color: var(--dark); }
.text-sm      { font-size: 0.8rem; }
.text-xs      { font-size: 0.72rem; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
