/* ============ GymTrack – основен стил ============ */
:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-2: #64748b;
    --primary: #059669;
    --primary-dark: #047857;
    --primary-soft: #ecfdf5;
    --green: #16a34a;
    --green-soft: #f0fdf4;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --amber: #d97706;
    --amber-soft: #fffbeb;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.page-sub { color: var(--text-2); margin: 0 0 20px; }

/* ---------- Topbar ---------- */
.topbar {
    background: #0f172a;
    color: #fff;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    min-height: 56px;
}
.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a {
    color: #cbd5e1;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 500;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.mainnav a.active { color: #fff; background: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
/* Бутони към основния сайт и към другото приложение (в хедъра) */
.app-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-links .btn { white-space: nowrap; }
@media (max-width: 820px) {
    .topbar-right { gap: 10px; flex-wrap: wrap; }
    .app-links .btn { padding: 4px 9px; font-size: .8rem; }
}
.userbox { color: #e2e8f0; font-size: .9rem; }
.userbox small { color: #94a3b8; }
.lang-switch a { color: #94a3b8; font-weight: 600; font-size: .85rem; }
.lang-switch a.active { color: #fff; }
.lang-switch .sep { color: #475569; margin: 0 4px; }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 24px auto; padding: 0 20px; min-height: calc(100vh - 170px); }
.footer { text-align: center; color: var(--text-2); font-size: .85rem; padding: 20px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-tight { padding: 14px 16px; margin-bottom: 0; }

/* ---------- Stat tiles ---------- */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.stat .stat-label { color: var(--text-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.stat .stat-value small { font-size: .9rem; font-weight: 500; color: var(--text-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: #f8fafc; }
.tbl tr:hover td { background: #f8fafc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-gray { background: #f1f5f9; color: var(--text-2); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=url], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 0;
    border-color: var(--primary);
}
textarea { min-height: 90px; resize: vertical; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.form-row > div { flex: 1; min-width: 140px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }
.hint { color: var(--text-2); font-size: .82rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: .85rem; }
.btn-outline { background: transparent; border-color: #64748b; color: inherit; }
.btn-outline:hover { background: rgba(100,116,139,.12); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-light { background: #f1f5f9; color: var(--text); }
.btn-light:hover { background: #e2e8f0; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--green-soft); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-soft); color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #bfdbfe; }

/* ---------- Login ---------- */
.login-wrap { max-width: 400px; margin: 8vh auto; }
.login-logo { text-align: center; font-size: 2.4rem; margin-bottom: 8px; }
.login-wrap h1 { text-align: center; }
.login-wrap .page-sub { text-align: center; }
.demo-accounts { font-size: .82rem; color: var(--text-2); margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.demo-accounts code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; }

/* ---------- Schedule ---------- */
.week-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.week-nav .range { font-weight: 700; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
@media (max-width: 1000px) { .week-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .week-grid { grid-template-columns: 1fr; } }
.day-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 110px; }
.day-col.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.day-col .day-head { font-weight: 700; font-size: .85rem; margin-bottom: 8px; }
.day-col .day-head small { display: block; color: var(--text-2); font-weight: 400; }
.session {
    border-radius: 8px;
    padding: 6px 8px;
    font-size: .82rem;
    margin-bottom: 6px;
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
}
.session.done { background: var(--green-soft); border-left-color: var(--green); }
.session.missed { background: var(--red-soft); border-left-color: var(--red); }
.session.cancelled { background: #f1f5f9; border-left-color: #94a3b8; color: var(--text-2); text-decoration: line-through; }
.session .s-time { font-weight: 700; }

/* ---------- Workout log ---------- */
.exercise-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; background: #fbfcfd; }
.exercise-block .ex-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.exercise-block .ex-head h3 { margin: 0; }
.sets-table { width: 100%; border-collapse: collapse; }
.sets-table th, .sets-table td { padding: 4px 6px; text-align: center; }
.sets-table th { font-size: .75rem; text-transform: uppercase; color: var(--text-2); }
.sets-table input { max-width: 110px; text-align: center; margin: 0 auto; font-size: 16px; padding: 10px 8px; }
.sets-table td.set-no { font-weight: 700; color: var(--primary); }
.ex-foot { display: flex; align-items: center; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.rir-inline { display: flex; align-items: center; gap: 8px; }
.rir-inline label { margin: 0; font-size: .82rem; color: var(--text-2); }
.rir-inline input { width: 70px; text-align: center; }
.last-perf {
    margin: 0 0 10px; font-size: .85rem; color: var(--text-2);
    background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px;
}
@media (max-width: 640px) {
    .sets-table input { max-width: none; width: 100%; }
    .sets-table th, .sets-table td { padding: 6px 3px; }
    .exercise-block { padding: 12px 10px; }
}

/* ---------- Misc ---------- */
.review-box { background: var(--amber-soft); border: 1px solid #fde68a; border-radius: 8px; padding: 12px 14px; margin-top: 10px; }
.comment-box { background: var(--primary-soft); border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px 14px; margin-top: 10px; }
.dossier-note { border-left: 3px solid var(--primary); padding: 10px 14px; background: #fbfcfd; border-radius: 0 8px 8px 0; margin-bottom: 12px; }
.dossier-note .d-date { font-size: .8rem; color: var(--text-2); font-weight: 600; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters > div { min-width: 130px; }
.chart-box { position: relative; height: 300px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.text-muted { color: var(--text-2); }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }


/* ---------- NutriTrack специфични ---------- */
.thumb { width: 100%; height: 160px; object-fit: cover; border-radius: 10px 10px 0 0; display: block; }
.thumb-ph { display: flex; align-items: center; justify-content: center; font-size: 3rem;
            background: linear-gradient(135deg, #ecfdf5, #d1fae5); color: #059669; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.rcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
         box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.rcard .rcard-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.rcard h3 { margin: 0; font-size: 1rem; }
.rcard .macros { margin-top: auto; }
.macro-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.chip-kcal { background: #ecfdf5; color: #047857; }
.chip-p { background: #eff6ff; color: #1e40af; }
.chip-c { background: #fffbeb; color: #b45309; }
.chip-f { background: #fdf2f8; color: #be185d; }

/* Прогрес барове за макро цели */
.pbar { margin-bottom: 12px; }
.pbar .pbar-head { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 4px; }
.pbar .pbar-head .pv { font-variant-numeric: tabular-nums; color: var(--text-2); }
.pbar .pbar-track { height: 10px; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.pbar .pbar-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s; }
.pbar .pbar-fill.over { background: #dc2626; }
.pbar.pb-p .pbar-fill { background: #2a78d6; }
.pbar.pb-c .pbar-fill { background: #eda100; }
.pbar.pb-f .pbar-fill { background: #e34948; }
.pbar.pb-p .pbar-fill.over, .pbar.pb-c .pbar-fill.over, .pbar.pb-f .pbar-fill.over { background: #dc2626; }

/* Блог */
.blog-hero { background: linear-gradient(135deg, #064e3b, #059669); color: #fff; border-radius: 14px;
             padding: 40px 32px; margin-bottom: 24px; }
.blog-hero h1 { font-size: 1.9rem; margin: 0 0 6px; }
.blog-hero p { color: #d1fae5; margin: 0 0 16px; max-width: 640px; }
.article-body { max-width: 760px; line-height: 1.7; }
.article-body p { margin: 0 0 14px; }
.meal-block { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.meal-block .meal-head { background: #f8fafc; padding: 8px 14px; font-weight: 700; font-size: .9rem;
                         display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); }
.meal-block .meal-head .mh-kcal { color: var(--text-2); font-weight: 600; }
.live-macros { font-size: .9rem; background: var(--primary-soft); border: 1px solid #a7f3d0;
               border-radius: 8px; padding: 8px 12px; margin-top: 8px; display: none; }

/* ---------- Седмичен режим (треньор ↔ клиент) ---------- */
.dossier-note-edit {
    outline: 2px solid var(--primary);
    outline-offset: 2px; border-radius: 8px;
}

.plan-week { display: grid; gap: 14px; }
.plan-day { padding: 16px 18px; }
.plan-day.plan-today { border-color: var(--green, #059669); box-shadow: 0 0 0 1px var(--green, #059669); }
.plan-day-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.plan-day-head h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.plan-day-tot { font-size: .92rem; white-space: nowrap; }
.plan-meal { margin-top: 10px; }
.plan-meal-name {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
    font-weight: 700; opacity: .6; margin-bottom: 4px;
}
.plan-row {
    display: flex; align-items: center; gap: 12px;
    padding: 7px 0; border-bottom: 1px solid rgba(148, 163, 184, .25);
}
.plan-row:last-child { border-bottom: 0; }
.plan-row-main { flex: 1; min-width: 0; }
.plan-row-main .muted { margin-left: 8px; font-size: .88rem; }
.plan-x { font-size: 1.3rem; line-height: 1; text-decoration: none; opacity: .45; padding: 0 6px; }
.plan-x:hover { opacity: 1; color: #dc2626; }
.plan-done { font-size: .88rem; color: #059669; font-weight: 600; white-space: nowrap; }
.plan-copy {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 12px; padding-top: 10px; border-top: 1px dashed rgba(148, 163, 184, .4);
}
.plan-copy select { padding: 5px 8px; }

.plan-actions { text-align: right; white-space: nowrap; }

@media (min-width: 900px) {
    .plan-week { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .plan-actions { display: flex; flex-direction: column; gap: 6px; }
    .tbl-clients .col-sec { display: none; }
    .plan-day-tot { white-space: normal; }
    .plan-row { flex-wrap: wrap; align-items: flex-start; gap: 4px 10px; }
    .plan-row-main { flex: 1 0 100%; }
    .plan-row-main .muted { margin-left: 0; display: block; }
    .plan-row { position: relative; }
    .plan-row > form,
    .plan-row > .plan-done { flex: 0 0 auto; }
    .plan-row > .plan-x { position: absolute; top: 4px; right: 0; }
    .plan-row-main { padding-right: 26px; }
}
