/* ============================================================
   BOOKUP — globalne style
   Tailwind CDN ładujemy przed tym plikiem; tu definiujemy
   zmienne brandu i custom componenty.
   ============================================================ */

/* Box-sizing reset — żeby width:100% + padding + border nie wychodziło
   poza kontener. Konieczne na stronach które nie ładują Tailwinda
   (np. /login.html) — w przeciwnym razie .input wystaje poza kartę. */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --brand-50:  #f0f9ee;
    --brand-100: #d4f0cf;
    --brand-200: #aee2a5;
    --brand-300: #87d57c;
    --brand-400: #5DC754;
    --brand-500: #42B939;
    --brand-600: #2E8E2A;
    --brand-700: #246f22;
    --brand-800: #1c5519;
    --brand-900: #143d12;
    --ink:       #1a1d22;
    --text:      #2c2f36;
    --text-soft: #6b7079;
    --border:    #e5e3df;
    --bg:        #ffffff;
    --bg-soft:   #faf7f2;
    --shadow-sm: 0 1px 2px rgba(20, 30, 20, 0.06);
    --shadow-md: 0 4px 16px rgba(20, 30, 20, 0.08);
    --shadow-lg: 0 12px 32px rgba(20, 30, 20, 0.12);
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg-soft);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .font-display {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    color: var(--ink);
    letter-spacing: -0.01em;
}

/* ============================================================
   Montserrat 700 — daty, godziny, slot buttons, calendar headers
   "maj 2026", numery dni, godziny slotów, picker'y czasu/daty
   ============================================================ */
.font-num,
.fc .fc-toolbar-title,
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number,
.fc .fc-timegrid-slot-label-cushion,
.fc .fc-timegrid-axis-cushion,
.fc .fc-list-day-cushion,
.fc-event-time,
.fc-list-event-time,
.slot-btn,
.week-day .day-date,
.week-nav .label,
input[type="time"],
input[type="date"],
input[type="datetime-local"] {
    font-family: 'Montserrat', 'Inter', system-ui, sans-serif;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.75rem;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    line-height: 1.2;
}
.btn-primary {
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-400) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(66, 185, 57, 0.25);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(66, 185, 57, 0.35); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
    background: #fff; color: var(--ink); border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-soft); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; border-radius: 0.5rem; }
.btn-icon { width: 2.5rem; height: 2.5rem; padding: 0; }

/* ============ Inputs ============ */
.input, .select, .textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: #fff;
    color: var(--ink);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(66, 185, 57, 0.15);
}
.textarea { resize: vertical; min-height: 4.5rem; }
.label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--ink); margin-bottom: 0.3rem; }
.help { font-size: 0.8rem; color: var(--text-soft); margin-top: 0.25rem; }

/* ============ Cards / surfaces ============ */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.25rem; }

/* ============ Topbar ============ */
.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    height: 64px;
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1rem;
    position: sticky; top: 0; z-index: 40;
}
.app-topbar img.logo { height: 40px; width: auto; max-width: 220px; object-fit: contain; }
@media (max-width: 640px) {
    .app-topbar img.logo { height: 34px; max-width: 170px; }
}

/* Nav w topbarze panelu specjalisty (desktop) */
.panel-topnav { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.panel-topnav a {
    padding: 0.5rem 0.85rem;
    border-radius: 0.5rem;
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
}
.panel-topnav a:hover { background: var(--bg-soft); color: var(--ink); }
.panel-topnav a.active { background: var(--brand-50); color: var(--brand-700); }
@media (max-width: 760px) {
    .panel-topnav { display: none; }
}

/* ============ Bottom nav (mobile) ============ */
.app-bottomnav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--border);
    padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
}
.app-bottomnav .nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 0.5rem; color: var(--text-soft); font-size: 0.72rem;
    border-radius: 0.5rem; text-decoration: none;
}
.app-bottomnav .nav-item.active { color: var(--brand-600); }
.app-bottomnav .nav-item svg { width: 22px; height: 22px; }
@media (max-width: 760px) {
    .app-bottomnav { display: flex; }
    body.has-bottomnav { padding-bottom: 80px; }
}

/* ============ Sidebar (admin desktop) ============ */
.app-sidebar {
    background: #fff; border-right: 1px solid var(--border);
    width: 260px;
    min-height: 100vh;
    padding: 1rem 0.75rem;
}
.app-sidebar .menu-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.85rem; border-radius: 0.6rem;
    color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.95rem;
    margin-bottom: 0.15rem;
}
.app-sidebar .menu-item:hover { background: var(--bg-soft); color: var(--ink); }
.app-sidebar .menu-item.active { background: var(--brand-50); color: var(--brand-600); }
.app-sidebar .menu-item svg { width: 20px; height: 20px; opacity: 0.85; }

/* ============ Calendar (FullCalendar overrides) ============ */
.fc {
    --fc-border-color: var(--border);
    --fc-today-bg-color: rgba(66, 185, 57, 0.04);
    --fc-event-text-color: #fff;
    --fc-now-indicator-color: var(--brand-600);
    background: #fff; border-radius: 1rem; overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    font-family: inherit !important;
}
.fc .fc-toolbar-title { font-family: 'Montserrat', 'Inter', sans-serif; font-size: 1.4rem !important; font-weight: 700; text-transform: capitalize; }
.fc .fc-button {
    background: #fff !important; color: var(--ink) !important;
    border: 1px solid var(--border) !important;
    border-radius: 0.5rem !important;
    padding: 0.4rem 0.75rem !important;
    font-weight: 500;
    box-shadow: none !important;
    text-transform: none !important;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):hover {
    background: var(--brand-500) !important; color: #fff !important; border-color: var(--brand-500) !important;
}
.fc .fc-event { border: none !important; padding: 2px 6px; font-size: 0.85rem; border-radius: 6px !important; cursor: pointer; }
.fc .fc-event:hover { filter: brightness(0.95); }
.fc .fc-timegrid-slot { height: 2.5em; }
.fc .fc-col-header-cell-cushion { font-weight: 600; padding: 8px 4px; }
.fc-direction-ltr .fc-list-event-time { text-align: left; }
.fc-event-main { padding: 1px 2px; }
.fc-event-title { font-weight: 600; }

/* ============ Tryb "wszyscy specjaliści" (admin filter = null) ============
   N specjalistów w tym samym slocie → N pionowych pasków po 1/N szerokości.
   Pokazujemy tylko inicjały specjalisty (eventContent w Alpine). Container
   query chowa inicjały gdy bloczek za wąski (<26px). */
.fc.all-specs .fc-timegrid-event .fc-event-title,
.fc.all-specs .fc-timegrid-event .fc-event-time,
.fc.all-specs .fc-timegrid-event .fc-event-main-frame {
    display: none !important;
}
.fc.all-specs .fc-timegrid-event .fc-event-main {
    padding: 0 !important;
    position: relative;
    min-height: 14px;
}
.fc.all-specs .fc-timegrid-event { border-radius: 4px !important; }

/* Inicjały specjalisty — wycentrowane na bloczku (tryb all-specs) */
.ev-initials {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-family: 'Montserrat', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    pointer-events: none;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
    line-height: 1;
}

/* Pełny bloczek wizyty (tryb single-spec admin + cały panel specjalisty)
   Zawartość: imię klienta (pogrubione) + usługa pod spodem */
.ev-block {
    padding: 3px 6px;
    color: #fff;
    line-height: 1.2;
    overflow: hidden;
    height: 100%;
}
.ev-block .ev-client {
    font-weight: 700;
    font-size: 0.86rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.ev-block .ev-service {
    font-size: 0.74rem;
    opacity: 0.92;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    margin-top: 1px;
}
/* Container query: kompaktuj zawartość gdy bloczek wąski */
@container bookup-event (max-width: 70px) {
    .ev-block .ev-service { display: none; }
    .ev-block .ev-client { font-size: 0.74rem; }
}
@container bookup-event (max-width: 35px) {
    .ev-block * { display: none; }
}
/* Mobile: zwartsze */
@media (max-width: 760px) {
    .ev-block { padding: 2px 4px; }
    .ev-block .ev-client { font-size: 0.78rem; }
    .ev-block .ev-service { font-size: 0.68rem; }
}

/* Closed-day overrides — szary "X-pattern" zamiast jednolitego tła
   żeby było bardziej widoczne że to celowo zamknięty dzień */
.bookup-closed-day {
    background: rgba(156, 163, 175, 0.55) !important;
    background-image: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 8px,
        rgba(0, 0, 0, 0.08) 8px,
        rgba(0, 0, 0, 0.08) 16px
    ) !important;
    opacity: 1 !important;
}

/* ============ Single-specialist mode + container query safety net.
   Gdy się okaże że 5+ specjalistów mimo wszystko ma wąską kolumnę
   w panelu wybranego spec (np. mobile), upewnij się że tekst nie wystaje. */
.fc-timegrid-event-harness {
    container-type: inline-size;
    container-name: bookup-event;
}
.fc-timegrid-event-harness .fc-event { overflow: hidden; }
.fc-timegrid-event-harness .fc-event-title,
.fc-timegrid-event-harness .fc-event-time {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@container bookup-event (max-width: 50px) {
    .fc.single-spec .fc-event-time { display: none !important; }
}
@container bookup-event (max-width: 35px) {
    .fc.single-spec .fc-event-title, .fc.single-spec .fc-event-time { display: none !important; }
}
/* Chowamy inicjały w trybie all-specs gdy bloczek za wąski (5+ specjalistów) */
@container bookup-event (max-width: 26px) {
    .fc.all-specs .ev-initials { display: none !important; }
}

/* Mobile + widok miesięczny — w komórkach 1 dnia na ~50px szerokości
   nawet inicjały się rozjeżdżają. Zostaw tylko kolorowe paseczki. */
@media (max-width: 760px) {
    .fc-dayGridMonth-view .ev-initials,
    .fc-dayGridMonth-view .ev-block { display: none !important; }
    .fc-dayGridMonth-view .fc-event {
        padding: 1px 2px !important;
        min-height: 4px;
    }
}

/* ============ Non-business hours — szare (FC robi to automatycznie,
   ale dodajemy mocniejszy kontrast) ============ */
.fc .fc-non-business {
    background: rgba(229, 231, 235, 0.55) !important;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 6px,
        rgba(0, 0, 0, 0.03) 6px,
        rgba(0, 0, 0, 0.03) 12px
    ) !important;
}

/* ============ Calendar: past / today / future styling ============ */
/* Dni minione — szary tło, wyblakłe etykiety, kursor disabled */
.fc .fc-day-past {
    background: #f3f4f6 !important;
}
.fc .fc-day-past .fc-daygrid-day-number,
.fc .fc-col-header-cell.fc-day-past .fc-col-header-cell-cushion {
    color: #9ca3af !important;
}
.fc .fc-timegrid-col.fc-day-past { background: #f3f4f6 !important; }
.fc .fc-day-past .fc-daygrid-day-frame { cursor: not-allowed; }

/* Dzień dzisiejszy — wyraźny zielony */
.fc .fc-day-today {
    background: rgba(66, 185, 57, 0.10) !important;
}
.fc .fc-timegrid-col.fc-day-today { background: rgba(66, 185, 57, 0.06) !important; }
.fc .fc-day-today .fc-daygrid-day-number,
.fc .fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion {
    color: var(--brand-700) !important;
    font-weight: 700;
}

/* Dni przyszłe — białe */
.fc .fc-day-future { background: #ffffff !important; }

/* ============ Booking status visualization ============ */
.fc-event.bookup-cancelled {
    opacity: 0.6;
    text-decoration: line-through;
    background: #9ca3af !important;
}
.fc-event.bookup-completed {
    opacity: 0.78;
    background: var(--brand-600) !important;
    border-left: 4px solid var(--brand-800) !important;
}
.fc-event.bookup-no_show {
    background: #dc2626 !important;
    border-left: 4px solid #991b1b !important;
}

/* ============ Calendar: mobile fluid sizing ============
   Używamy clamp() żeby cyferki dat i godzin automatycznie skalowały się
   do szerokości viewportu. Min/max chronią przed za małym/za dużym tekstem. */
@media (max-width: 760px) {
    .fc { border-radius: 0.6rem; font-size: 0.85rem; }
    .fc .fc-toolbar { flex-wrap: wrap; gap: 0.4rem; row-gap: 0.6rem; }
    .fc .fc-toolbar-chunk { display: flex; flex-wrap: wrap; gap: 0.25rem; }
    .fc .fc-toolbar-title { font-size: clamp(0.95rem, 4vw, 1.2rem) !important; flex: 1 0 100%; text-align: center; order: -1; }
    .fc .fc-button {
        padding: clamp(0.25rem, 1vw, 0.4rem) clamp(0.45rem, 1.6vw, 0.7rem) !important;
        font-size: clamp(0.7rem, 2.4vw, 0.85rem) !important;
        border-radius: 0.4rem !important;
    }
    /* Cyferki godzin po lewej (axis) — fluid */
    .fc .fc-timegrid-axis-cushion,
    .fc .fc-timegrid-slot-label-cushion {
        font-size: clamp(0.6rem, 2.2vw, 0.78rem) !important;
        padding: 0 clamp(2px, 0.8vw, 4px) !important;
    }
    .fc .fc-timegrid-axis { width: clamp(30px, 9vw, 42px) !important; }
    /* Daty w nagłówkach kolumn — fluid */
    .fc .fc-col-header-cell-cushion {
        font-size: clamp(0.62rem, 2.3vw, 0.78rem) !important;
        padding: 4px 1px !important;
        white-space: normal;
        line-height: 1.15;
    }
    .fc .fc-daygrid-day-number {
        font-size: clamp(0.7rem, 2.4vw, 0.85rem) !important;
        padding: 2px 4px !important;
    }
    .fc .fc-event {
        padding: 1px 3px !important;
        font-size: clamp(0.65rem, 2.2vw, 0.75rem) !important;
    }
    .fc-event-title { font-size: clamp(0.65rem, 2.2vw, 0.75rem) !important; }
    .fc-event-time { font-size: clamp(0.6rem, 2vw, 0.7rem) !important; }
    .fc .fc-timegrid-slot { height: 2.1em !important; }
    .fc .fc-list-day-cushion,
    .fc .fc-list-event-time { font-size: clamp(0.72rem, 2.4vw, 0.85rem) !important; }
}

/* ============ Helpers ============ */
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px;
    background: var(--brand-50); color: var(--brand-700);
    font-size: 0.78rem; font-weight: 500;
}
.chip-soft { background: var(--bg-soft); color: var(--text-soft); }
.chip-danger { background: #fef2f2; color: #b91c1c; }

.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ============ Toast ============ */
#toast-root { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    background: var(--ink); color: #fff;
    padding: 0.75rem 1rem; border-radius: 0.6rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    min-width: 220px; max-width: 360px;
    animation: toast-in 0.2s ease;
}
.toast.toast-success { background: var(--brand-600); }
.toast.toast-error { background: #dc2626; }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ Spinner ============ */
.spinner {
    width: 1.25rem; height: 1.25rem; border: 2.5px solid rgba(0,0,0,0.1);
    border-top-color: var(--brand-500); border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.spinner-lg { width: 2.5rem; height: 2.5rem; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Modal ============ */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(20, 25, 20, 0.5);
    z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem;
    animation: fade-in 0.15s ease;
}
.modal {
    background: #fff; border-radius: 1rem;
    width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.2s ease;
}
.modal-header { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 1.25rem; margin: 0; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 0.85rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ Modal mobile fix ============ */
@media (max-width: 560px) {
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal {
        max-height: 100vh; max-height: 100dvh;
        border-radius: 1rem 1rem 0 0;
        min-height: 50vh;
        animation: modal-in-mobile 0.2s ease;
    }
    .modal-header { padding: 0.85rem 1rem; position: sticky; top: 0; background: #fff; z-index: 2; }
    .modal-header h2 { font-size: 1.1rem; }
    .modal-body { padding: 1rem; }
    .modal-footer {
        padding: 0.75rem 1rem;
        position: sticky; bottom: 0; background: #fff; z-index: 2;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    }
    .modal-footer .btn { flex: 1 0 calc(50% - 0.25rem); min-width: 120px; }
    .modal-footer > div[style*="flex:1"] { display: none; }   /* schowaj spacer flex-1 */

    /* Slot grid: mniejsze ramki na bardzo wąskim */
    .slot-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)) !important; gap: 0.3rem !important; }
    .slot-btn { padding: 0.4rem 0.3rem !important; font-size: 0.82rem !important; }

    /* "Lub wpisz własną" — stack pionowo (span nad inputem time) */
    .custom-time-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.3rem !important;
    }
    .custom-time-row input[type="time"] { max-width: 100% !important; }
}
@keyframes modal-in-mobile {
    from { transform: translateY(100%); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============ Hide scrollbars on horizontal swipes ============ */
.scroll-x { overflow-x: auto; scrollbar-width: thin; }
.scroll-x::-webkit-scrollbar { height: 6px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============ Animations on app load ============ */
[x-cloak] { display: none !important; }
