/* css/components.css — table properties, guest list, alcohol totals, conflicts,
   seat popup, demand editor modal, print preview UI, room sharing */

/* --- Table properties panel --- */

#table-properties {
    margin-top: 10px;
    padding: 10px;
    background: #f8f4e9;
    border: 1px solid #e2dbc9;
    border-radius: 8px;
}

#table-properties h4 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #7a4a3a;
}

.rotation-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    font-size: 0.85rem;
}

.warning {
    font-size: 0.78rem;
    color: #b32323;
    background: #fbeceb;
    border-radius: 6px;
    padding: 6px 8px;
    margin: 6px 0;
}

/* --- Guest list --- */

#guest-list {
    list-style: none;
    max-height: 320px;
    overflow-y: auto;
}

.guest-group {
    margin-bottom: 12px;
}

.guest-group-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #7a4a3a;
    padding: 3px 2px;
    border-bottom: 1px solid #e2dbc9;
    margin-bottom: 5px;
}

.guest-group-list {
    list-style: none;
}

.guest-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: #fff;
    border: 1px solid #ece5d3;
}

.guest-chip.picked {
    border-color: #2f6fd1;
    background: #eaf1fc;
}

.guest-chip .swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.guest-info {
    flex-grow: 1;
    cursor: pointer;
    min-width: 0;
}

.guest-name {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guest-seat {
    font-size: 0.72rem;
    color: #6b6045;
}

.guest-drinks {
    font-size: 0.72rem;
    color: #7a4a3a;
}

.guest-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

/* --- Alcohol totals --- */

#drink-totals {
    list-style: none;
}

.drink-total {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 3px 4px;
    border-radius: 5px;
}

.drink-total:nth-child(odd) {
    background: #fbf8f0;
}

.drink-total.empty {
    color: #8a8270;
}

.drink-total-label {
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drink-total-count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.drink-code {
    flex-shrink: 0;
    min-width: 22px;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: #5a4636;
    background: #ece5d3;
    border-radius: 4px;
    padding: 1px 4px;
}

.drink-total.empty .drink-code {
    background: #f2eee4;
    color: #8a8270;
}

/* Short, fixed list – show all of it instead of scrolling like the guest lists. */
.drink-select {
    max-height: none;
}

.drink-select .checkbox-row .drink-code {
    margin-left: auto;
}

#drinks-empty-hint.hint {
    font-size: 0.75rem;
    color: #6b6045;
    margin-bottom: 6px;
}

/* --- Conflicts --- */

#conflict-list {
    list-style: none;
    max-height: 160px;
    overflow-y: auto;
}

.conflict-item {
    font-size: 0.8rem;
    color: #b32323;
    padding: 5px 6px;
    border-radius: 5px;
    cursor: pointer;
}

.conflict-item:hover {
    background: #fbeceb;
}

.conflict-empty {
    font-size: 0.8rem;
    color: #6b6045;
    padding: 5px 6px;
}

/* --- Seat-assign popup --- */

#seat-popup {
    position: absolute;
    background: #fffdf7;
    border: 1px solid #cbbf9e;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 10px;
    width: 220px;
    max-height: 340px;
    overflow-y: auto;
    z-index: 50;
}

#seat-popup h5 {
    font-size: 0.82rem;
    color: #7a4a3a;
    margin-bottom: 8px;
}

.seat-popup-current {
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #ece5d3;
}

.seat-popup-current-label {
    font-size: 0.7rem;
    color: #6b6045;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.seat-popup-current-name {
    font-size: 0.88rem;
    font-weight: 600;
    padding: 4px 0;
    cursor: pointer;
    border-radius: 4px;
}

.seat-popup-current-name:hover {
    color: #2f6fd1;
}

.seat-popup-vacate {
    width: 100%;
    margin-top: 4px;
}

.seat-popup-list-heading {
    font-size: 0.72rem;
    color: #6b6045;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.seat-popup-list {
    list-style: none;
}

.seat-popup-list li {
    padding: 5px 6px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
}

.seat-popup-list li:hover {
    background: #f1ead9;
}

/* Guests seated elsewhere: click to swap with this seat (or move them here). */
.seat-popup-swap-list {
    max-height: 132px;
    overflow-y: auto;
}

.seat-popup-swap-list li {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.seat-popup-swap-where {
    font-size: 0.72rem;
    color: #8a7f66;
}

.seat-popup-filter {
    width: 100%;
    margin-bottom: 4px;
    padding: 4px 6px;
    font-size: 0.8rem;
    border: 1px solid #cbbf9e;
    border-radius: 5px;
    background: #fff;
}

.seat-popup-empty {
    font-size: 0.8rem;
    color: #6b6045;
    padding: 4px 0;
}

/* --- Demand editor modal --- */

#demand-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(58, 50, 38, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.demand-panel {
    background: #fffdf7;
    border-radius: 10px;
    padding: 20px;
    width: 380px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.demand-panel h3 {
    margin-bottom: 14px;
    color: #7a4a3a;
}

.multi-select {
    margin-bottom: 14px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid #ece5d3;
    border-radius: 6px;
    padding: 8px;
}

.multi-select-label {
    font-size: 0.78rem;
    color: #6b6045;
    margin-bottom: 6px;
    font-weight: 600;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    padding: 3px 0;
    cursor: pointer;
}

.checkbox-row input {
    width: auto;
}

/* --- Print preview overlay --- */

#print-view {
    position: fixed;
    inset: 0;
    z-index: 200;
    overflow-y: auto;
    background: #5b5340;
    padding: 0 0 40px;
}

.print-toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #fffdf7;
    border-bottom: 1px solid #cbbf9e;
}

.print-toolbar-hint {
    flex-grow: 1;
    font-size: 0.82rem;
    color: #6b6045;
}

.print-doc {
    width: 186mm; /* A4 width minus the 12mm page margins set in @page */
    max-width: 100%;
    margin: 24px auto 0;
    color: #1a1a1a;
}

.print-page {
    background: #fff;
    padding: 16mm 12mm;
    margin-bottom: 18px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.print-title {
    font-size: 1.5rem;
    color: #3a3226;
}

.print-subtitle {
    font-size: 0.9rem;
    color: #4a4436;
    margin-top: 4px;
}

.print-heading {
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #3a3226;
    margin: 18px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #3a3226;
}

.print-page > .print-heading:first-child {
    margin-top: 0;
}

.print-overview {
    text-align: center;
}

.print-overview canvas,
.print-diagram canvas {
    max-width: 100%;
    height: auto; /* keeps the aspect ratio when the preview is narrower than the sheet */
}

.print-note {
    font-size: 0.8rem;
    line-height: 1.45;
    color: #4a4436;
    margin-top: 8px;
}

.print-note-muted {
    color: #7a7263;
}

/* --- Print: per-table cards --- */

.print-card {
    border: 1px solid #3a3226;
    border-radius: 4px;
    padding: 10px 12px;
    margin-top: 12px;
}

.print-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid #cbbf9e;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.print-card-title {
    font-size: 1.1rem;
    color: #1a1a1a;
}

.print-card-meta {
    font-size: 0.8rem;
    color: #4a4436;
    white-space: nowrap;
}

.print-card-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.print-diagram {
    flex-shrink: 0;
}

.print-seat-list {
    flex-grow: 1;
    list-style: none;
    min-width: 0;
}

.print-seat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px dotted #cbbf9e;
    font-size: 0.92rem;
}

.print-seat-row:last-child {
    border-bottom: none;
}

.print-seat-check {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    border: 1px solid #3a3226;
    border-radius: 2px;
}

.print-seat-num {
    width: 22px;
    flex-shrink: 0;
    font-weight: 700;
    text-align: right;
}

.print-seat-name {
    flex-grow: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.print-seat-drinks {
    display: block;
    font-size: 0.72rem;
    color: #4a4436;
}

.print-card-drinks {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #cbbf9e;
    font-size: 0.8rem;
    color: #4a4436;
}

.print-card-drinks-label {
    font-weight: 700;
}

.print-seat-row-empty .print-seat-name,
.print-seat-row-empty .print-seat-num {
    color: #8a8270;
    font-weight: 400;
}

/* --- Print: guest index --- */

.print-index {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.print-index th,
.print-index td {
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid #cbbf9e;
}

.print-index th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid #3a3226;
}

.print-index-name {
    font-weight: 600;
}

.print-index-unseated td {
    color: #8a8270;
}


/* ---- Room sharing ---- */

#room-section {
    border-bottom: 1px solid #ddd;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

#room-code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 1.6rem;
    letter-spacing: 0.12em;
    font-weight: 600;
    text-align: center;
    padding: 6px 0;
    user-select: all;
}

.room-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.room-status::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.room-status-live::before { background: #3cb44b; }
.room-status-connecting::before { background: #d4a017; }
.room-status-offline::before { background: #e6194b; }
.room-status-offline { color: #e6194b; }

#room-panel button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Toasts --- */

.toast-root {
    position: fixed;
    left: 50%;
    bottom: calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    z-index: var(--z-toast);
    width: min(420px, calc(100vw - 2 * var(--sp-4)));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4);
    border-radius: var(--radius-lg);
    background: var(--c-ink);
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
}

.toast-text { flex: 1; min-width: 0; }

.toast-action {
    flex: 0 0 auto;
    min-height: var(--tap-min);
    padding: 0 var(--sp-4);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-weight: 600;
}

.toast-action:hover { background: rgba(255, 255, 255, 0.15); }

/* --- Modal dialogs --- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: rgba(58, 50, 38, 0.45);
    z-index: var(--z-modal);
}

.modal {
    width: min(420px, 100%);
    max-height: 85dvh;
    overflow-y: auto;
    padding: var(--sp-5);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.modal-title { font-size: 1.05rem; color: var(--c-accent); margin-bottom: var(--sp-3); }
.modal-message { font-size: 0.9rem; line-height: 1.45; margin-bottom: var(--sp-4); }

.modal-error {
    min-height: 1.1rem;
    font-size: 0.8rem;
    color: var(--c-danger);
    margin-bottom: var(--sp-3);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
}

.modal-actions button { min-height: var(--tap-min); padding: 0 var(--sp-5); }
