
body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #f4f4f9; }

.app-container { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

.mobile-warning-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.mobile-warning-card {
    width: min(420px, 100%);
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #d1d5db;
    box-shadow: 0 16px 36px rgba(2, 6, 23, 0.35);
    padding: 18px 16px 14px;
    position: relative;
}

.mobile-warning-card h3 {
    margin: 0 28px 10px 0;
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
}

.mobile-warning-card p {
    margin: 0 0 14px;
    color: #334155;
    line-height: 1.5;
    font-size: 14px;
}

.mobile-warning-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    padding: 0;
    margin: 0;
    box-shadow: none;
    font-size: 18px;
    line-height: 1;
}

.mobile-warning-close:hover {
    background: #f8fafc;
    transform: none;
}

.sidebar {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    background: #ffffff;
    padding: 22px;
    border-right: 1px solid #ddd;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    overflow-y: auto;
    z-index: 10;
    color: #333;
}

.sidebar-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(14, 165, 233, 0.18);
    background: rgba(14, 165, 233, 0.08);
    color: #0f766e;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.sidebar-back-link:hover {
    transform: translateY(-1px);
    background: rgba(14, 165, 233, 0.14);
    border-color: rgba(14, 165, 233, 0.38);
}

.sidebar-title-wrap {
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid #eee;
}

.sidebar-kicker {
    margin: 0 0 6px;
    color: #0891b2;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.32em;
    text-transform: uppercase;
}

.sidebar h2 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.05em;
    color: #111827;
}

.control-group { margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #eee; }
.control-group h3 { margin-top: 0; font-size: 12px; color: #0f766e; text-transform: uppercase; letter-spacing: 0.24em; font-weight: 900; }

input, select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #ffffff;
    color: #333;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

input::placeholder, textarea::placeholder {
    color: #9ca3af;
}

button {
    display: block; width: 100%; padding: 10px; margin-bottom: 10px;
    background: #2c3e50;
    color: white; border: none; border-radius: 14px;
    cursor: pointer; transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease; font-weight: 900;
    letter-spacing: 0.06em;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}
button:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 14px 26px rgba(0,0,0,0.12); }

.head-table-controls { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.head-table-controls input { flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 12px; text-align: center; background: #ffffff; color: #333; }
.head-table-controls button { margin-top: 5px; }

textarea { width: 100%; height: 80px; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 14px; resize: vertical; background: #ffffff; color: #333; }

.table-create-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.table-create-controls select {
    grid-column: 1 / span 2;
}

.guest-add-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
}

.guest-add-row input {
    margin-bottom: 0;
}

.guest-add-row button {
    width: auto;
    min-width: 84px;
    margin-bottom: 0;
    padding-inline: 14px;
}

.inline-toggle {
    grid-column: 1 / span 2;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4d5a67;
}

.inline-toggle input {
    width: auto;
    margin: 0;
}

.table-size-extra {
    grid-column: 1 / span 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.hidden {
    display: none;
}

.table-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding-right: 4px;
}

.table-list-item {
    border: 1px solid #d9d9d9;
    border-radius: 14px;
    padding: 8px;
    background: #fbfbfd;
}

.table-list-item.active {
    border-color: #2c3e50;
    background: #eef3f7;
}

.table-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}

.table-item-head button {
    width: auto;
    margin: 0;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 999px;
}

.table-editor {
    border: 1px dashed #c4c4c4;
    border-radius: 16px;
    padding: 10px;
    background: #fafafa;
}

.table-editor.empty-state {
    color: #777;
    font-size: 13px;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.editor-grid .full {
    grid-column: 1 / span 2;
}

.small-note {
    margin: 0 0 8px;
    font-size: 12px;
    color: #666;
}

.status-message {
    margin-top: 8px;
    min-height: 20px;
    font-size: 12px;
    color: #2d4f66;
}

.guest-pool {
    min-height: 56px;
    border: 1px dashed #b3b9bf;
    border-radius: 16px;
    background: #f8fafc;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.guest-chip {
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 999px;
    padding: 5px 6px 5px 10px;
    font-size: 12px;
    border: 1px solid #c8d2dc;
    background: #ffffff;
    color: #333;
    cursor: grab;
    user-select: none;
    position: relative;
    min-height: 28px;
}

.remove-guest-btn {
    background: transparent;
    color: #e74c3c;
    border: none;
    font-size: 16px;
    line-height: 14px;
    cursor: pointer;
    padding: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: 8px;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Ignore clicks until hovered */
}

.guest-chip:hover .remove-guest-btn {
    opacity: 1;
    pointer-events: auto; /* Enable clicks */
}

.remove-guest-btn:hover {
    background: rgba(231,76,60,0.1);
}

.guest-chip:active {
    cursor: grabbing;
}

.selected-table-guests {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.selected-table-guests li {
    border: 1px solid #d7dde3;
    border-radius: 12px;
    background: #fff;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.selected-table-guests li.drag-target {
    border-color: #2c3e50;
    background: #edf3f8;
}

.guest-item-actions {
    display: flex;
    gap: 4px;
}

.guest-item-actions button {
    width: auto;
    margin: 0;
    padding: 5px 8px;
    font-size: 11px;
}

.canvas-container {
    flex-grow: 1;
    position: relative;
    background: radial-gradient(circle at top, #111114 0%, #09090b 100%);
    overflow: auto;
}

/* Draggable Table Styles */
.table-widget {
    position: absolute;
    background: rgba(244, 244, 245, 0.98);
    border: 2px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: #111827;
    cursor: grab;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    white-space: pre-line; /* Allows line breaks in JS text */
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    text-align: center;
}
.table-widget:active { cursor: grabbing; box-shadow: 0 6px 12px rgba(0,0,0,0.2); }

.table-widget.selected {
    border-color: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34,211,238,0.18), 0 6px 12px rgba(0,0,0,0.2);
}

.table-widget.overflow {
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244,63,94,0.18), 0 6px 12px rgba(0,0,0,0.2);
}

.table-title {
    font-size: 12px;
    font-weight: 700;
    margin-top: 24px;
}

.table-desc {
    font-size: 10px;
    color: #475569;
}

.floating-guest {
    position: absolute;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: grab;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border: 2px solid var(--sidebar-header-bg);
}

.remove-floating-btn {
    background: transparent;
    color: #e74c3c;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 16px;
    line-height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.remove-floating-btn:hover {
    background: rgba(231, 76, 60, 0.1);
}

.table-meta {
    font-size: 11px;
    color: #475569;
}

.table-meta.warn {
    color: #be123c;
}

.table-preview {
    font-size: 10px;
    color: #67737f;
    line-height: 1.2;
}

.table-circle { border-radius: 50%; }
.table-square { border-radius: 8px; }
.table-rectangle { border-radius: 8px; }

/* Visual Seats */
.seat {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: all 0.2s;
    user-select: none;
}

.seat.occupied {
    background: #3498db;
    border-color: #2980b9;
    cursor: grab;
}

.seat.occupied:active {
    cursor: grabbing;
}

.seat.drag-target {
    transform: translate(-50%, -50%) scale(1.5);
    background: #f1c40f;
    border-color: #f39c12;
}

.seat-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    color: #e2e8f0;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    font-weight: normal;
}

/* Modal */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}
.modal.hidden { display: none; }
.modal-content {
    background: #fff; border-radius: 18px; width: 450px;
    max-width: 90%; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 18px 40px rgba(0,0,0,0.45);
    border: 1px solid rgba(63, 63, 70, 0.75);
}
.modal-header {
    padding: 15px 20px; border-bottom: 1px solid rgba(63, 63, 70, 0.75);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; }
.modal-header button {
    background: none; border: none; font-size: 24px; cursor: pointer; color: #a1a1aa;
    width: auto; padding: 0; margin: 0;
}
.modal-header button:hover { background: none; color: #67e8f9; }
.modal-body { padding: 20px; }
.modal-section { margin-bottom: 20px; }
.modal-section h4 { margin: 0 0 10px 0; }
.modal-add-guest {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
}
.modal-add-guest input,
.modal-add-guest select {
    margin: 0;
    padding: 8px;
}
.modal-add-guest button {
    width: auto;
    margin: 0;
    padding: 8px 12px;
    min-width: 120px;
}

.layout-insights {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 300px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    z-index: 950;
}

.layout-insights-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.layout-insights h3 {
    margin: 0;
    font-size: 12px;
    color: #0f766e;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 900;
}

.layout-insights-toggle {
    width: 28px;
    min-width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    box-shadow: none;
}

.layout-insights-toggle:hover {
    background: #f8fafc;
    transform: none;
}

.layout-insights.collapsed {
    width: auto;
    min-width: 190px;
    max-width: 220px;
    padding: 8px 10px;
    overflow: hidden;
}

.layout-insights.collapsed .layout-insights-header {
    justify-content: space-between;
    margin-bottom: 0;
}

.layout-insights.collapsed #layout-insights-body {
    display: none;
}

.insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.insight-find-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: center;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #ffffff;
    padding: 6px 8px;
    margin-bottom: 10px;
}

.insight-find-icon {
    font-size: 14px;
    opacity: 0.8;
}

#layout-insights-find {
    border: none;
    margin: 0;
    padding: 4px 2px;
    background: transparent;
    color: #0f172a;
    box-shadow: none;
}

#layout-insights-find:focus {
    outline: none;
}

.insight-card {
    border: 1px solid #d9d9d9;
    border-radius: 12px;
    background: #fbfbfd;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.insight-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
    font-weight: 700;
}

.insight-value {
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
}

.insight-dropdown {
    border: 1px solid #d9d9d9;
    border-radius: 12px;
    padding: 8px 10px;
    background: #fff;
    margin-top: 8px;
}

.insight-dropdown summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.insight-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 11px;
    font-weight: 800;
    padding: 0 8px;
}

.insight-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insight-list li {
    font-size: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 6px 8px;
    background: #f8fafc;
}

.modal-seats-input {
    width: 140px;
    margin-bottom: 4px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    color: var(--text-color);
}

.modal-shape-select {
    width: 160px;
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    color: var(--text-color);
}

.modal-seat-style-select {
    width: 220px;
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    color: var(--text-color);
}

.table-actions {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 6px;
    z-index: 20;
}

.table-widget.actions-at-head .table-actions {
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
}

.table-action-btn {
    background: #fff; border: 1px solid #ccc;
    border-radius: 50%; width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-size: 13px; padding-bottom: 1px; color: #333;
}
.table-action-btn:hover { background: #f0f0f0; border-color: #999; }

@keyframes findPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.45);
    }
    100% {
        box-shadow: 0 0 0 8px rgba(14, 165, 233, 0);
    }
}

.search-hit {
    border-color: #0ea5e9 !important;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35), 0 0 12px rgba(14, 165, 233, 0.35) !important;
    animation: findPulse 1s ease-out infinite;
}

.search-hit-text {
    background: rgba(14, 165, 233, 0.2);
    border-radius: 6px;
    padding-inline: 2px;
    color: #0f172a !important;
    text-shadow: none !important;
}

/* Theme & New Elements */
:root {
    --bg-color: #f4f4f9;
    --sidebar-bg: #ffffff;
    --border-color: #ddd;
    --text-color: #333;
    --text-muted: #555;
    --btn-bg: #2c3e50;
    --btn-hover: #1a252f;
    --item-bg: #fbfbfd;
    --item-border: #d9d9d9;
    --active-border: #2c3e50;
    --active-bg: #eef3f7;
    --canvas-bg1: #f0f0f0;
    --canvas-bg2: #f4f4f9;
    --modal-bg: rgba(0,0,0,0.5);
}

* { box-sizing: border-box; font-family: 'Inter', sans-serif; color: var(--text-color); }
body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; background: var(--bg-color); }

.sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--border-color); }
.control-group { border-bottom: 1px solid var(--border-color); }
.control-group h3 { color: var(--text-muted); }
input, select, textarea { background: #ffffff; border: 1px solid var(--border-color); color: var(--text-color); }
button { background: var(--btn-bg); }
button:hover { background: var(--btn-hover); }
.table-list-item { border: 1px solid var(--item-border); background: var(--item-bg); }
.table-list-item.active { border-color: var(--active-border); background: var(--active-bg); }
.canvas-container { background: repeating-linear-gradient(45deg, var(--canvas-bg1), var(--canvas-bg1) 10px, var(--canvas-bg2) 10px, var(--canvas-bg2) 20px); }

.top-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 1000;
    background: var(--sidebar-bg);
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    align-items: center;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-color);
    border: none;
    box-shadow: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.06);
    transform: scale(1.05);
}
.icon-btn:active {
    transform: scale(0.95);
}

.csv-columns-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 6px;
}
.csv-column-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.csv-column-item input {
    width: auto; margin: 0;
}
.modal-content { background: var(--sidebar-bg); color: var(--text-color); }
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-header button { color: var(--text-muted); }
.modal-header button:hover { color: var(--text-color); }

.sidebar h2,
.modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.04em;
}

.sidebar,
.table-list-item,
.table-editor,
.guest-pool,
.selected-table-guests li,
.modal-content {
    backdrop-filter: blur(14px);
}

.table-list-item button,
.table-item-head button,
.table-action-btn,
.icon-btn {
    font-family: 'Inter', sans-serif;
}

.small-note,
.status-message,
.table-meta,
.table-desc,
.table-editor.empty-state {
    color: var(--text-muted);
}

.sidebar-kicker,
.control-group h3 {
    text-shadow: 0 0 16px rgba(34, 211, 238, 0.12);
}

@media print {
    body * { visibility: hidden; }
    #floorplan, #floorplan * { visibility: visible; }
    #floorplan { position: absolute; left: 0; top: 0; width: 100vw; height: 100vh; overflow: hidden; border: none; background: transparent; padding: 0; margin: 0; }
}

.modal-title-input {
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-color);
    margin-bottom: 4px;
    width: 100%;
}
.modal-title-input:focus {
    border-bottom-color: var(--primary-color);
    outline: none;
}
.modal-desc-input {
    font-size: 13px;
    color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #f8fafc;
    padding: 8px 10px;
    width: 100%;
    margin-bottom: 0;
}
.modal-desc-input:focus {
    border-color: #0ea5e9;
    background: #ffffff;
    outline: none;
}

@media (max-width: 1080px) {
    .layout-insights {
        top: 10px;
        right: 12px;
        width: 280px;
        max-height: calc(100vh - 20px);
    }
}
