/* =========================================================
   TNIS – ortaq tema (açıq / tünd), font və rəng tənzimləmələri
   js/theme.js <html data-theme="light|dark"> və --fs-scale, --font,
   --primary dəyişənlərini təyin edir.
   ========================================================= */

:root,
:root[data-theme="light"] {
    color-scheme: light;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    /* Bütün rənglər --primary-nin tonlarıdır (yalnız success/danger status üçündür) */
    --primary-solid: color-mix(in srgb, var(--primary) 80%, #000);   /* düymə fonu (ağ yazı oxunsun) */
    --primary-strong: color-mix(in srgb, var(--primary) 62%, #000);  /* tünd ton: mətn / vurğu */
    --primary-soft: color-mix(in srgb, var(--primary) 12%, transparent);   /* açıq fon */
    --primary-soft-line: color-mix(in srgb, var(--primary) 28%, transparent);
    --secondary: color-mix(in srgb, var(--primary) 62%, #000);
    --accent: var(--primary-strong);
    --success: #059669;
    --danger: #dc2626;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --chip-text: var(--primary-strong);

    --body-bg: linear-gradient(135deg, #f6f8ff 0%, #eef5ff 45%, #f8f1ff 100%);
    --bg-card: rgba(255, 255, 255, 0.88);
    --bg-dark: #e2e8f0;
    --btn-neutral: #e2e8f0;
    --input-bg: #ffffff;
    --inset-bg: rgba(15, 23, 42, 0.035);
    --backdrop: rgba(15, 23, 42, 0.45);

    --ov: 15, 23, 42;               /* üst-üstə qoyulan şəffaf təbəqələrin rəngi */
    --line: rgba(15, 23, 42, 0.10);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 28px rgba(79, 70, 229, 0.08);
    --radius: 14px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-solid: color-mix(in srgb, var(--primary) 80%, #000);
    --primary-strong: color-mix(in srgb, var(--primary) 55%, #fff);  /* tünd fonda açıq ton */
    --primary-soft: color-mix(in srgb, var(--primary) 20%, transparent);
    --primary-soft-line: color-mix(in srgb, var(--primary) 40%, transparent);
    --secondary: color-mix(in srgb, var(--primary) 62%, #000);
    --accent: var(--primary-strong);
    --success: #059669;
    --danger: #dc2626;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --chip-text: var(--primary-strong);

    --body-bg: radial-gradient(circle at top right, #1e1b4b, #0b1224 70%);
    --bg-card: rgba(30, 41, 59, 0.72);
    --bg-dark: #0f172a;
    --btn-neutral: #334155;
    --input-bg: rgba(0, 0, 0, 0.30);
    --inset-bg: rgba(0, 0, 0, 0.25);
    --backdrop: rgba(0, 0, 0, 0.80);

    --ov: 255, 255, 255;
    --line: rgba(255, 255, 255, 0.10);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ---------- Əsas ---------- */
html { font-size: calc(16px * var(--fs-scale, 1)); -webkit-text-size-adjust: 100%; }
* { font-family: var(--font, 'Inter', system-ui, sans-serif); }
body { background: var(--body-bg); background-attachment: fixed; color: var(--text-main); transition: background .25s, color .25s; }
.timer-badge, code, pre { font-family: ui-monospace, Consolas, monospace; }

.glass { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.navbar.glass { border-radius: var(--radius); }
.nav-logo { letter-spacing: -0.5px; }

/* ---------- Düymələr ---------- */
.btn, .btn-small, .btn-tab, .menu-item, button { transition: transform .15s ease, filter .15s ease, background .2s ease, box-shadow .2s ease; }
.btn:hover, .btn-small:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active, .btn-small:active { transform: translateY(0); }
.btn { border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12); }
.btn-small { border-radius: 8px; }
.btn-primary, .btn-edit { background: var(--primary-solid); color: #fff; }
.btn-success, .btn-add { background: var(--success); }
.btn-danger, .btn-delete { background: var(--danger); }
.badge { border-radius: 999px; padding: 4px 10px; letter-spacing: .3px; }
.btn-tab { background: rgba(var(--ov), 0.06); }
.btn-tab.active, .menu-item.active { background: var(--primary-solid); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.menu-item { background: rgba(var(--ov), 0.04); }
.menu-item:hover { background: rgba(var(--ov), 0.09); }

/* ---------- Giriş sahələri ---------- */
input, select, textarea { border-radius: 10px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text-main); transition: border-color .2s, box-shadow .2s; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
option { background: var(--input-bg); color: var(--text-main); }
:root[data-theme="dark"] option { background: #1e293b; }

/* ---------- Cədvəl və kartlar ---------- */
table thead th { color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; }
table tbody tr { transition: background .15s; }
table tbody tr:hover { background: rgba(var(--ov), 0.04); }
.doctor-card, .monitor-card, .plan-step-box { border-radius: 14px; }
.doctor-card { transition: transform .15s, box-shadow .15s; }
.doctor-card:not(.inactive):hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); }
.modal-card { box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3); }
a { color: var(--accent); }

/* ---------- Skrol ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(var(--ov), 0.25) transparent; }

/* ---------- Tənzimləmə paneli ---------- */
.tn-fab { position: fixed; left: 14px; bottom: 14px; z-index: 3000; width: 46px; height: 46px; padding: 0; border-radius: 50%;
          background: var(--bg-card); color: var(--text-main); border: 1px solid var(--line); box-shadow: var(--shadow);
          font-size: 1.25rem; line-height: 1; cursor: pointer; backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; }
.tn-fab:hover { transform: rotate(30deg); }
.tn-panel { position: fixed; left: 14px; bottom: 70px; z-index: 3000; width: min(320px, calc(100vw - 28px)); padding: 16px;
            background: var(--bg-card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--text-main);
            border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 48px rgba(15, 23, 42, 0.25); display: none; }
:root[data-theme="light"] .tn-panel { background: rgba(255, 255, 255, 0.96); }
.tn-panel.open { display: block; }
.tn-panel h4 { font-size: .95rem; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; }
.tn-row { margin-bottom: 14px; }
.tn-row > label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 6px; font-weight: 700; }
.tn-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: rgba(var(--ov), 0.06); border-radius: 12px; }
.tn-panel button.tn-opt { width: auto; padding: 8px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--text-main); font-size: .8rem; font-weight: 600; cursor: pointer; box-shadow: none; }
.tn-panel button.tn-opt[aria-pressed="true"] { background: var(--primary-solid); color: #fff; }
.tn-size { display: grid; grid-template-columns: 38px 1fr 38px 48px; gap: 8px; align-items: center; }
.tn-panel button.tn-step { width: 38px; height: 34px; padding: 0; border-radius: 9px; border: 1px solid var(--line); background: rgba(var(--ov), 0.05); color: var(--text-main); font-weight: 700; cursor: pointer; box-shadow: none; }
.tn-panel input[type="range"] { width: 100%; padding: 0; background: none; border: 0; box-shadow: none; accent-color: var(--primary); }
.tn-val { font-size: .8rem; font-weight: 700; text-align: right; }
.tn-panel select { margin: 0; padding: 9px 10px; font-size: .85rem; }
.tn-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.tn-panel button.tn-sw { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.tn-panel button.tn-sw[aria-pressed="true"] { border-color: var(--text-main); }
.tn-panel button.tn-reset { width: 100%; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text-muted); font-size: .8rem; font-weight: 600; cursor: pointer; box-shadow: none; }
.tn-panel button.tn-reset:hover { color: var(--text-main); background: rgba(var(--ov), 0.05); }
.tn-panel button.tn-x { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; box-shadow: none; }

/* GPS yazısı mobil paneldə FAB ilə üst-üstə düşməsin */
#gps-status { background: var(--bg-card) !important; border: 1px solid var(--line); }

@media (max-width: 720px) {
    .layout { grid-template-columns: 1fr !important; }
}

/* ---------- Radio / checkbox: tam enə uzanmasın, mətn soldan düzülsün ---------- */
input[type="radio"], input[type="checkbox"] {
    width: 1.05rem; height: 1.05rem; flex: 0 0 auto; padding: 0; margin: 0;
    accent-color: var(--primary); cursor: pointer; box-shadow: none;
}
label { text-align: left; }

.radio-chip { justify-content: flex-start; text-align: left; border: 1px solid var(--line); transition: border-color .15s, background .15s; }
.radio-chip:hover { background: rgba(var(--ov), 0.07); }
.radio-chip:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

.checkbox-list { display: flex; flex-direction: column; gap: 2px; }
.checkbox-list label { justify-content: flex-start; text-align: left; padding: 7px 10px !important; border-radius: 8px; line-height: 1.3; transition: background .15s; }
.checkbox-list label:hover { background: rgba(var(--ov), 0.06); }
.checkbox-list label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.checkbox-list label em { color: var(--text-muted); font-style: normal; font-size: .85em; margin-left: 4px; }

/* 4. Ziyarət növü seçimləri: radio solda, mətn bir qutuda soldan düzülür */
#box-visit-content > div.visit-option { border: 1px solid var(--line); border-radius: 10px; transition: border-color .15s, background .15s; }
#box-visit-content > div.visit-option:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent) !important; }
#box-visit-content label { justify-content: flex-start; text-align: left; font-weight: 600; line-height: 1.35; }


/* ---------- Vahid rəng sistemi: badge, taymer, çip ---------- */
.badge { background: var(--primary-solid); color: #fff; }
.timer-badge { background: var(--primary-soft); color: var(--primary-strong); border: 1px solid var(--primary-soft-line); }
.timer-badge.act-timer { background: var(--primary-solid); color: #fff; border-color: transparent; }
.monitor-card { border-left-color: var(--primary); }
.info-chip { background: var(--primary-soft); color: var(--primary-strong); border: 1px solid var(--primary-soft-line); }
