/* ==========================================================================
   theflyingpeople.com – обща рамка на приложенията
   Учебник, подготовка за изпит, библиотека, формули, наръчник ПВП, SkyBase за инструктори.
   Същите цветове, шрифт, бутони и горна лента като на сайта (assets/css/site.css).
   Поведението (бутон „Приложения“, лента) е в /assets/js/apps.js.
   ========================================================================== */

:root {
    --tf-sky: #3CB4E5; --tf-sky-50: #EEF8FD; --tf-sky-100: #D6EFFA; --tf-sky-600: #1C8DC2;
    --tf-primary: #136F9E; --tf-primary-hover: #0E5A82; --tf-navy: #0B1B33;
    --tf-ink: #0F1B2D; --tf-text: #334155; --tf-muted: #64748B; --tf-line: #E3E9F0; --tf-soft: #F5F8FB;
    --tf-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --tf-r: 12px; --tf-r-lg: 18px; --tf-r-full: 999px;
    --tf-shadow: 0 8px 24px rgba(15, 27, 45, 0.08), 0 2px 6px rgba(15, 27, 45, 0.04);
    --tf-shadow-lg: 0 24px 60px rgba(15, 27, 45, 0.16);
}

/* ---------- цветовете на приложенията → цветовете на марката ---------- */
/* учебник, библиотека, формули */
html.tf-app {
    --primary-color: #136F9E; --primary-dark: #0E5A82; --secondary-color: #0B1B33;
    --text-color: #0F1B2D; --text-light: #64748B; --border-color: #E3E9F0; --bg-light: #F5F8FB;
    --radius-lg: 14px; --radius-xl: 18px;
    --pd: #136F9E; --navy: #0B1B33; --tx: #0F1B2D;
}
/* изпитна система (tfp-theme.css) */
html.tf-app { --tfp-navy: #0B1B33; }
html.tf-app body { font-family: var(--tf-font); }

/* ---------- бутон „Приложения“ и панелът ---------- */
.tf-apps { position: relative; flex: none; font-family: var(--tf-font); }
.tf-apps__btn {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
    border: 1px solid var(--tf-line); border-radius: var(--tf-r-full); background: #fff; color: var(--tf-ink);
    font: 600 14px/1 var(--tf-font); cursor: pointer; transition: border-color .15s, color .15s, background-color .15s;
}
.tf-apps__btn:hover, .tf-apps__btn[aria-expanded="true"] { border-color: var(--tf-sky); color: var(--tf-primary); background: var(--tf-sky-50); }
.tf-a-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tf-apps__panel {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 10060; width: min(560px, calc(100vw - 24px));
    padding: 14px; background: #fff; border: 1px solid var(--tf-line); border-radius: var(--tf-r-lg); box-shadow: var(--tf-shadow-lg);
    text-align: left;
}
.tf-apps__panel[hidden] { display: none; }
.tf-apps__head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; }
.tf-apps__head b { color: var(--tf-ink); font-size: 15px; }
.tf-apps__close { width: 34px; height: 34px; border: 0; background: transparent; border-radius: 50%; color: var(--tf-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tf-apps__close:hover { background: var(--tf-soft); color: var(--tf-ink); }
.tf-apps__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tf-apps__item { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-radius: var(--tf-r); text-decoration: none; color: var(--tf-ink); }
.tf-apps__item:hover { background: var(--tf-sky-50); }
.tf-apps__item.is-current { background: var(--tf-sky-50); box-shadow: inset 0 0 0 1px var(--tf-sky-100); }
.tf-apps__ico { width: 38px; height: 38px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--tf-sky-50); color: var(--tf-primary); }
.tf-apps__item.is-current .tf-apps__ico { background: var(--tf-primary); color: #fff; }
.tf-apps__item b { display: block; font: 600 14px/1.3 var(--tf-font); }
.tf-apps__item small { display: block; margin-top: 2px; color: var(--tf-muted); font: 400 12px/1.4 var(--tf-font); }
.tf-apps__site { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; padding: 12px; border-top: 1px solid var(--tf-line); color: var(--tf-primary); font: 600 14px/1 var(--tf-font); text-decoration: none; }
.tf-apps__site:hover { color: var(--tf-primary-hover); }
@media (max-width: 640px) {
    .tf-apps__btn span { display: none; }
    .tf-apps__btn { width: 40px; padding: 0; justify-content: center; }
    .tf-apps__panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; max-height: calc(100vh - 80px); overflow-y: auto; }
    .tf-apps__grid { grid-template-columns: 1fr; }
}

/* ---------- обща лента (за приложения без своя) ---------- */
.tf-appbar {
    position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 14px; height: 64px; width: 100%; box-sizing: border-box; margin: 0;
    padding: 0 max(16px, calc((100vw - 1200px) / 2)); background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--tf-line); font-family: var(--tf-font);
}
.tf-appbar__brand { display: flex; align-items: center; gap: 8px; text-decoration: none; flex: none; }
.tf-appbar__brand img { width: 36px; height: 36px; object-fit: contain; }
.tf-appbar__brand span { font: 700 1.45rem/1 'Caveat', cursive; color: var(--tf-primary); white-space: nowrap; }
.tf-appbar__sep { width: 1px; height: 26px; background: var(--tf-line); flex: none; }
.tf-appbar__title { color: var(--tf-ink); font: 600 15px/1.2 var(--tf-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tf-appbar__fill { flex: 1; }
.tf-appbar__site {
    display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px; flex: none;
    border-radius: var(--tf-r-full); background: var(--tf-primary); color: #fff; text-decoration: none; font: 600 14px/1 var(--tf-font);
}
.tf-appbar__site:hover { background: var(--tf-primary-hover); }
@media (max-width: 640px) {
    .tf-appbar { gap: 10px; padding: 0 12px; }
    .tf-appbar__brand span, .tf-appbar__sep { display: none; }
    .tf-appbar__site span { display: none; }
    .tf-appbar__site { width: 40px; padding: 0; justify-content: center; }
}

/* ---------- съществуващите ленти на приложенията – в един вид ---------- */
/* SkyBase за инструктори */
html.tf-app .topbar { font-family: var(--tf-font); min-height: 64px; padding-top: 8px !important; padding-bottom: 8px !important; }
html.tf-app .topbar .brand img { height: 40px !important; animation: none !important; filter: none !important; }
html.tf-app .topbar .brand span { font-size: 1.45rem !important; text-shadow: none !important; color: var(--tf-primary); }
html.tf-app .topbar-title strong { color: var(--tf-ink) !important; font-weight: 600; }
/* изпитна система */
html.tf-app .tfp-brandbar { font-family: var(--tf-font); min-height: 64px; border-bottom: 1px solid var(--tf-line); }
html.tf-app .tfp-brandbar .tfp-brand span { color: var(--tf-primary); }
html.tf-app .tfp-brandbar .tfp-links a { border-radius: var(--tf-r-full) !important; }
html.tf-app .tfp-brandbar .tfp-links a.primary { background: var(--tf-primary) !important; border-color: var(--tf-primary) !important; color: #fff !important; }
/* учебник */
html.tf-app .main-header .header-brand-name { color: var(--tf-primary); }
html.tf-app .main-header .header-back-btn,
html.tf-app .main-header .header-instructor-btn { border-radius: var(--tf-r-full) !important; }
html.tf-app .main-header .header-back-btn { background: var(--tf-primary) !important; border-color: var(--tf-primary) !important; color: #fff !important; }
/* „Формули“ и „Лекции“ (SkyBase) вече са в панела „Приложения“ – без дублиращи бутони в лентата на учебника */
html.tf-app .main-header #formulasBtn, html.tf-app .main-header .header-instructor-btn { display: none !important; }
html.tf-app .main-header .header-glossary-btn { border-radius: var(--tf-r-full) !important; }

/* „Формули“: бутонът за печат – в заглавната част */
.tf-print { margin: 14px 0 0; }
.tf-print button {
    display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: var(--tf-r-full);
    border: 1px solid var(--tf-line); background: #fff; color: var(--tf-primary); font: 600 14px/1 var(--tf-font); cursor: pointer;
}
.tf-print button:hover { border-color: var(--tf-primary); }
@media print { .tf-appbar, .tf-print, .tf-apps { display: none !important; } }

/* SkyBase – вход и съобщения: лентата е отгоре, формата – в средата */
html.tf-app body:has(> .tf-appbar) { display: block !important; padding: 0 !important; }
html.tf-app body:has(> .tf-appbar) > .box { margin: 48px auto; max-width: 440px; border-radius: var(--tf-r-lg); box-shadow: var(--tf-shadow); }
html.tf-app body:has(> .tf-appbar) > .box button[type="submit"] { background: var(--tf-primary); border-radius: var(--tf-r-full); }
html.tf-app body:has(> .tf-appbar) > .box h1 { color: var(--tf-ink); }
