/**
 * Remmerzelt Reservation — Frontend Styles
 */

/* Visually hidden utility — keeps content available to assistive tech but
   off-screen for sighted users. Used for skip links, hidden labels, and
   the canvas-status live region. The --focusable variant becomes visible
   on keyboard focus (skip link pattern). */
.remmerzelt-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.remmerzelt-sr-only--focusable:focus,
.remmerzelt-sr-only--focusable:active {
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 12px;
    padding: 8px 12px;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: #fff;
    color: #1976D2;
    border: 2px solid #1976D2;
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

/* Date tabs */
.remmerzelt-date-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 0 4px;
}

.remmerzelt-date-tab {
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    transition: all 0.2s ease;
}

.remmerzelt-date-tab:hover:not(:disabled) {
    border-color: #1976D2;
    color: #1976D2;
}

.remmerzelt-date-tab--active {
    background: #1976D2;
    border-color: #1976D2;
    color: #fff;
}

.remmerzelt-date-tab--active:hover {
    background: #0D62C3;
    border-color: #0D62C3;
    color: #fff;
}

.remmerzelt-date-tab--booked-out {
    opacity: 0.5;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* Timeslot tabs (shown only when the current date has configured slots) */
.remmerzelt-timeslot-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin: -4px 0 12px;
    padding: 0 4px;
}
.remmerzelt-timeslot-tabs[hidden] { display: none; }

.remmerzelt-timeslot-tabs__label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-right: 4px;
}

.remmerzelt-timeslot-tab {
    padding: 6px 12px;
    border: 2px solid #ddd;
    border-radius: 16px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.remmerzelt-timeslot-tab:hover:not(:disabled) {
    border-color: #1976D2;
    color: #1976D2;
}

.remmerzelt-timeslot-tab--active {
    background: #1976D2;
    border-color: #1976D2;
    color: #fff;
}

.remmerzelt-timeslot-tab--active:hover {
    background: #0D62C3;
    border-color: #0D62C3;
    color: #fff;
}

.remmerzelt-timeslot-tab--booked-out {
    opacity: 0.5;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* Container layout */
.remmerzelt-container {
    position: relative;
    display: flex;
    gap: 24px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #333;
}

@media (max-width: 1024px) {
    .remmerzelt-container {
        flex-direction: column;
    }
}

/* Map section */
.remmerzelt-map-section {
    flex: 1 1 auto;
    min-width: 0;
}

.remmerzelt-canvas-wrap {
    /* position: relative anchors the spinner overlay below. The aspect-ratio
       that reserves the wrap's height before Konva inserts canvases is set
       inline from Shortcode.php (per-event canvas dims). */
    position: relative;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
}

/* Absolute overlay so spinner removal doesn't shift layout. */
.remmerzelt-canvas-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* Fallback for iOS Safari ≤ 14 / Android Chrome < 88 / Firefox < 89. Without
   aspect-ratio support the wrap collapses to 0 before canvases arrive and
   the spinner overlay disappears. */
@supports not (aspect-ratio: 1) {
    .remmerzelt-canvas-wrap {
        min-height: 300px;
    }
}

.remmerzelt-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    /* #2196F3 (Material 500 blue) fails 4.5:1 against #f9f9f9 — use the
       saturated 700 variant that the rest of the file already standardises on. */
    border-top-color: #1976D2;
    border-radius: 50%;
    animation: remmerzeltSpin 0.8s linear infinite;
}

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

/* Loading state during date/timeslot switches. opacity-only dim (no blur)
   so existing tables stay legible; pointer-events:none blocks accidental
   clicks on stale tables. JS removes the attribute on idle, so the
   not-busy state uses :not() rather than [aria-busy="false"]. */
.remmerzelt-canvas-wrap[aria-busy="true"] {
    opacity: 0.65;
    pointer-events: none;
    transition: opacity 0.18s ease-out;
}
.remmerzelt-canvas-wrap:not([aria-busy="true"]) {
    opacity: 1;
    transition: opacity 0.25s ease-out;
}
.remmerzelt-sidebar-placeholder--loading .remmerzelt-quick-add {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.18s ease-out;
}
/* prefers-reduced-motion: skip the opacity transitions; the static dim
   is still applied so the loading-state semantics are preserved. */
@media (prefers-reduced-motion: reduce) {
    .remmerzelt-canvas-wrap[aria-busy="true"],
    .remmerzelt-canvas-wrap:not([aria-busy="true"]),
    .remmerzelt-sidebar-placeholder--loading .remmerzelt-quick-add {
        transition: none;
    }
}

/* Legend */
.remmerzelt-map-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.remmerzelt-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #555;
}

.remmerzelt-legend-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.remmerzelt-freshness {
    font-size: 12px;
    color: #767676;
    margin-top: 4px;
}

.remmerzelt-freshness--stale {
    color: #e67e22;
}

.remmerzelt-legend-free {
    background: #388E3C;
}

.remmerzelt-legend-partial {
    background: #B56B00;
}

.remmerzelt-legend-full {
    background: #D32F2F;
}

.remmerzelt-legend-selected {
    background: #1976D2;
}

.remmerzelt-legend-suggested {
    background: #7B1FA2;
}

.remmerzelt-legend-blocked {
    background: #9E9E9E;
}

/* Sidebar */
.remmerzelt-sidebar {
    flex: 0 0 340px;
    min-width: 300px;
}

@media (max-width: 1024px) {
    .remmerzelt-sidebar {
        flex: 1 1 auto;
        max-width: 500px;
    }
}

/* Mobile optimizations */
@media (max-width: 600px) {
    .remmerzelt-container {
        gap: 16px;
    }

    .remmerzelt-canvas-wrap {
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Prevent horizontal swipe past the container edge from triggering
           the browser's back gesture (iOS Safari) or pull-to-refresh
           (Firefox Android) — both feel like spontaneous reloads. */
        overscroll-behavior-x: contain;
    }

    .remmerzelt-canvas-scrollable::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 24px;
        background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.08));
        pointer-events: none;
        z-index: 1;
        transition: opacity 0.3s;
    }

    .remmerzelt-canvas-scrolled-end::after {
        opacity: 0;
    }

    .remmerzelt-sidebar {
        min-width: 0;
        max-width: none;
    }

    .remmerzelt-legend-item {
        font-size: 13px;
    }

    .remmerzelt-legend-dot {
        width: 14px;
        height: 14px;
    }
}

.remmerzelt-sidebar-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 28px 24px;
    text-align: center;
    color: #6d6d6d;
    font-size: 15px;
    line-height: 1.6;
}

/* Process info (collapsible) */
.remmerzelt-process-info {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.remmerzelt-process-info summary {
    padding: 10px 14px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.remmerzelt-process-info summary::before {
    content: '\25B8';
    font-size: 12px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.remmerzelt-process-info[open] summary::before {
    transform: rotate(90deg);
}

.remmerzelt-process-info summary::-webkit-details-marker {
    display: none;
}

.remmerzelt-process-info ol {
    margin: 0 0 4px 0;
    padding: 0 14px 12px 32px;
    color: #555;
}

.remmerzelt-process-info ol li {
    margin-bottom: 6px;
}

.remmerzelt-process-info ol li:last-child {
    margin-bottom: 0;
}

.remmerzelt-process-info ol ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
    list-style: disc;
    color: #555;
}

/* Table info */
.remmerzelt-table-info {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 16px;
}

.remmerzelt-table-info h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.remmerzelt-info-seats {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

/* Notice */
.remmerzelt-notice {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.remmerzelt-notice-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.remmerzelt-notice p {
    margin: 0;
}

/* Connectivity warning */
.remmerzelt-connectivity-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 8px 40px 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 8px;
    text-align: center;
    position: relative;
}

.remmerzelt-connectivity-warning__dismiss {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    color: #856404;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    min-width: 28px;
    min-height: 28px;
}

.remmerzelt-connectivity-warning__dismiss:hover {
    color: #5e4700;
}

.remmerzelt-connectivity-warning__dismiss:focus-visible {
    outline: 2px solid #856404;
    outline-offset: 2px;
}

/* Buttons */
.remmerzelt-btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1.4;
}

.remmerzelt-btn-primary {
    background: #1976D2;
    color: #fff;
}

.remmerzelt-btn-primary:hover {
    background: #0D62C3;
}

.remmerzelt-btn-secondary {
    background: #388E3C;
    color: #fff;
}

.remmerzelt-btn-secondary:hover {
    background: #2E7D32;
}

.remmerzelt-btn-danger {
    background: #D32F2F;
    color: #fff;
}

.remmerzelt-btn-danger:hover {
    background: #B71C1C;
}

.remmerzelt-btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.remmerzelt-btn-cancel {
    background: #5a6268;
    color: #fff;
}

.remmerzelt-btn-cancel:hover {
    background: #495057;
}

.remmerzelt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Unified focus ring — 3 px, 0.4 alpha, ≥ 3:1 contrast vs adjacent
   colors per WCAG 2.4.11 (Focus Appearance, AA in 2.2). */
.remmerzelt-btn:focus-visible,
.remmerzelt-date-tab:focus-visible,
.remmerzelt-timeslot-tab:focus-visible,
.remmerzelt-btn-remove:focus-visible,
.remmerzelt-btn-max:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.4);
}

.remmerzelt-people-input:focus-visible {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.4);
}

.remmerzelt-btn-remove:focus-visible {
    color: #1976D2;
    border-radius: 3px;
}

/* Selected tables */
.remmerzelt-selected-tables {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 16px;
}

.remmerzelt-selected-tables h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
}

.remmerzelt-selected-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.remmerzelt-selected-row:last-child {
    border-bottom: none;
}

.remmerzelt-selected-info {
    display: flex;
    flex-direction: column;
}

.remmerzelt-selected-info strong {
    font-size: 14px;
}

.remmerzelt-selected-seats {
    font-size: 12px;
    color: #666;
}

.remmerzelt-selected-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.remmerzelt-selected-controls label {
    font-size: 13px;
    color: #555;
}

.remmerzelt-people-input {
    width: 55px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.remmerzelt-btn-remove {
    background: none;
    border: none;
    color: #6d6d6d;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    /* WCAG 2.5.8 (AA, neu in 2.2): Touch-Target ≥ 24×24 CSS px. */
    min-width: 32px;
    min-height: 32px;
}

.remmerzelt-btn-remove:hover {
    color: #D32F2F;
}

/* Quick-add dropdown */
.remmerzelt-quick-add {
    margin: 12px 0 4px 0;
}

.remmerzelt-quick-add-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.remmerzelt-quick-add-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.remmerzelt-quick-add-select {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #333;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.remmerzelt-quick-add-select:focus-visible {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.4);
}

.remmerzelt-quick-add-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.remmerzelt-quick-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.remmerzelt-quick-add-empty {
    font-size: 13px;
    color: #999;
    font-style: italic;
    margin: 0;
}

#remmerzelt-sidebar-placeholder .remmerzelt-quick-add {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed #ddd;
}

/* Max seats button */
.remmerzelt-btn-max {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 3px;
    color: #1565C0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    line-height: 1;
    transition: background-color 0.2s;
    /* WCAG 2.5.8 (AA, neu in 2.2): Touch-Target ≥ 24×24 CSS px. */
    min-width: 32px;
    min-height: 28px;
}

.remmerzelt-btn-max:hover {
    background: #bbdefb;
}

@media (max-width: 600px) {
    .remmerzelt-quick-add-select {
        font-size: 16px;
        padding: 10px 12px;
    }
}

#remmerzelt-proceed-form {
    margin-top: 12px;
    width: 100%;
}

/* Reservation form wrap */
.remmerzelt-reservation-form-wrap {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
}

/* Confirmation modal — viewport-fixed so it is always centered in view regardless of
   #remmerzelt-app height / scroll position. Appended to <body>, so it carries its own
   font stack (previously inherited from .remmerzelt-container). High z-index clears
   sticky theme headers. */
.remmerzelt-confirm-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100000;
    overscroll-behavior: contain;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #333;
}

.remmerzelt-confirm-dialog {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 24px;
    max-width: 380px;
    width: 90%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    text-align: center;
    animation: remmerzeltDialogIn 0.22s ease-out;
}

.remmerzelt-confirm-title {
    margin: 0 0 8px 0;
    font-size: 17px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.3;
}

.remmerzelt-confirm-text {
    margin: 0 0 16px 0;
    font-size: 15px;
    color: #333;
    line-height: 1.5;
}

.remmerzelt-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.remmerzelt-confirm-actions .remmerzelt-btn {
    flex: 1;
    max-width: 160px;
}

/* Confirm-dialog entrance animations */
@keyframes remmerzeltDialogIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes remmerzeltSheetIn {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Bottom-sheet presentation on phones + tablets (≤1024px, matches the renderer/layout
   breakpoint): full-width, pinned to the bottom edge, thumb-reachable. */
@media (max-width: 1024px) {
    .remmerzelt-confirm-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .remmerzelt-confirm-dialog {
        width: 100%;
        max-width: none;
        border-radius: 16px 16px 0 0;
        padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
        max-height: 85vh;
    }

    /* Keep the action row from stretching across a wide tablet sheet. */
    .remmerzelt-confirm-actions {
        max-width: 360px;
        margin-left: auto;
        margin-right: auto;
    }

    .remmerzelt-confirm-actions .remmerzelt-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
}

/* Sheet slide-up only when motion is allowed; the reduced-motion block below stays
   authoritative (it sets the dialog animation to none). */
@media (max-width: 1024px) and (prefers-reduced-motion: no-preference) {
    .remmerzelt-confirm-dialog {
        animation: remmerzeltSheetIn 0.25s ease-out;
    }
}

/* Fade-in animation */
@keyframes remmerzeltFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.remmerzelt-fade-in {
    animation: remmerzeltFadeIn 0.3s ease-out;
}

/* Arrival-time picker in the sidebar (between table list and "Weiter zur Reservierung") */
#remmerzelt-arrival-picker {
    margin: 12px 0 16px;
}

#remmerzelt-arrival-picker label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: #333;
}

#remmerzelt-arrival-picker select {
    width: 100%;
    padding: 8px 10px;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

#remmerzelt-arrival-picker select:focus-visible {
    border-color: #1976D2;
    outline: none;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.4);
}

.remmerzelt-arrival-error {
    color: #c72b20;
    font-size: 13px;
    margin: 6px 0 0;
    min-height: 1em;
}

/* Respect prefers-reduced-motion: skip the decorative fade-in.
   The Konva spinner and the fade animations elsewhere are decorative —
   the underlying state is conveyed via aria-live regions, so removing
   the motion does not remove information. */
@media (prefers-reduced-motion: reduce) {
    .remmerzelt-fade-in {
        animation: none;
    }
    .remmerzelt-confirm-dialog {
        animation: none;
    }
    .remmerzelt-spinner {
        animation-duration: 2.4s;
    }
}
