/* ===== Teme ===== */
:root,
[data-bs-theme="light"] {
    --app-bg: #f4f6f5;
    --app-card: #ffffff;
    --app-border: rgba(15, 23, 42, .07);
    --app-muted-bg: #eef2f1;
    --app-teal: #0d9488;
    --app-teal-soft: #ccfbf1;
    --app-water: #0ea5e9;
    --app-water-soft: #e0f2fe;
    --app-meal: #f97316;
    --app-meal-soft: #ffedd5;
    --app-workout: #8b5cf6;
    --app-workout-soft: #ede9fe;
    --app-weight-soft: #ccfbf1;
    --bs-primary: #0d9488;
    --bs-primary-rgb: 13, 148, 136;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --nav-h: 68px;
}

[data-bs-theme="dark"] {
    --app-bg: #0f1413;
    --app-card: #182120;
    --app-border: rgba(255, 255, 255, .07);
    --app-muted-bg: #1f2a29;
    --app-teal-soft: rgba(45, 212, 191, .15);
    --app-water-soft: rgba(56, 189, 248, .15);
    --app-meal-soft: rgba(251, 146, 60, .15);
    --app-workout-soft: rgba(167, 139, 250, .15);
    --app-weight-soft: rgba(45, 212, 191, .15);
    --bs-link-color: #2dd4bf;
    --bs-link-color-rgb: 45, 212, 191;
}

body {
    background: var(--app-bg);
    -webkit-tap-highlight-color: transparent;
}

.container-app {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}

.auth-main {
    padding-top: 48px;
    padding-bottom: 48px;
    max-width: 440px;
}

/* ===== Dugmad ===== */
.btn-primary {
    --bs-btn-bg: var(--app-teal);
    --bs-btn-border-color: var(--app-teal);
    --bs-btn-hover-bg: #0f766e;
    --bs-btn-hover-border-color: #0f766e;
    --bs-btn-active-bg: #115e59;
    --bs-btn-active-border-color: #115e59;
    --bs-btn-disabled-bg: var(--app-teal);
    --bs-btn-disabled-border-color: var(--app-teal);
    font-weight: 600;
}

.btn-lg { border-radius: 14px; }

.btn-icon {
    border: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: inherit;
}

.btn-icon:hover { background: var(--app-muted-bg); }
.btn-sm.btn-icon { width: 32px; height: 32px; }

.btn-water {
    white-space: nowrap;
    padding-left: .5rem;
    padding-right: .5rem;
    background: var(--app-water-soft);
    color: var(--app-water);
    border: 0;
    font-weight: 600;
    border-radius: 12px;
}

.btn-water:hover, .btn-water:active { background: var(--app-water); color: #fff; }

.btn-chip {
    border: 1px solid var(--app-border);
    background: var(--app-card);
    border-radius: 999px;
    padding: .4rem .9rem;
    font-weight: 500;
    white-space: nowrap;
}

.btn-check:checked + .btn-chip,
.btn-chip.active {
    background: var(--app-teal);
    border-color: var(--app-teal);
    color: #fff;
}

.chip-group { display: flex; flex-wrap: wrap; gap: .5rem; }

.chip-scroll {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 0 16px;
}

.chip-scroll::-webkit-scrollbar { display: none; }

.type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem;
}

.btn-type {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .65rem .15rem;
    border: 1px solid var(--app-border);
    background: var(--app-card);
    border-radius: 14px;
    font-size: .78rem;
    line-height: 1.15;
    font-weight: 500;
}

.btn-type i { font-size: 1.4rem; color: var(--app-workout); }

.btn-check:checked + .btn-type {
    border-color: var(--app-workout);
    background: var(--app-workout-soft);
    box-shadow: inset 0 0 0 1px var(--app-workout);
}

/* ===== Kartice i naslovi ===== */
.card-soft {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.page-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
    min-height: 48px;
}

.page-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.section-title { font-size: 1rem; font-weight: 700; margin: 0 0 .5rem .25rem; }

.card-kicker {
    font-size: .8rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-big { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.stat-big small { font-size: 1rem; font-weight: 500; color: var(--bs-secondary-color); }

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.avatar {
    --avatar: var(--app-teal);
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--avatar);
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }
.min-w-0 { min-width: 0; }

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--bs-secondary-color);
    border: 2px dashed var(--app-border);
    border-radius: 20px;
}

.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; }
.empty-state p { margin: 0; }

.toast-flash { border-radius: 14px; }

/* ===== Voda ===== */
.water-ring {
    --pct: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(var(--app-water) calc(var(--pct) * 1%), var(--app-water-soft) 0);
    display: grid;
    place-items: center;
}

.water-ring span {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--app-card);
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
}

.progress-water { height: 6px; background: var(--app-water-soft); }
.progress-water .progress-bar { background: var(--app-water); }

.water-list {
    list-style: none;
    margin: 0;
    padding: 0 1rem .5rem 4rem;
}

.water-list li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .25rem 0;
    font-size: .9rem;
}

.card-water .water-day { border-radius: 14px; background: var(--app-muted-bg); }
.card-water .water-day summary { padding: .6rem .75rem; }
.card-water .water-day .entry-icon { display: none; }
.card-water .water-list { padding-left: .75rem; }

/* ===== Unosi (vremenska linija) ===== */
.day { margin-bottom: 1.25rem; }
.day-title { font-size: .95rem; font-weight: 700; margin: 0 0 .5rem .25rem; }

.entries > .entry + .entry { border-top: 1px solid var(--app-border); }

.entry {
    display: flex;
    gap: .75rem;
    padding: .85rem 1rem;
    color: inherit;
    text-decoration: none;
}

a.entry:hover { background: var(--app-muted-bg); }
.entries > .entry:first-child { border-top-left-radius: 20px; border-top-right-radius: 20px; }
.entries > .entry:last-child { border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; }

.water-day { display: block; padding: 0; }
.water-day summary { display: flex; gap: .75rem; padding: .85rem 1rem; list-style: none; cursor: pointer; }
.water-day summary::-webkit-details-marker { display: none; }
.water-day[open] .entry-chevron { transform: rotate(180deg); }

.entry-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

.entry-tezina .entry-icon { background: var(--app-weight-soft); color: var(--app-teal); }
.entry-obroci .entry-icon { background: var(--app-meal-soft); color: var(--app-meal); }
.entry-trening .entry-icon { background: var(--app-workout-soft); color: var(--app-workout); }
.entry-water .entry-icon { background: var(--app-water-soft); color: var(--app-water); }

.entry-body { flex: 1; min-width: 0; }
.entry-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.entry-title { font-weight: 600; }
.entry-time { font-size: .85rem; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.entry-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .75rem;
    font-size: .875rem;
    color: var(--bs-secondary-color);
    margin-top: .1rem;
}

.intensity { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }
.intensity::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.intensity-lako { color: #16a34a; }
.intensity-srednje { color: #d97706; }
.intensity-jako { color: #dc2626; }

.entry-text { font-size: .9rem; color: var(--bs-secondary-color); margin-top: .1rem; overflow-wrap: anywhere; }
.entry-chevron { align-self: center; color: var(--bs-tertiary-color); transition: transform .2s; }

.thumbs { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; }

/* ===== Porodica ===== */
.member-card { color: inherit; text-decoration: none; transition: transform .1s; }
.member-card:active { transform: scale(.99); }

.member-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1rem;
    margin-top: .75rem;
    font-size: .85rem;
    color: var(--bs-secondary-color);
}

.member-stats:empty { display: none; }

/* ===== Forme ===== */
.form-label { font-weight: 600; }

.form-control, .form-select, .input-group-text { border-radius: 12px; }
.form-control-lg { border-radius: 14px; }

.big-number-input {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: .5rem;
}

.big-number-input input {
    width: 5.5ch;
    font-size: 3rem;
    font-weight: 800;
    text-align: center;
    border: 0;
    border-bottom: 3px solid var(--app-border);
    background: transparent;
    color: inherit;
    padding: 0;
    letter-spacing: -.03em;
    -moz-appearance: textfield;
}

.big-number-input input::-webkit-outer-spin-button,
.big-number-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.big-number-input input:focus { outline: none; border-bottom-color: var(--app-teal); }
.big-number-input span { font-size: 1.25rem; color: var(--bs-secondary-color); font-weight: 600; }

.form-actions { margin-top: .5rem; }

/* Slike */
.photo-grid { display: grid; gap: .5rem; grid-template-columns: repeat(5, 1fr); }
.photo-grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 420px) {
    .photo-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

.photo-slot { position: relative; }

.photo-tile {
    position: relative;
    display: block;
    aspect-ratio: 1;
    border-radius: 14px;
    border: 2px dashed var(--bs-border-color);
    background: var(--app-muted-bg);
    overflow: hidden;
    cursor: pointer;
    margin: 0;
}

.photo-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.photo-empty {
    position: absolute;
    inset: 0 0 1.1rem;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    color: var(--bs-secondary-color);
}

.photo-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: .3rem;
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
}

.photo-slot.has-photo .photo-tile { border-style: solid; border-color: transparent; }
.photo-slot.has-photo .photo-empty { display: none; }

.photo-slot.has-photo .photo-label {
    bottom: 0;
    padding: .15rem 0;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}

.photo-slot.is-loading .photo-tile::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%230d9488' stroke-width='3' stroke-dasharray='40 20'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center no-repeat;
}

.photo-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--app-card);
    background: #ef4444;
    color: #fff;
    font-size: .7rem;
    display: none;
    place-items: center;
    padding: 0;
}

.photo-slot.has-photo .photo-remove { display: grid; }

/* ===== Grafikon ===== */
.chart-wrap { position: relative; }

/* ===== Donja navigacija ===== */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--app-card) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--app-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav a {
    flex: 1;
    max-width: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: .7rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    text-decoration: none;
}

.bottom-nav a i { font-size: 1.35rem; }
.bottom-nav a.active { color: var(--app-teal); }

.nav-add {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    border: 0;
    background: var(--app-teal);
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 6px 16px rgba(13, 148, 136, .35);
    margin-top: -22px;
    transition: transform .15s;
}

.nav-add:active { transform: scale(.94); }

/* Meni "+" */
.add-sheet {
    height: auto !important;
    border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    max-width: 640px;
    margin: 0 auto;
}

.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.add-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: 1.25rem .5rem;
    border-radius: 18px;
    font-weight: 700;
    text-decoration: none;
    transition: transform .1s;
}

.add-tile i { font-size: 1.9rem; }
.add-tile:active { transform: scale(.97); }
.tile-weight { background: var(--app-weight-soft); color: var(--app-teal); }
.tile-meal { background: var(--app-meal-soft); color: var(--app-meal); }
.tile-water { background: var(--app-water-soft); color: var(--app-water); }
.tile-workout { background: var(--app-workout-soft); color: var(--app-workout); }

/* ===== Filter (segmentirana kontrola) ===== */
.segmented {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 4px;
    padding: 4px;
    background: var(--app-muted-bg);
    border-radius: 16px;
}

.segmented a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: .45rem .1rem;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    text-decoration: none;
    min-width: 0;
}

.segmented a i { font-size: 1.1rem; }
.segmented a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.segmented a.active {
    background: var(--app-card);
    color: var(--app-teal);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}

/* ===== Prekidaci u boji aplikacije ===== */
.form-check-input:checked { background-color: var(--app-teal); border-color: var(--app-teal); }
.form-check-input:focus { border-color: var(--app-teal); box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .2); }
.form-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");
}
.form-control:focus, .form-select:focus { border-color: var(--app-teal); box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .15); }
.card-soft { overflow: hidden; }
.card-soft.entries { overflow: visible; }

/* ===== Uski ekrani ===== */
@media (max-width: 380px) {
    .container-app { padding-left: 12px; padding-right: 12px; }
    .stat-big { font-size: 1.75rem; }
    .page-title { font-size: 1.35rem; }
    .entry:not(.water-day), .water-day summary { padding: .75rem .85rem; gap: .65rem; }
    .entry-icon { width: 36px; height: 36px; font-size: 1.05rem; }
}
