/* ============================================================
   app.css — Stilovi za Zoo vrt Rezervacije
   Organizacija:
     1. CSS promenljive (boje, razmaci)
     2. Reset i osnova
     3. Login ekran
     4. Topbar (zaglavlje)
     5. Navigacija (mobile bottom nav + desktop tabovi)
     6. Layout (wrapper, view)
     7. Card (bela kutija)
     8. Kalendar
     9. Nedeljni prikaz
    10. Lista rezervacija (ri = rezervacija item)
    11. Detail modal
    12. Forma za dodavanje
    13. Pretraga
    14. Dugmad i badge-ovi
    15. Toast obaveštenja
    16. Spinner (loading)
    17. Print stilovi
   ============================================================ */


/* ── 1. CSS PROMENLJIVE ──────────────────────────────────── */
:root {
    /* Zelena — primarna boja */
    --green:        #1a9e74;
    --green-dark:   #0f6e52;
    --green-light:  #e0f5ee;
    --green-text:   #0d5c44;

    /* Ostale boje */
    --amber:        #b87415;
    --amber-light:  #faeeda;
    --red:          #a22c2c;
    --red-light:    #fceaea;

    /* Pozadine */
    --bg:           #f4f2eb;
    --card:         #ffffff;

    /* Borderi */
    --border:       #e8e6df;
    --border-dark:  #d0cec6;

    /* Tekst */
    --text-1:       #1e1d1b;   /* primarni */
    --text-2:       #5c5b57;   /* sekundarni */
    --text-3:       #928f8a;   /* muted / placeholder */

    /* Zaobljeni uglovi */
    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    5px;

    /* Senka */
    --shadow:       0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.05);
}


/* ── 2. RESET I OSNOVA ───────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    min-height: 100dvh;
}


/* ── 3. LOGIN EKRAN ──────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.25rem 1.75rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-card .logo      { font-size: 2.75rem; margin-bottom: .5rem; }
.login-card h1         { font-size: 1.2rem; font-weight: 700; margin-bottom: .2rem; }
.login-card p          { color: var(--text-3); font-size: .875rem; margin-bottom: 1.75rem; }

.login-error {
    background: var(--red-light);
    color: var(--red);
    padding: .6rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-bottom: 1rem;
}

.login-card input[type="password"] {
    width: 100%;
    padding: .75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
    margin-bottom: .9rem;
    transition: border-color .15s;
    font-family: inherit;
}

.login-card input[type="password"]:focus { border-color: var(--green); }

.login-card button {
    width: 100%;
    padding: .8rem;
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.login-card button:active { background: var(--green-dark); }


/* ── 4. TOPBAR ───────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    height: 54px;
    gap: 10px;
}

.topbar-icon  { font-size: 1.4rem; flex-shrink: 0; }

.topbar-name  { font-weight: 700; font-size: .95rem; flex: 1; line-height: 1.2; }
.topbar-name small {
    display: block;
    font-weight: 400;
    font-size: .73rem;
    color: var(--text-3);
}

.topbar-logout {
    font-size: .78rem;
    color: var(--text-3);
    text-decoration: none;
    padding: .35rem .7rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    white-space: nowrap;
    transition: border-color .15s, color .15s;
}
.topbar-logout:hover { border-color: var(--red); color: var(--red); }


/* ── 5. NAVIGACIJA ───────────────────────────────────────── */

/* Mobile: bottom navigation bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    height: 58px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text-3);
    font-size: .68rem;
    font-weight: 500;
    transition: color .15s;
    user-select: none;
}

.nav-item.active      { color: var(--green); }
.nav-item svg         { width: 22px; height: 22px; stroke-width: 1.8; }

.nav-dot {
    display: none;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
    margin: 0 auto -2px;
}
.nav-item.active .nav-dot { display: block; }

/* Desktop: tabovi ispod topbara */
.desktop-tabs { display: none; }

@media (min-width: 700px) {
    .bottom-nav   { display: none; }
    .desktop-tabs {
        display: flex;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }
    .desktop-tab {
        padding: .7rem 1.25rem;
        font-size: .875rem;
        font-weight: 500;
        cursor: pointer;
        border-bottom: 2.5px solid transparent;
        color: var(--text-3);
        white-space: nowrap;
        user-select: none;
        transition: color .15s;
    }
    .desktop-tab.active {
        color: var(--green);
        border-bottom-color: var(--green);
    }
    .desktop-tab:hover:not(.active) { color: var(--text-2); }
}


/* ── 6. LAYOUT ───────────────────────────────────────────── */
.wrap {
    padding: 1rem;
    max-width: 900px;
    margin: 0 auto;
    /* razmak na dnu da bottom nav ne prekriva sadržaj */
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0));
}

@media (min-width: 700px) {
    .wrap { padding: 1.25rem; padding-bottom: 1.5rem; }
}

.view         { display: none; }
.view.active  { display: block; }


/* ── 7. CARD ─────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .9rem;
    gap: .5rem;
    flex-wrap: wrap;
}
.card-head h2    { font-size: 1rem; font-weight: 700; }
.card-head .actions { display: flex; gap: 6px; align-items: center; }


/* ── 8. KALENDAR ─────────────────────────────────────────── */
.month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: .9rem;
}
.month-nav h3 { flex: 1; text-align: center; font-size: 1rem; font-weight: 700; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }

.cal-label {
    text-align: center;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-3);
    padding: 3px 0;
}

.cal-day {
    min-height: 52px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 5px;
    cursor: pointer;
    transition: border-color .12s, background .12s;
}

@media (min-width: 500px) { .cal-day { min-height: 68px; } }

.cal-day:hover           { border-color: var(--green); background: var(--green-light); }
.cal-day.empty           { border-color: transparent; background: none; cursor: default; }
.cal-day.today           { border-color: var(--green); }
.cal-day.selected        { background: var(--green-light); border-color: var(--green-dark); }
.cal-day .day-num        { font-size: .8rem; font-weight: 700; }
.cal-day.today .day-num  { color: var(--green); }

.dots     { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 3px; }
.dot      { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* Dan panel (ispod kalendara) */
.day-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.day-panel-title  { font-size: 1rem; font-weight: 700; }
.day-panel-sub    { font-size: .8rem; color: var(--text-3); margin-top: 2px; }


/* ── 9. NEDELJNI PRIKAZ ──────────────────────────────────── */
.week-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: .9rem;
}
.week-nav h3 { flex: 1; text-align: center; font-size: .95rem; font-weight: 700; }

.week-day {
    margin-bottom: .75rem;
}

.week-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .45rem .75rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-2);
}
.week-day-head.today { background: var(--green-light); color: var(--green-text); border-color: var(--green); }

.week-day-body {
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: .5rem;
}


/* ── 10. LISTA REZERVACIJA ───────────────────────────────── */
.rez-list   { display: flex; flex-direction: column; gap: 7px; }

/* ri = rezervacija item — jedan red u listi */
.ri {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color .12s;
}
.ri:hover          { border-color: var(--green); }

.ri-bar            { width: 4px; background: var(--green); flex-shrink: 0; }

.ri-time {
    padding: 10px 10px 10px 8px;
    min-width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
    background: var(--card);
}
.ri-time .t-start  { font-size: .78rem; font-weight: 700; color: var(--green); }
.ri-time .t-end    { font-size: .68rem; color: var(--text-3); margin-top: 1px; }

.ri-body { flex: 1; padding: 9px 10px; min-width: 0; }
.ri-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-meta { font-size: .75rem; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ri-delete {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: var(--text-3);
    background: none;
    border: none;
    cursor: pointer;
    transition: color .12s;
}
.ri-delete:hover   { color: var(--red); }
.ri-delete svg     { width: 16px; height: 16px; stroke-width: 2; }

.empty-msg {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-3);
    font-size: .875rem;
}
.empty-msg.compact { padding: .75rem; }

.section-label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-3);
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .1rem 0 .4rem;
    margin-top: .6rem;
}
.section-label:first-child { margin-top: 0; }


/* ── 11. DETAIL MODAL ────────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

@media (min-width: 600px) { .overlay { align-items: center; } }
.overlay.open { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--card);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.25rem;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform .2s;
}

@media (min-width: 600px) {
    .modal {
        border-radius: var(--radius);
        transform: translateY(0) scale(.96);
        max-height: 80vh;
    }
}
.overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: .5rem;
}
.modal-header h3    { font-size: 1.05rem; font-weight: 700; flex: 1; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-3);
    padding: 0 2px;
    line-height: 1;
}

/* Redovi sa detaljima unutar modala */
.detail-row {
    display: flex;
    gap: 10px;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child  { border-bottom: none; }
.detail-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .04em;
    min-width: 90px;
    padding-top: .1rem;
    flex-shrink: 0;
}
.detail-value { font-size: .9rem; color: var(--text-1); flex: 1; word-break: break-word; }

.modal-actions { display: flex; gap: 8px; margin-top: 1rem; }

.btn-modal-close {
    flex: 1;
    padding: .65rem;
    border: 1.5px solid var(--border);
    background: none;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-1);
    font-family: inherit;
}

.btn-modal-delete {
    flex: 1;
    padding: .65rem;
    background: var(--red-light);
    color: var(--red);
    border: none;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}


/* ── 12. FORMA ZA DODAVANJE ──────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

.form-full { grid-column: 1 / -1; }

.form-group        { display: flex; flex-direction: column; gap: 4px; }
.form-group label  {
    font-size: .73rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: .65rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    width: 100%;
    background: var(--card);
    color: var(--text-1);
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--green); }

.form-group textarea { height: 70px; resize: vertical; }

.btn-submit {
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: .75rem 1.5rem;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: .25rem;
    width: 100%;
    font-family: inherit;
    transition: background .15s;
}
.btn-submit:hover    { background: var(--green-dark); }
.btn-submit:disabled { opacity: .5; cursor: default; }


/* ── 13. PRETRAGA ────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 180px;
    padding: .65rem .9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    outline: none;
    font-family: inherit;
    background: var(--card);
    color: var(--text-1);
    transition: border-color .15s;
}
.search-input:focus { border-color: var(--green); }

.search-date {
    width: 145px;
    padding: .65rem .75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .85rem;
    outline: none;
    font-family: inherit;
    background: var(--card);
    color: var(--text-1);
    transition: border-color .15s;
    /* Jednaka širina na mobilnim uređajima */
    box-sizing: border-box;
}
.search-date:focus  { border-color: var(--green); }

    .search-date      { width: 100%; }
}

.search-count {
    font-size: .8rem;
    color: var(--text-3);
    margin-bottom: .75rem;
}


/* Forsira DD.MM.GGGG format u Chrome/Edge za date inpute */
input[type="date"]::-webkit-datetime-edit-fields-wrapper { direction: ltr; }
input[type="date"]::-webkit-datetime-edit-day-field    { order: 1; }
input[type="date"]::-webkit-datetime-edit-literal:nth-of-type(1) { order: 2; }
input[type="date"]::-webkit-datetime-edit-month-field  { order: 3; }
input[type="date"]::-webkit-datetime-edit-literal:nth-of-type(2) { order: 4; }
input[type="date"]::-webkit-datetime-edit-year-field   { order: 5; }


/* Forsira 24h format za time inpute u svim browserima ──── */
input[type="time"]::-webkit-datetime-edit-ampm-field {
    display: none !important;
    width: 0;
    overflow: hidden;
}


/* ── 14. DUGMAD I BADGE-OVI ─────────────────────────────── */

/* Malo dugme (npr. Štampaj, Dodaj u day panelu) */
.btn-sm {
    padding: .4rem .85rem;
    border: 1.5px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    cursor: pointer;
    color: var(--text-1);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    transition: border-color .15s;
}
.btn-sm:hover      { border-color: var(--border-dark); }
.btn-sm.green      { background: var(--green); color: #fff; border-color: var(--green); }
.btn-sm.green:hover { background: var(--green-dark); border-color: var(--green-dark); }

/* Dugme navigacija (strelice za mesec/nedelju) */
.btn-nav {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .3rem .75rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-1);
    font-family: inherit;
}
.btn-nav:hover { background: var(--bg); }

/* Dugme za pretragu */
.btn-search {
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: .65rem 1.1rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}
.btn-search:active { background: var(--green-dark); }

/* Badge (broj rezervacija, oznaka) */
.badge {
    display: inline-block;
    background: var(--green-light);
    color: var(--green-text);
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 5px;
}
.badge.empty { background: var(--border); color: var(--text-3); }


/* ── Export bar (ispod kalendara) ────────────────────────── */
.export-bar {
    margin-top: .9rem;
    padding-top: .9rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: .55rem 1.1rem;
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.btn-export:hover    { background: var(--green-dark); }
.btn-export:disabled { opacity: .6; cursor: default; }
.btn-export svg      { width: 16px; height: 16px; flex-shrink: 0; }


/* ── 15. TOAST OBAVEŠTENJA ───────────────────────────────── */
#toast {
    position: fixed;
    bottom: calc(68px + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--text-1);
    color: #fff;
    padding: .6rem 1.2rem;
    border-radius: 20px;
    font-size: .85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 1000;
    white-space: nowrap;
}

@media (min-width: 700px) {
    #toast { bottom: 1.5rem; right: 1.5rem; left: auto; transform: translateY(0); }
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 700px) { #toast.show { transform: none; } }

#toast.error { background: var(--red); }


/* ── 16. SPINNER ─────────────────────────────────────────── */
.spinner {
    display: block;
    width: 20px;
    height: 20px;
    margin: .75rem auto;
    border: 2px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* ── 17. PRINT STILOVI ───────────────────────────────────── */
@media print {
    .topbar,
    .bottom-nav,
    .desktop-tabs,
    .overlay,
    #toast,
    .no-print      { display: none !important; }

    body           { background: #fff; }
    .card          { box-shadow: none; border: 1px solid #ddd; }
    .ri-delete     { display: none; }
    .wrap          { padding-bottom: 0; }
}
