/* =========================================================
   COREIDON.AI — Customer Reservation (mobile-first)
   Independent stylesheet. Do not share with other pages.
   ========================================================= */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;

    /* Light theme */
    --bg-canvas: #FFFFFF;
    --bg-section: #F8F5F0;
    --bg-surface: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-input-hover: #F8F5F0;
    --bg-track: #F8F5F0;

    --text-primary: #000000;
    --text-secondary: #2B303B;
    --text-muted: rgba(43, 48, 59, 0.7);
    --text-inverse: #FFFFFF;

    --accent-navy: #091C3A;
    --accent-navy-hover: #0C2550;
    --accent-cyan: #0284C7;
    --accent-cyan-hover: #0369A1;
    --accent-cyan-soft: rgba(2, 132, 199, 0.1);
    --accent-cyan-soft-strong: rgba(2, 132, 199, 0.22);

    --color-success: #16A34A;
    --color-success-soft: rgba(22, 163, 74, 0.14);
    --color-danger: #DC2626;
    --color-danger-soft: rgba(220, 38, 38, 0.12);

    --border-subtle: #E5E7EB;
    --border-strong: #2B303B;
    --border-focus: #0284C7;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --brand-fill: #091C3A;

    --shadow-card: 0 1px 2px rgba(9, 28, 58, 0.05);
    --shadow-raised: 0 8px 24px rgba(9, 28, 58, 0.1);

    --safe-inset-top: env(safe-area-inset-top, 0px);
    --safe-inset-bottom: env(safe-area-inset-bottom, 0px);

    --transition-snap: 120ms ease;
    --transition-swift: 200ms ease;

    /* Touch-friendly sizes */
    --tap-size: 48px;
    --timeline-row-height: 56px;
}

[data-theme="dark"] {
    --bg-canvas: #0A1220;
    --bg-section: #0A1220;
    --bg-surface: #121B2A;
    --bg-elevated: #243447;
    --bg-input: #121B2A;
    --bg-input-hover: #1F2A3C;
    --bg-track: #1F2A3C;

    --text-primary: #FFFFFF;
    --text-secondary: rgba(248, 245, 240, 0.78);
    --text-muted: rgba(248, 245, 240, 0.5);
    --text-inverse: #0A1220;

    --accent-navy: #091C3A;
    --accent-navy-hover: #0C2550;
    --accent-cyan: #38BDF8;
    --accent-cyan-hover: #7DD3FC;
    --accent-cyan-soft: rgba(56, 189, 248, 0.14);
    --accent-cyan-soft-strong: rgba(56, 189, 248, 0.3);

    --color-success: #34D399;
    --color-success-soft: rgba(52, 211, 153, 0.14);
    --color-danger: #FB7185;
    --color-danger-soft: rgba(251, 113, 133, 0.14);

    --border-subtle: #1F2A3C;
    --border-strong: #2D3D52;
    --border-focus: #38BDF8;

    --brand-fill: #F8F5F0;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-raised: 0 10px 30px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg-section);
    color: var(--text-primary);
    font-family: var(--font-sans);
    /* 16px base prevents iOS auto-zoom on input focus */
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
    touch-action: manipulation;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin: 0;
}

a { color: var(--accent-cyan); text-decoration: none; transition: color var(--transition-snap); }
a:active { color: var(--accent-cyan-hover); }

button { font-family: inherit; }

/* ---------- Topbar ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(0.75rem + var(--safe-inset-top)) 1rem 0.75rem;
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--brand-fill);
    text-decoration: none;
}
.brand:active { color: var(--brand-fill); }

.brand-logo {
    width: 28px;
    height: 28px;
    color: var(--brand-fill);
}
.brand-logo svg { width: 100%; height: 100%; }

.brand-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.client-logo {
    display: none;
    align-items: center;
    height: 156px;
    max-width: 660px;
    margin-right: auto;
    color: var(--text-secondary);
}
.client-logo.has-logo { display: inline-flex; }
.client-logo img, .client-logo svg { max-height: 100%; max-width: 100%; width: auto; }

/* Keep the actions pinned to the right even when no client logo is shown. */
.topbar-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }

/* Coreidon brand moved here from the topbar — a quiet "powered by" footer. */
.app-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2.5rem;
    padding: 1.5rem 1rem calc(1.5rem + var(--safe-inset-bottom));
    border-top: 1px solid var(--border-subtle);
}
.app-footer .brand { opacity: 0.75; }

.theme-toggle {
    width: var(--tap-size);
    height: var(--tap-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition-snap), color var(--transition-snap);
}
.theme-toggle:active { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.theme-toggle svg { width: 22px; height: 22px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Main container ---------- */
.reserve-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.25rem 1rem calc(2rem + var(--safe-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

.page-header .eyebrow {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent-cyan);
    margin: 0 0 0.25rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1.2;
}

.page-subtitle {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---------- Cards ---------- */
.reserve-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-card);
}

.section-title {
    margin: 0 0 1rem 0;
    padding-bottom: 0.6rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.hidden { display: none !important; }

/* ---------- Forms ---------- */
#reservation-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
#reservation-form.hidden { display: none !important; }

.search-box {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

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

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

label, .rooms-label {
    font-family: var(--font-sans);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    min-height: var(--tap-size);
    padding: 0.75rem 0.9rem;
    font: inherit;
    /* font-size: 16px prevents iOS zoom-on-focus */
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-snap), box-shadow var(--transition-snap);
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    resize: vertical;
    line-height: 1.4;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%232B303B' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.25rem;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23F8F5F0' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}

input:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-cyan-soft);
}

/* ---------- Buttons ---------- */
.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--tap-size);
    padding: 0.75rem 1.1rem;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 0.88rem;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition-snap), border-color var(--transition-snap),
                color var(--transition-snap), transform var(--transition-snap);
    white-space: nowrap;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-cyan-soft); }
.btn:disabled { opacity: 0.55; cursor: progress; }

.btn-block { width: 100%; }

.btn-primary {
    background: var(--accent-navy);
    color: #FFFFFF;
    border-color: var(--accent-navy);
}
.btn-primary:active { background: var(--accent-navy-hover); border-color: var(--accent-navy-hover); }

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-subtle);
}
.btn-secondary:active { color: var(--accent-cyan); border-color: var(--accent-cyan); }

.btn-icon {
    width: var(--tap-size);
    height: var(--tap-size);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition-snap), border-color var(--transition-snap);
}
.btn-icon:active { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-icon svg { width: 18px; height: 18px; }

/* Legacy class used elsewhere in JS — same visual as .btn .btn-secondary */
.btn-secondary-small {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: var(--tap-size);
    transition: all var(--transition-snap);
}
.btn-secondary-small:active { color: var(--accent-cyan); border-color: var(--accent-cyan); }

.btn-submit {
    width: 100%;
    margin-top: 0.5rem;
    min-height: var(--tap-size);
    padding: 0.85rem 1.2rem;
    background: var(--accent-navy);
    color: #FFFFFF;
    border: 1px solid var(--accent-navy);
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 0.9rem;
    text-transform: uppercase;
    cursor: pointer;
}
.btn-submit:active { background: var(--accent-navy-hover); border-color: var(--accent-navy-hover); }

/* ---------- Room list (manual search) ---------- */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
}

.room-option {
    min-height: var(--tap-size);
    padding: 0.85rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    transition: border-color var(--transition-snap), background var(--transition-snap);
    font-weight: 500;
}
.room-option:active {
    border-color: var(--accent-cyan);
    background: var(--bg-input-hover);
}

.room-option.selected {
    border-color: var(--accent-cyan);
    background: var(--accent-cyan-soft);
}
.room-option.selected::after {
    content: '✓';
    color: var(--accent-cyan);
    font-weight: 700;
    margin-left: auto;
}

.room-option .room-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.room-option .room-price {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: normal;
    flex-basis: 100%;
}

.room-option .room-price--free {
    color: var(--color-success);
    font-weight: 600;
}

/* ---------- Glance Timeline (mobile-first: horizontal scroll) ---------- */
.date-nav-glance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.date-input-glance {
    flex: 1;
    min-height: var(--tap-size);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
}
.date-input-glance:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-cyan-soft);
}

[data-theme="dark"] .date-input-glance::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.timeline-legend {
    display: flex;
    justify-content: flex-start;
    gap: 0.8rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 0.3rem;
    vertical-align: middle;
    border: 1px solid var(--border-subtle);
}
.legend-dot--free { background: var(--bg-track); }
.legend-dot--busy { background: var(--color-danger-soft); border-color: var(--color-danger); }
.legend-dot--selected { background: var(--accent-cyan); border-color: var(--accent-cyan); }

/* On mobile, the timeline becomes a horizontal scroller to preserve readability */
.timeline-grid-glance {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-surface);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Swipe to scroll instead of relying on a thin scrollbar — hide it on mobile. */
    scrollbar-width: none; /* Firefox */
}
.timeline-grid-glance::-webkit-scrollbar { display: none; } /* WebKit */

/* The timeline pans by click-drag (its scrollbar is hidden), so hint it with a
   grab cursor. Free slots keep their own pointer cursor (more specific), so the
   "click to select" affordance stays. While actively panning, force grabbing. */
.timeline-grid-glance { cursor: grab; }
.timeline-grid-glance.is-grabbing,
.timeline-grid-glance.is-grabbing * { cursor: grabbing !important; user-select: none; }

.timeline-header-glance,
.timeline-room-row-glance {
    display: grid;
    /* Content column grows to fit the timeline's min-width (set per-render in JS from
       the hour count) so the header grid and each track row stay exactly the same
       width and their labels/slots line up. */
    grid-template-columns: 110px 1fr;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}
.timeline-grid-glance > :last-child { border-bottom: none; }

.timeline-header-glance { background: var(--bg-track); }

.timeline-header-room-glance,
.timeline-room-label-glance {
    padding: 0.6rem 0.75rem;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    position: sticky;
    left: 0;
    background: var(--bg-surface);
    z-index: 1;
}

.timeline-header-room-glance {
    text-transform: uppercase;
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    background: var(--bg-track);
}

.timeline-header-grid-glance {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    text-align: center;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.5rem 0;
    /* Own background (not just the row's) so labels revealed by horizontal scroll
       beyond the initial viewport aren't left on a white strip. */
    background: var(--bg-track);
}

.timeline-header-hour-glance { padding: 0 0.15rem; }

.timeline-track-glance {
    position: relative;
    height: var(--timeline-row-height);
    background: var(--bg-track);
    /* Gridline at the centre of each hour column, where the centered label and the
       (+30 min shifted) block start sit. background-size is set per-render in JS. */
    background-image: linear-gradient(to right,
        transparent calc(50% - 0.5px),
        var(--border-subtle) calc(50% - 0.5px),
        var(--border-subtle) calc(50% + 0.5px),
        transparent calc(50% + 0.5px));
    background-size: calc(100% / 15) 100%;
    /* Selection is tap-based, so leave both axes free: a horizontal swipe scrolls
       the timeline, a vertical swipe scrolls the page. */
    touch-action: pan-x pan-y;
}

.glance-time-slot {
    position: absolute;
    top: 0;
    height: 100%;
    cursor: pointer;
    transition: background var(--transition-snap);
}

.glance-time-slot:active { background: var(--accent-cyan-soft); }

.glance-time-slot.occupied {
    background: var(--color-danger-soft);
    cursor: not-allowed;
}

.glance-time-slot.selected {
    background: var(--accent-cyan) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(1rem + var(--safe-inset-bottom));
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    min-width: 240px;
    max-width: 440px;
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--color-success);
    color: #FFFFFF;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    box-shadow: var(--shadow-raised);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--transition-swift), transform var(--transition-swift);
    pointer-events: auto;
}
.toast.visible { opacity: 1; transform: translateY(0); }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 640px) {
    .reserve-container {
        padding: 2rem 1.5rem calc(2rem + var(--safe-inset-bottom));
        gap: 1.25rem;
    }
    .page-header {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
        gap: 1rem;
    }
    .page-header h1 { font-size: 2rem; }
    .reserve-card { padding: 1.5rem; }
    .search-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
    .timeline-header-glance,
    .timeline-room-row-glance {
        grid-template-columns: 140px 1fr;
    }
    .timeline-grid-glance { overflow-x: visible; }
    .timeline-header-room-glance,
    .timeline-room-label-glance { position: static; }
    .timeline-legend {
        justify-content: center;
        gap: 1.25rem;
    }
    .date-nav-glance { justify-content: center; }
    .date-input-glance { flex: 0 1 200px; }
}
