/**
 * BA-LI Seat Map Styles
 *
 * FIXED VERSION - addresses:
 * - Map takes most of the page
 * - Sidebar for cart on the left
 * - Price legend at bottom in single row
 * - Better responsive behavior
 */

/* ============================================
   SEAT PAGE LAYOUT
   ============================================ */

.bali-seat-page {
    min-height: 100vh;
    background: var(--bali-light, #f4f4f4);
}

.bali-seat-page__container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.bali-seat-page__header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.bali-seat-page__back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--bali-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.bali-seat-page__back:hover {
    background: var(--bali-light);
}

.bali-seat-page__event-info {
    flex: 1;
}

.bali-seat-page__title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--bali-dark);
}

.bali-seat-page__meta {
    font-size: 14px;
    color: #666;
}

/* Lock Timer */
.bali-lock-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff3cd;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    color: #856404;
}

.bali-lock-timer[hidden] {
    display: none;
}

.bali-lock-timer.is-warning {
    background: #f8d7da;
    color: #721c24;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================
   MAIN LAYOUT: Map + Sidebar
   ============================================ */

.bali-seat-page__layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px 0;
    min-height: calc(100vh - 80px);
    position: relative;
}

.bali-seat-page__layout.has-selection {
    grid-template-columns: 1fr 360px;
}

/* Sidebar (Cart) - Hidden until selection */
.bali-seat-page__sidebar {
    display: none;
    order: 1; /* Sidebar on right */
}

.bali-seat-page__layout.has-selection .bali-seat-page__sidebar {
    display: block;
}

.bali-seat-page__sidebar-inner {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 24px;
    position: sticky;
    top: 100px;
    border: 2px solid var(--bali-dark);
}

.bali-seat-page__sidebar-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

/* Selected Seats List */
.bali-seat-page__selected {
    min-height: 150px;
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.bali-seat-map__empty-state {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 40px 20px;
}

.bali-selected-seat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bali-light);
    border-radius: 10px;
    margin-bottom: 8px;
}

.bali-selected-seat__info {
    flex: 1;
}

.bali-selected-seat__label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--bali-dark);
}

.bali-selected-seat__details {
    font-size: 13px;
    color: #666;
}

.bali-selected-seat__price {
    font-weight: 700;
    font-size: 15px;
    color: var(--bali-dark);
    white-space: nowrap;
}

.bali-selected-seat__remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #d63638;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bali-selected-seat__remove:hover {
    background: #d63638;
    color: #fff;
}

/* Totals */
.bali-seat-page__totals {
    padding: 16px 0;
    border-top: 2px solid #eee;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.bali-seat-page__total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bali-seat-page__total-row span {
    font-size: 16px;
    color: #666;
}

.bali-seat-page__total-row strong {
    font-size: 24px;
    font-weight: 700;
    color: var(--bali-dark);
}

/* Actions */
.bali-seat-page__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================
   MAP AREA
   ============================================ */

.bali-seat-page__map-area {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

.bali-seat-page__map-wrapper {
    flex: 1;
    min-height: calc(100vh - 250px);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    overflow: hidden;
}

/* Legend Bar at Bottom */
.bali-seat-page__legend-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bali-light);
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 16px;
}

.bali-seat-page__seats-count {
    font-size: 14px;
    color: #666;
}

.bali-seat-page__seats-count strong {
    color: var(--bali-dark);
    font-weight: 700;
}

/* ============================================
   SEAT MAP SVG
   ============================================ */

#bali-seat-map {
    width: 100%;
    height: 100%;
    min-height: 450px;
    position: relative;
}

.bali-seat-map__svg {
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

.bali-seat-map__svg.is-dragging {
    cursor: grabbing;
}

/* Stage */
.bali-stage__rect {
    fill: var(--bali-dark, #181818);
}

.bali-stage__label {
    fill: #fff;
    font-size: 20px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
}

/* Section Labels */
.bali-section__label {
    fill: #333;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Row Labels */
.bali-row__label {
    font-size: 10px;
    fill: #666;
    font-family: inherit;
    pointer-events: none;
    user-select: none;
}

.bali-seat__number {
    font-size: 7px;
    fill: rgba(0,0,0,0.6);
    font-family: inherit;
    pointer-events: none;
    user-select: none;
    font-weight: 600;
}

.bali-seat--selected ~ text.bali-seat__number,
.bali-seat__number--selected {
    fill: black;
}

/* Section Labels */
.bali-section__label {
    fill: #333;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================================
   SEATS
   ============================================ */

.bali-seat {
    cursor: pointer;
    transition: fill 0.15s, stroke-width 0.15s;
}

.bali-seat:hover {
    stroke: #000;
    stroke-width: 3;
}

/* Available */
.bali-seat--available {
    fill: #4CAF50;
}

.bali-seat--available:hover {
    fill: #388E3C;
}

/* Selected (by current user) */
.bali-seat--selected {
    fill: #2563EB !important;   /* כחול ברור */
    stroke: #1D4ED8;
    stroke-width: 2;
    filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.6));
}

.bali-seat--selected:hover {
    fill: #1976D2;
}

/* Locked (by another user) */
.bali-seat--locked {
    fill: #FFB300;
    cursor: not-allowed;
}

.bali-seat--locked:hover {
    transform: none;
}

/* Sold */
.bali-seat--sold {
    fill: #9E9E9E;
    cursor: not-allowed;
}

.bali-seat--sold:hover {
    transform: none;
}

/* Special seat types */
.bali-seat--wheelchair {
    stroke: #9C27B0;
    stroke-width: 2;
}

.bali-seat--vip {
    stroke: #FFD700;
    stroke-width: 2;
}

/* Not for sale */
.bali-seat--unavailable {
    fill: #E0E0E0;
    cursor: not-allowed;
}

/* ============================================
   PRICE LEGEND (Compact)
   ============================================ */

.bali-price-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.bali-price-legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.bali-price-legend__color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.bali-price-legend__label {
    color: #666;
}

.bali-price-legend__price {
    font-weight: 600;
    color: var(--bali-dark);
}

/* Status Legend */
.bali-price-legend__divider {
    width: 1px;
    height: 20px;
    background: #ddd;
    margin: 0 8px;
}

.bali-price-legend__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #888;
}

.bali-price-legend__status-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.bali-price-legend__status-dot--available {
    background: #4CAF50;
}

.bali-price-legend__status-dot--selected {
    background: #2196F3;
}

.bali-price-legend__status-dot--locked {
    background: #FFB300;
}

.bali-price-legend__status-dot--sold {
    background: #9E9E9E;
}

/* ============================================
   ZOOM CONTROLS
   ============================================ */

.bali-seat-map__zoom {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.bali-seat-map__zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.bali-seat-map__zoom-btn:hover {
    background: var(--bali-light);
}

/* Loading Overlay */
#bali-seat-map-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

#bali-seat-map-loading[hidden] {
    display: none;
}

.bali-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bali-light);
    border-top-color: var(--bali-dark);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .bali-seat-page__layout,
    .bali-seat-page__layout.has-selection {
        grid-template-columns: 1fr;
    }

    .bali-seat-page__layout.has-selection .bali-seat-page__sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        display: block;
    }

    .bali-seat-page__layout.has-selection .bali-seat-page__sidebar-inner {
        position: static;
        border-radius: 16px 16px 0 0;
        max-height: 50vh;
        overflow-y: auto;
    }

    .bali-seat-page__map-wrapper {
        min-height: calc(100vh - 200px);
    }
}

@media (max-width: 640px) {
    .bali-seat-page__header {
        flex-wrap: wrap;
    }

    .bali-seat-page__title {
        font-size: 18px;
    }

    .bali-seat-page__meta {
        font-size: 13px;
    }

    .bali-lock-timer {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .bali-seat-page__legend-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .bali-price-legend {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================
   ERROR STATE
   ============================================ */

.bali-seat-page--error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.bali-seat-page__error-box {
    text-align: center;
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    max-width: 400px;
}

.bali-seat-page__error-box h1 {
    font-size: 24px;
    margin: 0 0 16px;
}

.bali-seat-page__error-box p {
    color: #666;
    margin: 0 0 24px;
}
/* ============================================
   SIDEBAR TIMER
   ============================================ */

.bali-sidebar-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: #dc3545;
    color: #fff;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 18px;
}

.bali-sidebar-timer[hidden] {
    display: none;
}

.bali-sidebar-timer__icon {
    font-size: 20px;
}