/* TD Booking – calendar + form. Mobile first. Fonts inherit from the theme. */

.tdb-calendar,
.booking-form-wrapper {
    --tdb-green: #044e26;
    --tdb-green-dark: #033a1c;
    --tdb-green-soft: #a3cfb3;
    --tdb-red: #c0392b;
    --tdb-yellow: #ffc107;
    --tdb-yellow-ink: #3d2e00;
    --tdb-ink: #1f2a24;
    --tdb-muted: #6b7570;
    --tdb-line: #d9dedb;
    --tdb-na: #eef0ef;
}

.tdb-calendar {
    box-sizing: border-box;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px;
    color: var(--tdb-ink);
}
.tdb-calendar *,
.tdb-calendar *::before,
.tdb-calendar *::after { box-sizing: border-box; }

.tdb-status { padding: 40px 12px; text-align: center; color: var(--tdb-muted); }
.tdb-error { color: var(--tdb-ink); }

/* Month header */
.tdb-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.tdb-month {
    flex: 1;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

/*
 * Every calendar button is styled with high specificity on purpose:
 * the theme / Elementor give all <button>s a hover colour that would
 * otherwise paint over the days and prices.
 */
.tdb-calendar .tdb-nav button.tdb-nav-btn,
.tdb-calendar .tdb-nav button.tdb-nav-btn:hover,
.tdb-calendar .tdb-nav button.tdb-nav-btn:focus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1px solid var(--tdb-line);
    border-radius: 50%;
    background: #fff;
    color: var(--tdb-ink);
    box-shadow: none;
    transform: none;
    cursor: pointer;
    flex: none;
}
.tdb-calendar .tdb-nav button.tdb-nav-btn:hover { background: #f3f5f4; color: var(--tdb-ink); }
.tdb-calendar .tdb-nav button.tdb-nav-btn:disabled,
.tdb-calendar .tdb-nav button.tdb-nav-btn:disabled:hover { background: #fff; color: #c5cbc8; border-color: #eceeed; cursor: default; }
.tdb-calendar .tdb-nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* Grid: minmax(0,1fr) so it can never be wider than the screen */
.tdb-nav,
.tdb-grid {
    -webkit-user-select: none;
    user-select: none;
}
.tdb-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    background: #f3f5f4;
    border-radius: 8px;
    touch-action: pan-y;
}
.tdb-wd {
    padding: 8px 0;
    text-align: center;
    font-size: .85rem;
    font-weight: 700;
    color: var(--tdb-ink);
    background: #fff;
    border: 1px solid var(--tdb-line);
    border-radius: 4px;
}
.tdb-calendar .tdb-empty { min-height: 48px; aspect-ratio: 1 / 1; }

/* Day: base (also neutralises theme button styles) */
.tdb-calendar .tdb-grid button.tdb-day,
.tdb-calendar .tdb-grid button.tdb-day:hover,
.tdb-calendar .tdb-grid button.tdb-day:focus,
.tdb-calendar .tdb-grid button.tdb-day:active {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: auto;
    min-width: 0;
    min-height: 48px;
    aspect-ratio: 1 / 1;
    margin: 0;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-size: inherit;
    line-height: 1.1;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    color: var(--tdb-ink);
    background: #fff;
    box-shadow: none;
    transform: none;
    opacity: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .12s, border-color .12s;
}
.tdb-calendar .tdb-grid button.tdb-day:disabled { cursor: default; }
.tdb-calendar .tdb-grid button.tdb-day:focus-visible { outline: 3px solid #1a73e8; outline-offset: 1px; z-index: 1; }

.tdb-calendar .tdb-num { font-size: 1rem; font-weight: 600; color: inherit; }
.tdb-calendar .tdb-p { font-size: .72rem; font-weight: 600; color: var(--tdb-muted); white-space: nowrap; overflow: hidden; max-width: 100%; }
.tdb-calendar .tdb-p:empty { display: none; }

/* Status colours */
.tdb-calendar .tdb-grid button.tdb-day.is-free { background: #fff; border-color: var(--tdb-line); color: var(--tdb-ink); }
.tdb-calendar .tdb-grid button.tdb-day.is-booked { background: var(--tdb-red); border-color: var(--tdb-red); color: #fff; }
.tdb-calendar .tdb-grid button.tdb-day.is-locked { background: var(--tdb-yellow); border-color: var(--tdb-yellow); color: var(--tdb-yellow-ink); }
.tdb-calendar .tdb-grid button.tdb-day.is-na,
.tdb-calendar .tdb-grid button.tdb-day.is-past { background: #fff; border-color: #e3e7e5; color: #b5bbb8; }
/* Past days: grey, normal weight */
.tdb-calendar .tdb-grid button.tdb-day.is-past .tdb-num { font-weight: 400; }
/* Today: thin grey ring around the day, whatever its status */
.tdb-calendar .tdb-grid button.tdb-day.is-today { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #8c9690; z-index: 1; }
.tdb-calendar .tdb-grid button.tdb-day.is-booked .tdb-p,
.tdb-calendar .tdb-grid button.tdb-day.is-locked .tdb-p { color: inherit; }



/* While choosing the departure day */
.tdb-calendar .tdb-grid button.tdb-day.is-dim { opacity: .45; }
.tdb-calendar .tdb-grid button.tdb-day.is-short:not(.is-start) .tdb-num { opacity: .5; }

/* Selected range (after status rules, same specificity, so these win) */
.tdb-calendar .tdb-grid button.tdb-day.is-in { background: var(--tdb-green-soft); border-color: var(--tdb-green-soft); color: var(--tdb-ink); opacity: 1; }
.tdb-calendar .tdb-grid button.tdb-day.is-in.is-preview { background: #d3e9db; border-color: #d3e9db; }
.tdb-calendar .tdb-grid button.tdb-day.is-in .tdb-p { color: var(--tdb-ink); }
.tdb-calendar .tdb-grid button.tdb-day.is-start,
.tdb-calendar .tdb-grid button.tdb-day.is-end { background: var(--tdb-green); border-color: var(--tdb-green); color: #fff; opacity: 1; }
.tdb-calendar .tdb-grid button.tdb-day.is-start .tdb-p,
.tdb-calendar .tdb-grid button.tdb-day.is-end .tdb-p { color: #fff; }
/* Mouse preview of the departure day: light, so it reads as "not chosen yet" */
.tdb-calendar .tdb-grid button.tdb-day.is-end.is-preview { background: var(--tdb-green-soft); border-color: var(--tdb-green); color: var(--tdb-ink); }
/* Departure on a day someone else arrives (turnover): keeps its own colour, green border */
.tdb-calendar .tdb-grid button.tdb-day.is-end.is-preview.is-booked { background: var(--tdb-red); color: #fff; }
.tdb-calendar .tdb-grid button.tdb-day.is-end.is-preview.is-locked { background: var(--tdb-yellow); color: var(--tdb-yellow-ink); }


/* Hover (mouse only: on phones a tapped day would otherwise keep a green border).
   Only the border changes, so the price stays readable. */
@media (hover: hover) and (pointer: fine) {
    .tdb-calendar .tdb-grid button.tdb-day.is-free:not(:disabled):hover,
    .tdb-calendar .tdb-grid button.tdb-day.is-target:not(:disabled):hover { border-color: var(--tdb-green); }
}

/* Legend */
.tdb-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin: 12px 0;
    font-size: .85rem;
    color: var(--tdb-muted);
}
.tdb-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tdb-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--tdb-line); }
.tdb-swatch.is-free { background: #fff; }
.tdb-swatch.is-locked { background: var(--tdb-yellow); border-color: var(--tdb-yellow); }
.tdb-swatch.is-booked { background: var(--tdb-red); border-color: var(--tdb-red); }
.tdb-swatch.is-na { background: var(--tdb-na); }

/* Summary bar under the calendar: sticks to the bottom of the screen on phones */
.tdb-summary {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--tdb-line);
    border-radius: 8px;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
    font-size: .95rem;
}
.tdb-summary.is-done { border-color: var(--tdb-green); }
.tdb-hint { color: var(--tdb-ink); }
.tdb-note {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    background: #fff4d6;
    color: var(--tdb-yellow-ink);
    font-size: .9rem;
}
.tdb-dates { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.tdb-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

.tdb-calendar .tdb-summary button.tdb-link,
.tdb-calendar .tdb-summary button.tdb-link:hover,
.tdb-calendar .tdb-summary button.tdb-link:focus,
.tdb-calendar .tdb-status button.tdb-link,
.tdb-calendar .tdb-status button.tdb-link:hover {
    margin: 0;
    padding: 8px 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    color: var(--tdb-green);
    font: inherit;
    font-weight: 600;
    text-transform: none;
    text-decoration: underline;
    cursor: pointer;
}
.tdb-calendar .tdb-summary button.tdb-go,
.tdb-calendar .tdb-summary button.tdb-go:hover,
.tdb-calendar .tdb-summary button.tdb-go:focus {
    margin: 0;
    padding: 12px 22px;
    border: 0;
    border-radius: 25px;
    background: var(--tdb-green);
    box-shadow: none;
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-transform: none;
    cursor: pointer;
}
.tdb-calendar .tdb-summary button.tdb-go:hover { background: var(--tdb-green-dark); }

/* Form sits next to the calendar (any screen size): it already shows dates + price */
/* With the form on the page, the bar under the calendar only shows warnings */
.tdb-calendar .tdb-summary.has-form { position: static; padding: 0; border: 0; box-shadow: none; background: none; margin-top: 4px; }
.tdb-calendar .tdb-summary.has-form:not(.has-note) { display: none; }
.tdb-calendar.is-beside .tdb-summary.has-form { display: none; } /* form next to it shows the warning */
.tdb-calendar .tdb-summary.has-form .tdb-note { margin: 0; }
/* Extra padding row keeps the height stable next to the form; not needed when stacked */
.tdb-calendar:not(.is-beside) .tdb-empty.is-pad { display: none; }

/* Price block (summary + #show_total in the form) */
.tdb-price { margin-top: 6px; }
.tdb-price-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.tdb-price-total { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--tdb-line); font-weight: 700; font-size: 1.05rem; }
.tdb-price-note { margin-top: 4px; font-size: .85rem; line-height: 1.35; min-height: 2.7em; color: var(--tdb-muted); }
.tdb-price-note.is-warn { color: #8a5a00; font-weight: 600; }
.tdb-muted { color: var(--tdb-muted); font-weight: 400; }

@media (min-width: 600px) {
    .tdb-grid { gap: 6px; padding: 10px; }
    .tdb-calendar .tdb-grid button.tdb-day,
    .tdb-calendar .tdb-grid button.tdb-day:hover,
    .tdb-calendar .tdb-grid button.tdb-day:focus,
    .tdb-calendar .tdb-grid button.tdb-day:active,
    .tdb-calendar .tdb-empty { min-height: 60px; }
    .tdb-calendar .tdb-num { font-size: 1.1rem; }
    .tdb-calendar .tdb-p { font-size: .8rem; }
    .tdb-wd { font-size: .85rem; padding: 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .tdb-calendar .tdb-grid button.tdb-day { transition: none; }
}

/* ---------------- Booking form (moved from inline styles) ---------------- */

.booking-form-wrapper {
    box-sizing: border-box;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.booking-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}

.booking-form input,
.booking-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px; /* 16px stops iPhone from zooming in on focus */
    font-family: inherit;
    box-sizing: border-box;
}

.booking-form input:focus,
.booking-form textarea:focus {
    outline: none;
    border-color: #00563f;
}

.booking-form .full-width { grid-column: 1 / -1; }
.booking-form textarea { resize: vertical; }

.tdb-date-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.tdb-date-field span { font-size: .85rem; font-weight: 600; color: var(--tdb-muted); }
.booking-form .tdb-date-field input { cursor: pointer; background: #f7f9f8; caret-color: transparent; }

.booking-form .tdb-form-calendar { margin: 0; }
#show_total:empty { display: none; }
.tdb-form-hint { color: var(--tdb-muted); font-size: .95rem; }
#show_total { padding: 10px 12px; border-radius: 6px; background: #f3f5f4; }

.booking-form .submit-btn {
    grid-column: 1 / -1;
    padding: 14px 24px;
    background-color: #00563f;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    width: fit-content;
}
.booking-form .submit-btn:hover { background-color: #004230; }
.booking-form .submit-btn:disabled { background-color: #ccc; cursor: not-allowed; }

.booking-form .form-message {
    grid-column: 1 / -1;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}
.booking-form .form-message.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.booking-form .form-message.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

@media (max-width: 600px) {
    .booking-form { grid-template-columns: 1fr; }
    /* Phone: no card around the form, so the fields use the full width */
    .booking-form-wrapper { padding: 14px; }
}

/*
 * Old rule from the previous plugin version ("width: 350px !important" on
 * phones) can still be loaded from elsewhere. Win over it, always.
 */
html body .booking-form-wrapper {
    width: 100% !important;
    max-width: 520px !important;
    box-sizing: border-box !important;
}
