/* =====================================================================
   Alphacare Human Physiology — Stylesheet
   Theme: light red + white, fitness style, dark-mode capable
   ===================================================================== */

:root {
    --red:        #e63946;
    --red-dark:   #c1121f;
    --red-soft:   #ffe5e7;
    --red-tint:   #fff4f5;
    --white:      #ffffff;
    --bg:         #f7f7f9;
    --surface:    #ffffff;
    --text:       #1d2129;
    --text-soft:  #5a6472;
    --border:     #e7e9ee;
    --shadow:     0 4px 20px rgba(30,40,60,0.07);
    --shadow-lg:  0 10px 40px rgba(30,40,60,0.12);
    --radius:     14px;
    --radius-sm:  9px;
    --font:       'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

html.dark {
    --red:        #ff5d6a;
    --red-dark:   #ff7b85;
    --red-soft:   #3a1f24;
    --red-tint:   #241417;
    --white:      #1a1d24;
    --bg:         #12141a;
    --surface:    #1c1f27;
    --text:       #eef0f4;
    --text-soft:  #9aa3b2;
    --border:     #2c313c;
    --shadow:     0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg:  0 10px 40px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 3px solid var(--red);
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 50;
}
.header-inner {
    max-width: 1180px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 42px; width: auto; }
.brand-text { font-size: 1.15rem; letter-spacing: .3px; }
.brand-text strong { color: var(--red); }
.header-user { display: flex; align-items: center; gap: 14px; }
.user-chip {
    font-size: .85rem; color: var(--text-soft);
    background: var(--red-tint); padding: 6px 12px; border-radius: 20px;
}
.btn-logout {
    font-size: .85rem; color: var(--white);
    background: var(--red); padding: 7px 16px; border-radius: 20px;
}
.btn-logout:hover { background: var(--red-dark); text-decoration: none; }

/* ---------- Panel tab nav ---------- */
.panel-nav {
    max-width: 1180px; margin: 0 auto;
    display: flex; flex-wrap: wrap; gap: 4px;
    padding: 0 22px 0;
    border-top: 1px solid var(--border);
}
.panel-nav a {
    padding: 13px 18px; color: var(--text-soft);
    font-size: .92rem; font-weight: 600;
    border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.panel-nav a:hover { color: var(--red); text-decoration: none; }
.panel-nav a.active { color: var(--red); border-bottom-color: var(--red); }

/* ---------- Main ---------- */
.site-main {
    flex: 1; width: 100%; max-width: 1180px;
    margin: 0 auto; padding: 28px 22px;
}

/* ---------- Footer ---------- */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
.footer-inner {
    max-width: 1180px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; padding: 22px;
    font-size: .85rem; color: var(--text-soft);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
    background: var(--red-tint); border: 1px solid var(--border);
    color: var(--text); border-radius: 22px; cursor: pointer;
    padding: 8px 16px; font-size: .85rem; font-weight: 600;
}
.theme-toggle:hover { border-color: var(--red); }
.toggle-dark { display: none; }
html.dark .toggle-light { display: none; }
html.dark .toggle-dark { display: inline; }
.theme-toggle-floating {
    position: fixed; bottom: 22px; right: 22px; box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-block; border: none; cursor: pointer;
    padding: 11px 20px; border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 600; font-family: var(--font);
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); text-decoration: none; }
.btn-secondary { background: var(--red-tint); color: var(--red); border: 1px solid var(--red-soft); }
.btn-secondary:hover { background: var(--red-soft); text-decoration: none; }
.btn-danger { background: #fff; color: var(--red-dark); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; text-decoration: none; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 7px 13px; font-size: .82rem; }

/* ---------- Login ---------- */
.login-body {
    background: linear-gradient(135deg, var(--red-tint) 0%, var(--bg) 60%);
    display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 38px 32px;
    border-top: 5px solid var(--red); text-align: center;
}
.login-logo { height: 64px; margin-bottom: 16px; }
.login-title { font-size: 1.4rem; margin: 0 0 4px; }
.login-title span { color: var(--red); font-weight: 600; }
.login-sub { color: var(--text-soft); font-size: .9rem; margin: 0 0 24px; }
.login-form { text-align: left; }
.login-form label, .form label {
    display: block; font-size: .85rem; font-weight: 600;
    color: var(--text-soft); margin-bottom: 14px;
}
.login-form input, .form input, .form select, .form textarea {
    display: block; width: 100%; margin-top: 6px;
    padding: 12px 14px; font-size: 1rem; font-family: var(--font);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--white); color: var(--text);
}
.login-form input:focus, .form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}
.login-form button { margin-top: 8px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .9rem; }
.alert-error   { background: var(--red-soft); color: var(--red-dark); }
.alert-success { background: #e6f6ec; color: #1a7f43; }
html.dark .alert-success { background: #15301f; color: #5fd98a; }

/* ---------- Cards & sections ---------- */
.card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px; margin-bottom: 22px;
    border: 1px solid var(--border);
}
.card h2, .section-title {
    margin: 0 0 16px; font-size: 1.1rem;
    display: flex; align-items: center; gap: 8px;
}
.section-title::before {
    content: ''; width: 4px; height: 18px;
    background: var(--red); border-radius: 2px;
}
.page-title { font-size: 1.5rem; margin: 0 0 20px; }
.muted { color: var(--text-soft); }

/* ---------- Forms layout ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px){ .form-grid { grid-template-columns: 1fr; } }
.form-actions { margin-top: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.required-star { color: var(--red); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
    text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border);
}
table.data th { color: var(--text-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
table.data tr:hover td { background: var(--red-tint); }
.avatar-sm { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; vertical-align: middle; }

/* ---------- Search bar ---------- */
.toolbar {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
    margin-bottom: 18px;
}
.toolbar input[type=text] {
    flex: 1; min-width: 200px; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
}

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span {
    padding: 7px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); font-size: .85rem;
}
.pager a:hover { border-color: var(--red); text-decoration: none; }
.pager .cur { background: var(--red); color: #fff; border-color: var(--red); }

/* ---------- Metric cards (client page) ---------- */
.metric-grid {
    display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr));
    gap: 14px; margin-bottom: 8px;
}
.metric-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    border-left: 4px solid var(--red);
}
.metric-label { font-size: .78rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; }
.metric-value { font-size: 1.7rem; font-weight: 700; margin: 4px 0 0; }
.metric-unit { font-size: .85rem; color: var(--text-soft); font-weight: 400; }
.metric-stale { color: var(--red); font-size: .72rem; margin-top: 4px; }

/* ---------- Client hero ---------- */
.client-hero {
    display: flex; align-items: center; gap: 22px;
    background: linear-gradient(120deg, var(--red-tint), var(--surface));
    border-radius: var(--radius); padding: 24px; margin-bottom: 22px;
    border: 1px solid var(--border);
}
.client-hero img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--red); }
.client-hero h1 { margin: 0 0 4px; font-size: 1.5rem; }
.hero-meta { color: var(--text-soft); font-size: .92rem; }

/* ---------- Misc ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
    padding: 6px 13px; border-radius: 18px; font-size: .82rem; font-weight: 600;
    border: 1px solid var(--border); cursor: pointer; user-select: none;
    background: var(--surface);
}
.chip.off { opacity: .4; text-decoration: line-through; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-pending { background: #fff3cd; color: #8a6d1b; }
.badge-approved{ background: #e6f6ec; color: #1a7f43; }
.badge-denied  { background: var(--red-soft); color: var(--red-dark); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-soft); }
.measure-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 10px; }
.measure-box { background: var(--red-tint); border-radius: var(--radius-sm); padding: 10px 12px; }
.measure-box .ml { font-size: .72rem; color: var(--text-soft); }
.measure-box .mv { font-size: 1.05rem; font-weight: 700; }

/* ---------- Anthropometric carousel + 3D viewer ---------- */
.carousel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 14px;
}
.carousel-title { text-align: center; font-weight: 700; font-size: 1.05rem; }
.carousel-title .muted { font-weight: 400; font-size: .85rem; }
.carousel-arrow {
    background: var(--red-tint); border: 1px solid var(--border);
    color: var(--red); width: 44px; height: 44px; border-radius: 50%;
    font-size: 1.6rem; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.carousel-arrow:hover:not(:disabled) { background: var(--red); color: #fff; border-color: var(--red); }
.carousel-arrow:disabled { cursor: default; }
.anthro-viewer {
    position: relative; width: 100%; height: 420px;
    background: linear-gradient(160deg, var(--red-tint), var(--surface));
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; touch-action: pan-y;
}
.anthro-viewer canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.anthro-viewer canvas:active { cursor: grabbing; }
.viewer-empty {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; color: var(--text-soft); font-size: .95rem; text-align: center; padding: 20px;
}
.viewer-hint {
    position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
    font-size: .72rem; color: var(--text-soft); pointer-events: none;
}
