/* AppointlyWP – Booking Widget
 *
 * Design-Tokens werden als CSS Custom Properties auf .appointly-booking
 * definiert. Der Shortcode überschreibt sie per Inline-<style> auf der
 * jeweiligen Widget-Instanz (#appointly-form-{id}). Das ermöglicht
 * unterschiedliche Themes auf derselben Seite, ohne JS zu benötigen.
 *
 * Überschreibbar via:
 *   [appointly_booking id="1" primary_color="#2563eb" border_radius="4" max_width="600"]
 * oder global über AppointlyWP → Einstellungen → Design.
 */

.appointly-booking {
    /* ── Primärfarbe + Ableitungen ───────────────────────────── */
    --apw-primary:        #4f46e5;   /* Buttons, ausgewählte Tage, aktive Slots  */
    --apw-primary-light:  #eef2ff;   /* Helle Flächen: verfügbare Tage, Slots   */
    --apw-primary-mid:    #c7d2fe;   /* Hover-States, Slot-Borders               */
    --apw-primary-dark:   #4338ca;   /* Button :hover                            */

    /* ── Typografie & Farben ─────────────────────────────────── */
    --apw-text:           #111827;
    --apw-text-label:     #374151;
    --apw-text-muted:     #6b7280;
    --apw-text-faint:     #9ca3af;

    /* ── Borders & Hintergründe ──────────────────────────────── */
    --apw-border:         #e5e7eb;
    --apw-border-input:   #d1d5db;
    --apw-border-light:   #f3f4f6;
    --apw-bg:             #fff;

    /* ── Border-Radius ───────────────────────────────────────── */
    --apw-radius-sm:      6px;       /* Search-Input, kleine Elemente            */
    --apw-radius:         8px;       /* Inputs, Dropdowns, Buttons               */
    --apw-radius-full:    20px;      /* Slot-Buttons (Pill-Form)                 */

    /* ── Layout ──────────────────────────────────────────────── */
    --apw-max-width:      520px;

    max-width: var(--apw-max-width);
    font-family: inherit;
    color: var(--apw-text);
}

/* ── Layout: alle Sektionen untereinander ───── */

.appointly-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── 2-Spalten-Layout ────────────────────────
 * Aktiviert durch: [appointly_booking layout="two-column"]
 * oder globale Einstellung Layout = Zwei Spalten.
 * Links: Auswahl (Standort, Service, Datum, Slots)
 * Rechts: Formularfelder + Submit
 */
.appointly-booking.apw-layout-two .appointly-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
    align-items: start;
}

/* Formularfelder + Submit rechts fixieren */
.appointly-booking.apw-layout-two #s-fields {
    grid-column: 2;
    grid-row: 1 / 99;      /* überspannt alle linken Zeilen */
    border-bottom: none;
    border-left: 1px solid var(--apw-border);
    padding: 0 0 0 32px;
}

/* Auf schmalen Viewports (< 600px) immer eine Spalte */
@media ( max-width: 600px ) {
    .appointly-booking.apw-layout-two .appointly-layout {
        grid-template-columns: 1fr;
    }
    .appointly-booking.apw-layout-two #s-fields {
        grid-column: 1;
        grid-row: auto;
        border-left: none;
        padding: 20px 0 0;
    }
}

.appointly-section {
    border-bottom: 1px solid var(--apw-border);
    padding: 20px 0;
    transition: opacity .2s;
}
.appointly-section:last-child { border-bottom: none; }

.appointly-section.is-disabled {
    opacity: .35;
    pointer-events: none;
    user-select: none;
}

.appointly-section-label {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--apw-text-muted);
    margin-bottom: 10px;
}

.appointly-hint {
    font-size: .875rem;
    color: var(--apw-text-faint);
    margin: 0;
}

/* ── Searchable Dropdown ─────────────────────── */

.appointly-select {
    position: relative;
}

.appointly-select-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--apw-border-input);
    border-radius: var(--apw-radius);
    background: var(--apw-bg);
    cursor: pointer;
    transition: border-color .15s;
}
.appointly-select-box:hover { border-color: var(--apw-primary); }

.appointly-select-input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-size: .95rem;
    font-family: inherit;
    color: var(--apw-text);
    cursor: pointer;
    outline: none;
    caret-color: transparent;
}

.appointly-select-caret {
    padding: 0 12px;
    color: var(--apw-text-faint);
    font-size: .8rem;
    pointer-events: none;
}

/* Dropdown-Panel */
.appointly-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--apw-bg);
    border: 1px solid var(--apw-border);
    border-radius: var(--apw-radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    z-index: 100;
    overflow: hidden;
}
.appointly-select-dropdown.is-open { display: block; }

.appointly-select-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--apw-border-light);
}

.appointly-select-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--apw-border);
    border-radius: var(--apw-radius-sm);
    font-size: .875rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.appointly-select-search:focus { border-color: var(--apw-primary); }

.appointly-select-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 220px;
    overflow-y: auto;
}

.appointly-select-opt {
    padding: 9px 14px;
    font-size: .9rem;
    cursor: pointer;
    transition: background .1s;
}
.appointly-select-opt:hover       { background: var(--apw-primary-light); }
.appointly-select-opt.is-selected { background: var(--apw-primary-light); color: var(--apw-primary); font-weight: 600; }

/* ── Calendar ────────────────────────────────── */

.appointly-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.appointly-cal-prev,
.appointly-cal-next {
    background: none;
    border: 1px solid var(--apw-border);
    border-radius: var(--apw-radius-sm);
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--apw-text-label);
    transition: background .1s, border-color .1s;
}
.appointly-cal-prev:hover,
.appointly-cal-next:hover { background: var(--apw-border-light); border-color: var(--apw-border-input); }

.appointly-cal-month {
    font-weight: 600;
    font-size: .95rem;
}

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

.appointly-cal-head {
    text-align: center;
    font-size: .7rem;
    font-weight: 700;
    color: var(--apw-text-faint);
    padding: 4px 0 8px;
    letter-spacing: .04em;
}

.appointly-cal-day {
    aspect-ratio: 1;
    border: none;
    border-radius: var(--apw-radius-full);
    font-size: .875rem;
    font-family: inherit;
    cursor: default;
    background: transparent;
    color: var(--apw-border-input);
    transition: background .1s, color .1s;
}

.appointly-cal-day.is-available {
    color: var(--apw-primary);
    font-weight: 600;
    cursor: pointer;
    background: var(--apw-primary-light);
}
.appointly-cal-day.is-available:hover { background: var(--apw-primary-mid); }

.appointly-cal-day.is-selected {
    background: var(--apw-primary) !important;
    color: #fff !important;
}

/* ── Slot list ───────────────────────────────── */

.appointly-slot-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.appointly-slot-btn {
    padding: 8px 14px;
    background: var(--apw-primary-light);
    border: 1px solid var(--apw-primary-mid);
    border-radius: var(--apw-radius-full);
    color: var(--apw-primary);
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .1s, color .1s;
}
.appointly-slot-btn:hover       { background: var(--apw-primary-mid); }
.appointly-slot-btn.is-selected { background: var(--apw-primary); color: #fff; border-color: var(--apw-primary); }

/* ── Form fields ─────────────────────────────── */

.appointly-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}
.appointly-field:last-of-type { margin-bottom: 0; }

.appointly-field label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--apw-text-label);
}

.appointly-req { color: #ef4444; }

.appointly-field input,
.appointly-field textarea {
    padding: 9px 12px;
    border: 1px solid var(--apw-border-input);
    border-radius: var(--apw-radius);
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
    background: var(--apw-bg);
}
.appointly-field input:focus,
.appointly-field textarea:focus { border-color: var(--apw-primary); }
.appointly-field textarea { min-height: 80px; resize: vertical; }

/* ── Radio / Checkbox Gruppen ────────────────── */

.appointly-field-label {
    display: block;
    margin-bottom: 2px;
}

.appointly-choice-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.appointly-choice-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    color: var(--apw-text);
    cursor: pointer;
    line-height: 1.4;
}

.appointly-choice-label input[type="radio"],
.appointly-choice-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--apw-primary);
    cursor: pointer;
}

.appointly-error {
    display: none;
    margin: 12px 0;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--apw-radius);
    color: #dc2626;
    font-size: .875rem;
}

.appointly-submit-btn {
    width: 100%;
    margin-top: 16px;
    padding: 13px;
    background: var(--apw-primary);
    color: #fff;
    border: none;
    border-radius: var(--apw-radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s;
}
.appointly-submit-btn:hover:not(:disabled) { background: var(--apw-primary-dark); }
.appointly-submit-btn:disabled { opacity: .5; cursor: default; }

/* ── Success ─────────────────────────────────── */

.appointly-success {
    text-align: center;
    padding: 40px 16px;
}

.appointly-success-icon {
    width: 60px; height: 60px;
    background: #dcfce7;
    color: #16a34a;
    border-radius: 50%;
    font-size: 1.8rem;
    line-height: 60px;
    margin: 0 auto 16px;
}

.appointly-success h3 { margin: 0 0 8px; font-size: 1.25rem; }
.appointly-success p  { color: var(--apw-text-muted); margin: 0; line-height: 1.6; }
