/* ============================================================
   PHYSIOTHERAPY CMS — MAIN STYLESHEET v9
   Dark/Light mode + Professional design
   ============================================================ */

/* ---- CSS Variables (Light Mode) ---- */
:root {
    --primary:       #ec973e;
    --primary-dark:  #2461ac;
    --primary-light: #ccfbf1;
    --accent:        #f97316;
    --success:       #22c55e;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --bg-body:       #f0fdf9;
    --bg-card:       #ffffff;
    --sidebar-bg:    #0f172a;
    --sidebar-text:  #94a3b8;
    --border:        #e2e8f0;
    --text-main:     #1e293b;
    --text-muted:    #64748b;
    --font:          'Plus Jakarta Sans', sans-serif;
    --radius:        12px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
    --shadow-lg:     0 4px 24px rgba(0,0,0,.12);
    --sidebar-w:     260px;
    --topnav-h:      64px;
}

/* ---- Dark Mode Variables ---- */
[data-theme="dark"] {
    --bg-body:    #0f172a;
    --bg-card:    #1e293b;
    --border:     #334155;
    --text-main:  #f1f5f9;
    --text-muted: #94a3b8;
    --shadow:     0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
    --shadow-lg:  0 4px 24px rgba(0,0,0,.4);
}
[data-theme="dark"] .table    { color: var(--text-main); }
[data-theme="dark"] .table th { background: #1a2744; color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .table td { border-color: var(--border); }
[data-theme="dark"] .table tbody tr:hover { background: #263348; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
[data-theme="dark"] .form-control::placeholder { color: #64748b; }
[data-theme="dark"] .input-group-text { background: #263348; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .modal-content  { background: #1e293b; color: #f1f5f9; border-color: #334155; }
[data-theme="dark"] .modal-header   { border-color: #334155; }
[data-theme="dark"] .modal-footer   { border-color: #334155; }
[data-theme="dark"] .dropdown-menu  { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .dropdown-item  { color: #f1f5f9; }
[data-theme="dark"] .dropdown-item:hover { background: #263348; }
[data-theme="dark"] .list-group-item { background: var(--bg-card); border-color: var(--border); color: var(--text-main); }
[data-theme="dark"] .alert-info  { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }
[data-theme="dark"] .top-navbar  { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .btn-light   { background: #334155; color: #f1f5f9; border-color: #475569; }
[data-theme="dark"] .payment-summary { background: linear-gradient(135deg,#134e4a22,#0d948820); border-color: #0d948840; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg-body); color: var(--text-main); transition: background .2s, color .2s; }

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

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    position: fixed; top: 0; left: 0;
    height: 100vh; overflow-y: auto; overflow-x: hidden;
    z-index: 1000; transition: transform .3s ease;
    display: flex; flex-direction: column;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon {
    width: 40px; height: 40px; background: var(--primary);
    border-radius: 10px; display: flex; align-items: center;
    justify-content: center; font-size: 20px; color: white; flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.brand-role { color: var(--sidebar-text); font-size: .72rem; }

.sidebar-menu { list-style: none; padding: 12px 0; flex: 1; }
.sidebar-menu li.menu-label {
    padding: 12px 20px 4px;
    font-size: .65rem; text-transform: uppercase;
    letter-spacing: .08em; color: #475569; font-weight: 600;
}
.sidebar-menu li a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 20px; color: var(--sidebar-text);
    text-decoration: none; font-size: .875rem; font-weight: 500;
    transition: all .15s; border-left: 3px solid transparent;
}
.sidebar-menu li a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-menu li a.active { background: rgba(13,148,136,.2); color: #ec973e; border-left-color: var(--primary); }
.sidebar-menu li a i { font-size: 1rem; width: 20px; flex-shrink: 0; }

/* CONTENT */
#content { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* TOP NAV */
.top-navbar {
    height: var(--topnav-h); background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px;
    position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
    transition: background .2s;
}
.sidebar-toggle {
    background: none; border: 1px solid var(--border);
    border-radius: 8px; padding: 6px 10px;
    color: var(--text-main); font-size: 1.2rem; cursor: pointer;
}
.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: .875rem;
}

/* Dark mode toggle button */
.theme-toggle {
    background: none; border: 1px solid var(--border);
    border-radius: 8px; padding: 6px 10px; cursor: pointer;
    color: var(--text-main); font-size: 1rem; transition: all .15s;
}
.theme-toggle:hover { background: var(--primary); color: white; border-color: var(--primary); }

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

/* ============================================================ PAGE HEADER ============================================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin: 0; }

/* ============================================================ CARDS ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: background .2s;
}
.card-header {
    background: none; border-bottom: 1px solid var(--border);
    padding: 14px 20px; font-weight: 600; font-size: .95rem;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-main);
}
.card-body { padding: 20px; }

/* STAT CARDS */
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
    transition: transform .2s, box-shadow .2s, background .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    width: 44px; height: 44px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; margin-bottom: 10px;
}
.stat-card .stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1; color: var(--text-main); }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

.stat-teal   .stat-icon { background: #ccfbf1; color: #0d9488; }
.stat-orange .stat-icon { background: #fff7ed; color: #f97316; }
.stat-green  .stat-icon { background: #f0fdf4; color: #22c55e; }
.stat-red    .stat-icon { background: #fef2f2; color: #ef4444; }
.stat-blue   .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-purple .stat-icon { background: #faf5ff; color: #a855f7; }

[data-theme="dark"] .stat-teal   .stat-icon { background: #134e4a40; }
[data-theme="dark"] .stat-orange .stat-icon { background: #431a0040; }
[data-theme="dark"] .stat-green  .stat-icon { background: #14532d40; }
[data-theme="dark"] .stat-red    .stat-icon { background: #7f1d1d40; }
[data-theme="dark"] .stat-blue   .stat-icon { background: #1e3a5f40; }
[data-theme="dark"] .stat-purple .stat-icon { background: #3b0764 40; }

/* ============================================================ TABLE ============================================================ */
.table { margin: 0; font-size: .875rem; }
.table th {
    background: #f8fafc; font-weight: 600; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    padding: 11px 16px; white-space: nowrap;
}
.table td { padding: 11px 16px; vertical-align: middle; border-color: var(--border); color: var(--text-main); }
.table tbody tr:hover { background: rgba(0,0,0,.02); }

/* ============================================================ FORMS ============================================================ */
.form-label { font-weight: 600; font-size: .78rem; color: var(--text-muted); margin-bottom: 5px; }
.form-control, .form-select {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 9px 14px; font-size: .875rem;
    background: var(--bg-card); color: var(--text-main);
    transition: border-color .15s, box-shadow .15s; font-family: var(--font);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,.12); outline: none;
}
.input-group-text { background: #f8fafc; border-color: var(--border); color: var(--text-muted); }
.section-divider { border: none; border-top: 2px dashed var(--border); margin: 20px 0; }
.section-title {
    font-size: .78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--primary); margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}
.section-title::after { content:''; flex:1; height:1px; background: var(--primary-light); }

/* ============================================================ BUTTONS ============================================================ */
.btn { border-radius: 8px; font-weight: 600; font-size: .84rem; padding: 8px 16px; transition: all .15s; font-family: var(--font); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }
.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; display:inline-flex; align-items:center; justify-content:center; }

/* ============================================================ BADGES ============================================================ */
.badge { font-weight: 600; font-size: .69rem; border-radius: 6px; padding: 3px 8px; }

/* ============================================================ PAYMENT SUMMARY ============================================================ */
.payment-summary {
    background: linear-gradient(135deg, #f0fdf9, #ccfbf1);
    border: 1px solid #99f6e4; border-radius: var(--radius); padding: 14px;
}
.payment-summary .amount-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.payment-summary .amount-value { font-size: 1.1rem; font-weight: 700; }

/* ============================================================ VISIT GRID ============================================================ */
.visit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 5px;
}
.visit-chip {
    padding: 7px 4px 6px; border-radius: 8px; text-align: center;
    font-weight: 600; border: 1px solid transparent;
    line-height: 1.3; user-select: none;
    min-height: 52px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.visit-chip.status-present { background: #dcfce7; border-color: #86efac; }
.visit-chip.status-pending {
    background: #fefce8; border-color: #fde68a;
    cursor: pointer; transition: box-shadow .15s;
}
.visit-chip.status-pending:hover,
.visit-chip.status-pending.active-chip {
    box-shadow: 0 0 0 2px rgba(245,158,11,.35);
    border-color: #f59e0b;
}

/* ============================================================ LOGIN PAGE ============================================================ */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #134e4a 50%, #0f172a 100%);
}
.login-card {
    width: 100%; max-width: 420px; background: white;
    border-radius: 20px; padding: 40px;
    box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 16px; display: flex; align-items: center;
    justify-content: center; font-size: 30px; color: white; margin: 0 auto 20px;
}
.login-title { text-align:center; font-weight:800; font-size:1.5rem; margin-bottom:4px; }
.login-sub { text-align:center; color:#64748b; font-size:.85rem; margin-bottom:28px; }

/* ============================================================ VISIT TABLE BUTTONS ============================================================ */
.visit-btn-group { display:flex; gap:4px; flex-wrap:wrap; }
.visit-btn-group .btn { font-size:.75rem; padding:4px 10px; white-space:nowrap; }
@media (max-width:768px) {
    .visit-btn-group { flex-direction:column; gap:3px; }
    .visit-btn-group .btn { width:100%; }
    .visit-grid { grid-template-columns: repeat(auto-fill, minmax(48px,1fr)); }
}

/* ============================================================ RESPONSIVE ============================================================ */
@media (max-width:991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    #content { margin-left: 0; }
    .main-content { padding: 16px; }
}
@media (max-width:575.98px) {
    .stat-card .stat-value { font-size: 1.3rem; }
    .page-header h1 { font-size: 1.15rem; }
}

/* ============================================================ SCROLLBAR ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ============================================================ DARK MODE EXTRA ============================================================ */
[data-theme="dark"] .sidebar { background: #020617; }
[data-theme="dark"] .sidebar-menu li a.active { background: rgba(13,148,136,.25); }
[data-theme="dark"] .payment-summary { background: linear-gradient(135deg,#134e4a22,#0d948822); border-color:#0d948850; }
[data-theme="dark"] .visit-chip.status-present { background:#14532d30; border-color:#16a34a50; }
[data-theme="dark"] .visit-chip.status-pending { background:#78350f20; border-color:#f59e0b40; }
[data-theme="dark"] .stat-card { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .card-header { background: transparent; }
[data-theme="dark"] .login-card { background:#1e293b; }
[data-theme="dark"] .login-sub { color:#94a3b8; }
[data-theme="dark"] .table-secondary { background: rgba(255,255,255,.03) !important; }

/* ============================================================ LEADS ============================================================ */
.lead-status-pending   { background:#fff7ed; color:#c2410c; border:1px solid #fed7aa; }
.lead-status-converted { background:#f0fdf4; color:#15803d; border:1px solid #bbf7d0; }
.lead-status-negative  { background:#fef2f2; color:#b91c1c; border:1px solid #fecaca; }
