/**
 * Dental CRM & EMR - Warm Editorial & Forest Sage Aesthetic
 * Inspired directly by the reference image:
 * - Soothing warm linen / sand-cream canvas (#f0efe9)
 * - Pure white floating cards with 22px border radius
 * - Deep Forest Sage Green accents (#203a2e)
 * - Solid forest accent cards & circular semi-donut gauges
 * - Minimalist floating rounded sidebar with dark pill active states
 * 100% Local Assets - Zero CDN
 */

@font-face {
    font-family: 'Peyda';
    src: url('../fonts/PeydaWeb.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Peyda';
    src: url('../fonts/Peyda.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Warm Organic Canvas */
    --bg-body: #f0efe9;
    --bg-card: #ffffff;
    --bg-card-subtle: #f8f7f3;
    --border-color: #e5e3dc;
    --border-subtle: #eceae3;

    /* Text */
    --text-primary: #19231d;
    --text-secondary: #4a5850;
    --text-muted: #7c8a82;
    --text-light: #9ea9a2;

    /* Forest Sage Palette */
    --forest-dark: #203a2e;
    --forest-medium: #2e5241;
    --forest-light: #44705a;
    --sage-bg: #e6ede8;
    --sand-pill: #e8e5dc;
    --rose-accent: #c24141;

    --card-shadow: 0 8px 24px -4px rgba(32, 58, 46, 0.05), 0 2px 6px -1px rgba(32, 58, 46, 0.03);
    --card-shadow-hover: 0 16px 36px -6px rgba(32, 58, 46, 0.10);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-full: 9999px;
}

[data-theme="dark"] {
    --bg-body: #0e1512;
    --bg-card: #15201b;
    --bg-card-subtle: #1c2a24;
    --border-color: #24352d;
    --border-subtle: #1c2b23;

    --text-primary: #f2f5f3;
    --text-secondary: #c2ccc5;
    --text-muted: #88998f;
    --text-light: #5c6e64;

    --forest-dark: #1b2e24;
    --forest-medium: #3b6651;
    --forest-light: #528c6f;
    --sage-bg: rgba(68, 112, 90, 0.25);
    --sand-pill: #22332a;

    --card-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.40);
    --card-shadow-hover: 0 16px 36px -6px rgba(0, 0, 0, 0.60);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}

body {
    font-family: 'Peyda', 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
    text-align: right;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    font-size: 14px;
    line-height: 1.6;
}

/* Card Base */
.glass-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-subtle);
}

.glass-panel:hover {
    box-shadow: var(--card-shadow-hover);
}

.glass-panel-interactive:hover {
    transform: translateY(-2px);
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    padding: 24px;
    gap: 24px;
}

/* Slim Floating Sidebar */
.app-sidebar {
    width: 80px;
    flex-shrink: 0;
    height: calc(100vh - 48px);
    position: sticky;
    top: 24px;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-subtle);
}

.sidebar-brand-icon {
    width: 48px;
    height: 48px;
    background: var(--forest-dark);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    margin-bottom: 24px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
    flex: 1;
}

.nav-link {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 20px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--bg-card-subtle);
    color: var(--forest-dark);
}

.nav-link.active {
    background: var(--forest-dark);
    color: white;
    box-shadow: 0 6px 16px -2px rgba(32, 58, 46, 0.35);
}

[data-theme="dark"] .nav-link.active {
    background: var(--forest-light);
}

.sidebar-bottom-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: calc(100vw - 150px);
}

/* Warm Editorial Top Header */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.topbar-greeting h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.topbar-greeting p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.search-pill-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    padding: 6px 10px 6px 18px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-subtle);
    width: 320px;
}

.search-pill-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}

.search-circle-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--forest-dark);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.topbar-circle-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    font-size: 18px;
    position: relative;
}

.topbar-circle-btn:hover {
    background: var(--bg-card-subtle);
    transform: translateY(-2px);
}

/* =========================================================
   4 Top KPI Cards (Matching reference image)
   ========================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.stat-card {
    padding: 22px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card-forest {
    background: var(--forest-dark) !important;
    color: white !important;
}

.stat-card-forest .stat-label {
    color: rgba(255, 255, 255, 0.75) !important;
}

.stat-card-forest .stat-value {
    color: white !important;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

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

.stat-mini-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: var(--sand-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
}

/* =========================================================
   Main Grid Layout (Left: 2 Cols, Right: 1 Col)
   ========================================================= */
.editorial-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 20px;
}

/* Left Section */
.left-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Schedule / Appointments Card */
.appointments-card {
    padding: 26px;
}

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

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

/* Treatment Shift Rows */
.shift-slots-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shift-slot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-card-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
}

.shift-slot-row:hover {
    background: var(--bg-card);
    box-shadow: 0 4px 14px -2px rgba(32, 58, 46, 0.06);
    transform: translateX(-3px);
}

.slot-left-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.slot-time-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--forest-dark);
    padding: 4px 10px;
    background: var(--sage-bg);
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .slot-time-badge {
    color: var(--forest-light);
}

/* Right Section Cards (Doctor Profile & Progress Gauge) */
.right-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Doctor Profile Card (Matching Carlic Bolomboy in image) */
.doctor-profile-card {
    padding: 26px;
    text-align: center;
}

.doc-avatar-large {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    background: var(--sand-pill);
    margin: 0 auto 14px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border: 3px solid var(--bg-card);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.doc-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.doc-role {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    margin-bottom: 18px;
}

.doc-stats-row {
    display: flex;
    justify-content: space-around;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}

.doc-stat-col .val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.doc-stat-col .lbl {
    font-size: 11px;
    color: var(--text-muted);
}

/* Progress Gauge Card (Matching 80% Earnings Card in image) */
.gauge-card {
    padding: 24px;
}

.gauge-semi-circle {
    width: 140px;
    height: 70px;
    border-top-left-radius: 140px;
    border-top-right-radius: 140px;
    background: conic-gradient(from 180deg at 50% 100%, var(--forest-dark) 0% 80%, var(--border-color) 80% 100%);
    margin: 20px auto 10px auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.gauge-inner-white {
    width: 104px;
    height: 52px;
    border-top-left-radius: 104px;
    border-top-right-radius: 104px;
    background: var(--bg-card);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
}

.gauge-percentage {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

/* OPG Scan Preview in Sand-Olive frame */
.opg-card-editorial {
    padding: 22px;
}

.opg-frame-editorial {
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 14px;
    background: #000;
    border: 1px solid var(--border-subtle);
}

.opg-frame-editorial img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

/* Buttons */
.btn-forest {
    background: var(--forest-dark);
    color: white;
    border: none;
    padding: 9px 20px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

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

.btn-sand {
    background: var(--sand-pill);
    color: var(--text-primary);
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-sand:hover {
    background: var(--border-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 19, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-window {
    width: 100%;
    max-width: 580px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 28px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.reminder-toast {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-right: 5px solid var(--forest-dark);
    box-shadow: var(--card-shadow-hover);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
