/* =============================================================
   Clopr EMR — shared design system
   =============================================================
   Single source of truth for every EMR_* page's "teal medical"
   look (variables, hero banner, stat cards, tables, badges, empty
   states, primary buttons). Loaded once site-wide via header.php —
   individual EMR_* pages should NOT redeclare these; only add
   page-specific classes in their own <style> block.
   ============================================================= */

:root {
    --emr-bg: #f5f8fb;
    --emr-border: #e2e8f0;
    --emr-muted: #64748b;
    --emr-text: #0f172a;
    --emr-primary: #0d9488;
    --emr-primary-dark: #0f766e;
    --emr-primary-light: #14b8a6;
    --emr-primary-soft: #ccfbf1;
    --emr-accent: #f59e0b;
    --emr-accent-dark: #d97706;
    --emr-accent-soft: #fef3c7;

    /* Elevation scale (mirrors assets/css/main.css's --shadow-sm/md/lg/xl convention) */
    --emr-shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --emr-shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --emr-shadow-md: 0 6px 16px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
    --emr-shadow-lg: 0 14px 32px rgba(15, 23, 42, .12), 0 4px 10px rgba(15, 23, 42, .06);
    --emr-shadow-xl: 0 24px 48px rgba(15, 23, 42, .16);
    /* Kept for backward compat with pages that still reference these names directly */
    --emr-shadow: var(--emr-shadow-sm);
    --emr-shadow-hover: var(--emr-shadow-md);

    --emr-radius: 14px;
    --emr-radius-sm: 10px;
    --emr-transition: all .18s cubic-bezier(.4, 0, .2, 1);
}

.emr-page { background: var(--emr-bg); min-height: calc(100vh - 130px); padding: 24px; }
.emr-page * { box-sizing: border-box; }

/* ---- Hero banner ---- */
.emr-hero {
    background: linear-gradient(135deg, var(--emr-primary-dark), var(--emr-primary) 55%, var(--emr-primary-light));
    color: #fff; border-radius: 18px; padding: 26px 32px;
    box-shadow: 0 10px 32px rgba(13, 148, 136, .25);
    position: relative; overflow: hidden; margin-bottom: 20px;
}
.emr-hero::before {
    content: ''; position: absolute; inset-inline-start: -40px; bottom: -70px;
    width: 200px; height: 200px; border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 158, 11, .18), transparent 70%);
}
.emr-hero::after {
    content: ''; position: absolute; inset-inline-end: -60px; top: -60px;
    width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.emr-hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; position: relative; z-index: 1; }
.emr-hero h1 { font-size: 1.45rem; font-weight: 700; margin: 0 0 4px; }
.emr-hero p { margin: 0; opacity: .9; font-size: .9rem; }
.emr-hero-icon {
    width: 56px; height: 56px; border-radius: 14px; background: rgba(255, 255, 255, .18);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 6px 16px rgba(0, 0, 0, .12);
    backdrop-filter: blur(6px);
}

/* ---- KPI stat cards ---- */
.emr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.emr-stat {
    background: #fff; border: 1px solid var(--emr-border); border-radius: 12px; padding: 14px 16px;
    box-shadow: var(--emr-shadow-sm); transition: var(--emr-transition);
    display: flex; align-items: center; gap: 12px; position: relative; overflow: hidden;
}
.emr-stat:hover { box-shadow: var(--emr-shadow-md); transform: translateY(-2px); border-color: var(--emr-primary-soft); }
.emr-stat .num { font-size: 1.4rem; font-weight: 700; color: var(--emr-text); line-height: 1.1; }
.emr-stat .lbl { font-size: .74rem; color: var(--emr-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.emr-stat-body { display: flex; flex-direction: column; gap: 2px; }
.emr-stat-icon {
    width: 42px; height: 42px; border-radius: 11px; background: var(--emr-primary-soft); color: var(--emr-primary-dark);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; flex-shrink: 0;
}
.emr-stat-trend { display: inline-flex; align-items: center; gap: 3px; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 20px; margin-top: 2px; width: fit-content; }
.emr-stat-trend.up { color: #15803d; background: #dcfce7; }
.emr-stat-trend.down { color: #b91c1c; background: #fee2e2; }

/* ---- Cards ---- */
.emr-card { background: #fff; border: 1px solid var(--emr-border); border-radius: var(--emr-radius); box-shadow: var(--emr-shadow-sm); overflow: hidden; transition: var(--emr-transition); }
.emr-card-header { padding: 12px 18px; border-bottom: 1px solid var(--emr-border); font-weight: 700; font-size: .88rem; background: #f8fafc; }
.emr-card-body { padding: 18px 20px; }
.emr-card-hover:hover { box-shadow: var(--emr-shadow-md); transform: translateY(-2px); }

/* ---- Filter bars ---- */
.emr-filterbar {
    background: #fff; border: 1px solid var(--emr-border); border-radius: var(--emr-radius); box-shadow: var(--emr-shadow-sm);
    padding: 14px 18px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

/* ---- Tables ---- */
.emr-table thead th {
    background: #f8fafc; font-size: .76rem; text-transform: uppercase; letter-spacing: .4px;
    color: var(--emr-muted); font-weight: 700; border-bottom: 2px solid var(--emr-border); padding-top: 12px; padding-bottom: 12px;
}
.emr-table tbody tr { transition: var(--emr-transition); }
.emr-table tbody tr:hover { background: #f0fdfa; box-shadow: inset 3px 0 0 var(--emr-primary); }

/* ---- Empty / loading states ---- */
.emr-empty { text-align: center; padding: 40px 20px; color: var(--emr-muted); }
.emr-empty i { font-size: 2.2rem; opacity: .35; margin-bottom: 10px; display: block; }
.emr-skeleton-row td { padding: 14px 16px; }
.emr-skeleton-bar {
    height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 37%, #eef1f6 63%);
    background-size: 400% 100%; animation: emr-shimmer 1.4s ease infinite;
}
@keyframes emr-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Buttons ---- */
.emr-btn-primary { background: var(--emr-primary); border-color: var(--emr-primary); transition: var(--emr-transition); box-shadow: 0 2px 8px rgba(13, 148, 136, .2); }
.emr-btn-primary:hover { background: var(--emr-primary-dark); border-color: var(--emr-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(13, 148, 136, .3); }

/* ---- Soft semantic badges ---- */
.emr-badge-soft { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px; }
.emr-badge-soft.success { color: #15803d; background: #dcfce7; }
.emr-badge-soft.warning { color: var(--emr-accent-dark); background: var(--emr-accent-soft); }
.emr-badge-soft.danger { color: #b91c1c; background: #fee2e2; }
.emr-badge-soft.info { color: var(--emr-primary-dark); background: var(--emr-primary-soft); }
.emr-badge-soft.neutral { color: var(--emr-muted); background: #f1f5f9; }

/* ---- Page entrance ---- */
.emr-fade-in { animation: emr-fade-in .25s ease both; }
@keyframes emr-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Avatars / chips ---- */
.emr-avatar, .emr-avatar-lg, .emr-avatar-xl {
    border-radius: 50%; background: var(--emr-primary-soft); color: var(--emr-primary-dark);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.emr-avatar { width: 36px; height: 36px; font-size: .85rem; }
.emr-avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }
.emr-avatar-xl { width: 72px; height: 72px; font-size: 1.5rem; }
.emr-id-chip {
    background: rgba(255, 255, 255, .18); border-radius: 8px; padding: 3px 10px; font-size: .8rem;
    display: inline-flex; align-items: center; gap: 5px;
}

/* ---- Status badge generic helper (page-specific colors stay per-page) ---- */
.emr-status-pill { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; }

/* ---- Timeline (shared by PatientProfile + 360 view) ---- */
.emr-timeline { position: relative; }
.emr-tl-item { margin-bottom: 14px; }
.emr-tl-card { background: #fff; border: 1px solid var(--emr-border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--emr-shadow); }
.emr-tl-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.emr-tl-body { font-size: .88rem; color: var(--emr-text); }
.emr-tl-section { margin-top: 8px; }
.emr-tl-section h6 { font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; color: var(--emr-muted); margin-bottom: 4px; }
.emr-pill { display: inline-block; background: #f1f5f9; border-radius: 8px; padding: 3px 10px; margin: 2px; font-size: .8rem; }

/* ---- Toast notifications (replaces native alert()) ---- */
#emrToastStack { position: fixed; top: 20px; inset-inline-end: 20px; z-index: 10600; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.emr-toast {
    background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 23, 42, .15);
    padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px; font-size: .88rem;
    border-inline-start: 4px solid var(--emr-primary); animation: emr-toast-in .22s ease;
}
.emr-toast.success { border-inline-start-color: #16a34a; }
.emr-toast.error { border-inline-start-color: #dc2626; }
.emr-toast.warning { border-inline-start-color: #d97706; }
.emr-toast i.emr-toast-icon { font-size: 1.1rem; margin-top: 2px; }
.emr-toast.success i.emr-toast-icon { color: #16a34a; }
.emr-toast.error i.emr-toast-icon { color: #dc2626; }
.emr-toast.warning i.emr-toast-icon { color: #d97706; }
.emr-toast.info i.emr-toast-icon { color: var(--emr-primary); }
.emr-toast-close { cursor: pointer; color: var(--emr-muted); margin-inline-start: auto; }
@keyframes emr-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.emr-toast.emr-toast-out { animation: emr-toast-out .18s ease forwards; }
@keyframes emr-toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ---- Confirm modal (replaces native confirm()) ---- */
.emr-confirm-icon { width: 52px; height: 52px; border-radius: 50%; background: #fef3c7; color: #d97706; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; }
