/* ============================================
   Page & Container Layout
   ============================================ */
html, body.organizer-page {
    margin: 0;
    padding: 0;
    height: 100%;
    height: 100dvh;
    overflow: hidden; /* Prevents viewport scroll */
    box-sizing: border-box;
}

/* <main> needs an explicit height so that .container's height:100% has a
   definite value to resolve against. Without this, the height percentage
   chain is ambiguous and flex falls back to sizing children (including
   the SVG map) by their own intrinsic content/aspect ratio instead of
   the actual available screen space. */
main {
    display: block;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 12px;
    box-sizing: border-box;
}

.back-btn-container {
    flex-shrink: 0;
}

.page-title {
    margin: 4px 0 12px 0;
    font-size: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

/* ============================================
   Table map (SVG)
   ============================================
   The map is rendered as a single SVG with a viewBox matching the
   table layout's bounding box. Because of preserveAspectRatio, the
   browser itself scales the whole map to fit any container size or
   orientation - no JS resize/scale math required. */
.table-grid {
    flex: 1;
    min-height: 0; /* Critical for dynamic sizing inside flexboxes */
    min-width: 0;
    max-width: fit-content;
    width: 100%;
    justify-content: center;
    align-items: center;
    align-self: center;
    overflow: hidden;
}

.hall-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hall-background {
    fill: #f5f5f5;
}

.table-shape {
    stroke: #666;
    stroke-width: 2;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.table-group:hover .table-shape {
    filter: brightness(0.94);
}

.table-group:focus-visible .table-shape {
    outline: none;
    stroke: #1a73e8;
    stroke-width: 3;
}

.table-number-text {
    font-weight: bold;
    fill: #333;
    user-select: none;
    pointer-events: none;
}

.table-sub-text {
    fill: #555;
    user-select: none;
    pointer-events: none;
}

.no-data-message,
.error-message {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

/* ============================================
   Guest info panel
   ============================================ */
.guest-info-panel {
    position: fixed;
    inset: 0;
    margin: auto;

    width: 90%;
    max-width: 450px;
    height: 85vh;
    height: 85dvh;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 18px;
    z-index: 1000;
    box-sizing: border-box;
}

.guest-info-panel.hidden {
    display: none;
}

.panel-title {
    margin-top: 0;
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.panel-section {
    margin-bottom: 16px;
    flex: 1; /* Allow sections to grow and share space */
    min-height: 0; /* Critical for proper flexbox sizing */
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 1rem;
    margin-bottom: 6px;
    color: #555;
    flex-shrink: 0;
}

.guest-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto; /* Enable scrolling for the list */
    flex: 1; /* Take remaining space in the section */
    min-height: 0; /* Critical for proper flexbox sizing */
}

.guest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    margin-bottom: 4px;
    background-color: #f9f9f9;
    border-radius: 4px;
    gap: 8px;
}

.guest-item.arrived {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.guest-item.pending {
    background-color: #ffebee;
    color: #c62828;
}

.guest-name {
    font-weight: bold;
}

.guest-relation {
    font-size: 0.8rem;
    color: #666;
}

.no-guests-message {
    text-align: center;
    padding: 10px;
    color: #666;
    font-style: italic;
}

.btn-close-top {
    position: absolute;
    top: 16px;
    inset-inline-end: 16px; /* adapts to rtl/ltr automatically */
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.btn-close-top:hover {
    color: #333;
    background-color: rgba(0, 0, 0, 0.1);
}

.btn-close-top:active {
    transform: scale(0.9);
}

/* ============================================
   Landscape orientation support
   ============================================ */

/* In landscape the panel has width to spare but less height, so lay the
   two guest lists out side-by-side instead of stacked, giving each list
   much more vertical room to scroll within. */
@media (orientation: landscape) {
    .guest-info-panel {
        max-width: 680px;
        height: 82vh;
        height: 82dvh;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "title   title"
            "arrived pending";
        column-gap: 16px;
        row-gap: 0;
    }

    .panel-title {
        grid-area: title;
    }

    .arrived-section {
        grid-area: arrived;
    }

    .pending-section {
        grid-area: pending;
    }

    .panel-section {
        margin-bottom: 0;
    }
}

/* Landscape + short height (phone held sideways): compact the header
   so the table map keeps maximum space, and give the panel more height */
@media (orientation: landscape) and (max-height: 500px) {
    .container {
        padding: 6px 12px;
    }

    .page-title {
        margin: 2px 0 6px 0;
        font-size: 1.1rem;
    }

    .back-btn-container .back-btn {
        padding: 4px 10px;
        font-size: 0.85rem;
    }

    .guest-info-panel {
        height: 92vh;
        height: 92dvh;
        padding: 10px 14px;
    }

    .panel-title {
        margin-bottom: 6px;
        padding-bottom: 4px;
    }

    .section-title {
        margin-bottom: 4px;
    }
}