/* ============================================================================
   MediCore Clinic SaaS — base styles (Phase 1)
   Design tokens from §21 of the master plan:
     Primary blue  #155EEF
     Dark navy     #0B2A5B
     Cyan accent   #06B6D4
     Orange accent #FF8A00
     White cards, soft blue-gray background.
   Only tokens + layout here; no decorative gradients.
============================================================================ */

:root {
    --mc-primary:        #155EEF;
    --mc-primary-600:    #1250D2;
    --mc-primary-100:    #E6EEFF;
    --mc-navy:           #0B2A5B;
    --mc-cyan:           #06B6D4;
    --mc-orange:         #FF8A00;

    --mc-bg:             #F5F8FF;
    --mc-surface:        #FFFFFF;
    --mc-border:         #E3E8F3;
    --mc-text:           #0F2345;
    --mc-text-muted:     #5A6B8C;

    --mc-success:        #16A34A;
    --mc-warning:        #D97706;
    --mc-danger:         #DC2626;

    --mc-radius:         12px;
    --mc-radius-sm:      8px;
    --mc-shadow:         0 1px 2px rgba(11,42,91,.05), 0 6px 20px rgba(21,94,239,.06);
    --mc-shadow-sm:      0 1px 2px rgba(11,42,91,.06);

    --mc-sidebar-w:      248px;
    --mc-topbar-h:       60px;
}

html, body { background: var(--mc-bg); color: var(--mc-text); }
body       { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
             -webkit-font-smoothing: antialiased; }

a         { color: var(--mc-primary); text-decoration: none; }
a:hover   { color: var(--mc-primary-600); text-decoration: underline; }
code      { background: var(--mc-primary-100); color: var(--mc-navy); padding: .1rem .4rem; border-radius: 6px; font-size: .85em; }

/* ---- Buttons ---- */
.btn-primary {
    background-color: var(--mc-primary);
    border-color: var(--mc-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--mc-primary-600);
    border-color: var(--mc-primary-600);
}
.btn-primary:focus-visible {
    box-shadow: 0 0 0 .25rem rgba(21, 94, 239, .25);
}

/* ---- App shell ---- */
.app-shell  { background: var(--mc-bg); }
.app-wrap   { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--mc-sidebar-w);
    background: var(--mc-navy);
    color: #D8E1F3;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.app-brand {
    padding: 1.25rem 1.25rem 1rem;
    display: flex; align-items: center; gap: .6rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--mc-primary);
    display: inline-grid; place-items: center;
    color: #fff; font-size: 1.1rem;
}
.brand-name { font-weight: 600; letter-spacing: .2px; color: #fff; }

.app-nav { padding: .5rem; flex: 1; overflow-y: auto; }
.app-nav-link, .app-nav-stub {
    display: flex; align-items: center; gap: .75rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    color: #B9C5E0;
    margin-bottom: 2px;
    font-size: .95rem;
}
.app-nav-link { cursor: pointer; }
.app-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.app-nav-link.active { background: var(--mc-primary); color: #fff; }
.app-nav-link i, .app-nav-stub i { font-size: 1.05rem; width: 1.1em; text-align: center; }
.app-nav-stub { opacity: .55; cursor: not-allowed; }
.app-nav-section {
    margin: 1rem .75rem .25rem;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .08em;
    color: #7E8DAE;
}
.phase-pill {
    margin-left: auto;
    background: rgba(255,138,0,.15);
    color: var(--mc-orange);
    font-size: .7rem;
    padding: .1rem .45rem;
    border-radius: 999px;
}

.app-sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    color: #A8B4D1;
}
.app-sidebar-footer small { color: #D8E1F3; }

/* ---- Topbar ---- */
.app-topbar {
    height: var(--mc-topbar-h);
    background: var(--mc-surface);
    border-bottom: 1px solid var(--mc-border);
    display: flex; align-items: center;
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 20;
}
.app-topbar-title { font-weight: 600; color: var(--mc-navy); }
.app-topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.app-sidebar-toggle { color: var(--mc-navy); font-size: 1.25rem; padding: .25rem .5rem; }

.user-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .25rem .5rem;
    color: var(--mc-navy);
    text-decoration: none;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--mc-primary-100); color: var(--mc-primary);
    display: inline-grid; place-items: center; font-weight: 600;
}
.user-name { font-weight: 500; }

/* ---- Content & footer ---- */
.app-main-col { min-width: 0; }
.app-content  { padding: 1.5rem; max-width: 1280px; width: 100%; }
.app-footer   { padding: .75rem 1.5rem; display: flex; justify-content: space-between;
                border-top: 1px solid var(--mc-border); color: var(--mc-text-muted); font-size: .85rem; background: var(--mc-surface); }

/* ---- Page header ---- */
.page-header { margin-bottom: 1.25rem; }
.page-title  { font-size: 1.5rem; font-weight: 600; color: var(--mc-navy); margin: 0 0 .25rem; }
.page-sub    { margin: 0; }

/* ---- Stat cards ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-radius: var(--mc-radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--mc-shadow-sm);
}
.stat-label { color: var(--mc-text-muted); font-size: .85rem; }
.stat-value { font-size: 1.85rem; font-weight: 700; color: var(--mc-navy); margin: .25rem 0 .15rem; line-height: 1.1; }
.stat-foot  { font-size: .8rem; }

/* ---- Data cards (tables / lists) ---- */
.card-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 1rem;
}
@media (max-width: 900px) {
    .card-row { grid-template-columns: 1fr; }
}
.data-card {
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-radius: var(--mc-radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--mc-shadow-sm);
}
.data-card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: .5rem;
}
.data-card-head h2 { font-size: 1rem; font-weight: 600; color: var(--mc-navy); margin: 0; }

/* ---- Chips & phase list ---- */
.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .75rem; font-weight: 500;
    padding: .2rem .55rem; border-radius: 999px;
    background: #EEF1F7; color: var(--mc-text-muted);
}
.chip-ok      { background: #DCFCE7; color: #166534; }
.chip-pending { background: #FEF3C7; color: #92400E; }
.chip-danger  { background: #FEE2E2; color: #991B1B; }

.phase-list { list-style: none; padding: 0; margin: .25rem 0 0; }
.phase-item {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center; gap: .75rem;
    padding: .55rem 0;
    border-bottom: 1px dashed var(--mc-border);
}
.phase-item:last-child { border-bottom: 0; }
.phase-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--mc-primary-100); color: var(--mc-primary);
    display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.phase-done .phase-num { background: #DCFCE7; color: #166534; }
.phase-next .phase-num { background: #FEF3C7; color: #92400E; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--mc-text-muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--mc-primary-100); }

/* ---- Toasts (flash) ---- */
.toast-stack {
    position: fixed; top: calc(var(--mc-topbar-h) + 12px); right: 16px;
    display: grid; gap: .5rem; z-index: 1055;
    pointer-events: none;
}
.toast-item {
    pointer-events: auto;
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-left: 4px solid var(--mc-primary);
    padding: .6rem .9rem;
    border-radius: var(--mc-radius-sm);
    box-shadow: var(--mc-shadow);
    animation: toastIn .25s ease-out;
    max-width: 360px;
}
.toast-success { border-left-color: var(--mc-success); }
.toast-info    { border-left-color: var(--mc-primary); }
.toast-error   { border-left-color: var(--mc-danger); }
@keyframes toastIn { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---- Auth (login) layout ---- */
.auth-shell { background: var(--mc-bg); min-height: 100vh; }
.auth-wrap  { display: grid; place-items: center; padding: 2rem 1rem; min-height: 100vh; }
.auth-card  {
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-radius: var(--mc-radius);
    padding: 2rem;
    width: 100%; max-width: 400px;
    box-shadow: var(--mc-shadow);
}
.auth-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; }
.auth-brand .brand-name { color: var(--mc-navy); font-size: 1.1rem; }
.auth-title    { font-size: 1.5rem; font-weight: 600; color: var(--mc-navy); margin: 0 0 .25rem; }
.auth-subtitle { color: var(--mc-text-muted); margin: 0 0 1.25rem; font-size: .95rem; }
.auth-footnote { color: var(--mc-text-muted); font-size: .85rem; text-align: center; }
.auth-footer   { text-align: center; margin-top: .75rem; }

/* ---- Install wizard styling ---- */
.install-shell { background: var(--mc-bg); min-height: 100vh; }
.install-wrap  { max-width: 820px; margin: 0 auto; padding: 2.5rem 1rem 3rem; }
.install-card  {
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-radius: var(--mc-radius);
    padding: 2rem;
    box-shadow: var(--mc-shadow);
}
.install-steps {
    display: flex; gap: .5rem; margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: .25rem;
}
.install-step {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .7rem; border-radius: 999px;
    background: #EEF1F7; color: var(--mc-text-muted);
    font-size: .8rem; white-space: nowrap;
}
.install-step.current { background: var(--mc-primary); color: #fff; }
.install-step.done    { background: #DCFCE7; color: #166534; }
.check-list { padding-left: 1.1rem; }
.check-pass { color: #166534; }
.check-fail { color: #991B1B; }
.check-warn { color: #92400E; }

/* ---- Table niceties ---- */
.table thead th { font-weight: 600; color: var(--mc-text-muted); border-bottom: 1px solid var(--mc-border); }
.table tbody td { border-bottom: 1px solid var(--mc-border); }
.table-sm td, .table-sm th { padding: .5rem; }

/* ---- Form invalid feedback (we add is-invalid via PHP) ---- */
.invalid-feedback.d-block { display: block; }

/* ---- Responsive: hide sidebar on small screens; the toggle button appears ---- */
@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 1050;
    }
    .app-sidebar.open { transform: translateX(0); }
    .app-main-col     { width: 100%; }
}

/* ---- Print ---- */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .toast-stack { display: none !important; }
    .app-content { padding: 0; }
    body         { background: #fff; }
}

/* ---- Landing blurb ---- */
.landing-blurb { color: var(--mc-text-muted); font-size: .95rem; }
.landing-blurb p { margin-bottom: .75rem; }

/* ---- Phase 6: patient portal ---- */
.portal-shell .card { border-radius: .75rem; }
.portal-shell .slot-btn { min-width: 5.5rem; }
.portal-shell .doc-sheet { background: #fff; border: 1px solid #dee2e6; border-radius: .75rem; padding: 1.5rem; }
@media print {
    .no-print, .portal-nav { display: none !important; }
    .portal-shell { background: #fff !important; }
    .portal-shell .doc-sheet { border: 0; padding: 0; }
    .portal-shell main { padding: 0 !important; }
}
