/* htdocs/assets/style.css */

:root {
    --color-primary: #0056b3;
    --color-secondary: #f0f0f0;
    --color-success: #28a745;
    --color-available: #d4edda;
    --color-occupied: #dc3545;
    --color-selected: #ffc107;
    --color-text: #333;
    --color-border: #ccc;
}

[hidden] { display: none !important; }
#auth-nav a { display: inline-block; color: white; margin-left: 12px; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.admin-tabs button, .admin-panel button { padding: 10px 16px; border: 1px solid var(--color-border); border-radius: 4px; cursor: pointer; }
.admin-tabs button[aria-pressed="true"] { background: var(--color-primary); color: white; }
.admin-panel { padding: 24px; background: white; border-radius: 8px; }
.admin-panel h2 { margin-bottom: 16px; }
.admin-panel fieldset { padding: 20px; border: 1px solid var(--color-border); border-radius: 6px; }
.admin-panel legend { padding: 0 8px; font-weight: bold; }
.admin-panel label:not(.checkbox-label) { display: block; font-weight: bold; margin: 14px 0 6px; }
.admin-panel input:not([type="checkbox"]), .admin-panel select { width: 100%; padding: 10px; border: 1px solid var(--color-border); border-radius: 4px; }
.admin-panel form { max-width: 700px; }
.admin-panel button[type="submit"] { margin-top: 18px; background: var(--color-primary); color: white; }
.admin-panel button:disabled { opacity: .6; }
.admin-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.checkbox-label input { width: 20px; height: 20px; flex-shrink: 0; }
.form-help { margin: 10px 0; color: #555; font-size: .9em; }
.admin-table-wrap { margin-top: 24px; overflow-x: auto; }
.admin-table-wrap table { border-collapse: collapse; width: 100%; text-align: left; }
.admin-table-wrap caption { text-align: left; margin-bottom: 12px; font-weight: bold; }
.admin-table-wrap th, .admin-table-wrap td { border-bottom: 1px solid var(--color-border); padding: 10px; }
.report-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
.report-controls > div { flex: 1 1 240px; }
.report-controls button { margin-bottom: 0; }
.report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.report-stats > div { background: #f1f5f9; border-radius: 6px; padding: 14px; }
.report-stats dt { color: #555; }
.report-stats dd { font-size: 1.5rem; font-weight: bold; overflow-wrap: anywhere; }
#report-disabled { color: #555; }
#panel-reports tfoot { font-weight: bold; }
.bookings-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.bookings-heading p { flex: 1 1 260px; }
.bookings-heading button { padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 4px; cursor: pointer; }
.bookings-summary { margin-top: 8px; font-size: .95rem; font-weight: bold; overflow-wrap: anywhere; }
.booking-card { margin: 16px 0; padding: 18px; background: white; border: 1px solid var(--color-border); border-radius: 8px; overflow-wrap: anywhere; }
.booking-card h2 { font-size: 1.15rem; }
.booking-card h3 { margin-top: 10px; }
.booking-card ul { margin: 12px 0; padding-left: 22px; }
#bookings-user { color: white; margin-left: 12px; overflow-wrap: anywhere; }
@media (max-width: 850px) {
    .admin-columns { grid-template-columns: minmax(0, 1fr); }
    .admin-panel { padding: 12px; }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: #f8f9fa;
}

header {
    background: var(--color-primary);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.site-brand { display: flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%; }
.site-brand h1 { min-width: 0; overflow-wrap: anywhere; }
/* Il ritaglio centrale elimina soltanto i margini bianchi del file originale. */
.site-logo { display: block; flex: none; width: 140px; height: 56px; object-fit: cover; object-position: center; background: white; border-radius: 4px; }
#auth-nav { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }

header h1 {
    font-size: 1.8em;
}

#auth-nav button {
    margin-left: 10px;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: white;
    color: var(--color-primary);
}

#auth-nav button.logout {
    background-color: #dc3545;
    color: white;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

#app-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* --- Login Section --- */
#login-section {
    max-width: 400px;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

#login-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 10px;
}

.message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.hidden {
    display: none !important;
}

/* --- Main App Layout --- */
.control-panel {
    display: flex;
    gap: 20px;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.control-panel .form-group {
    margin-bottom: 0;
}
.control-panel select {
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
}

/* --- Seat Grid --- */
#seat-grid-container {
    margin-top: 30px;
    text-align: center;
}

#seat-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    width: max-content;
    transform-origin: top left;
}

.seat-row {
    display: flex;
    justify-content: flex-start;
    gap: 6px;
    align-items: center;
}

.seat {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.8em;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    border: 1px solid #ddd;
}

.seat:hover:not(.occupied) {
    transform: scale(1.05);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

/* Stati dei posti */
.seat.available {
    background-color: var(--color-available);
    color: #155724;
    border-color: #80bd95;
}

.seat.occupied {
    background-color: var(--color-occupied);
    color: white;
    cursor: not-allowed;
    opacity: 1;
    border-color: var(--color-occupied);
}

.seat.selected {
    background-color: var(--color-selected);
    color: var(--color-text);
    border: 2px solid #e0a800;
    transform: scale(1.1);
}

/* --- Summary Box --- */
.summary-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}
.summary-box h3 {
    margin-bottom: 10px;
}

#selected-count {
    font-size: 2em;
    color: var(--color-primary);
    font-weight: bold;
}

#selected-list {
    list-style: none;
    margin: 15px 0;
    text-align: left;
    max-height: 150px;
    overflow-y: auto;
    border-top: 1px solid var(--color-border);
    padding-top: 10px;
}

#selected-list li {
    padding: 5px 0;
    font-size: 0.9em;
}

#confirm-booking-btn {
    padding: 12px 25px;
    font-size: 1.1em;
    background-color: var(--color-success);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
    transition: background-color 0.2s;
}
#confirm-booking-btn:hover:not(:disabled) {
    background-color: #1e7e34;
}
#confirm-booking-btn:disabled {
    background-color: #90ee90;
    cursor: not-allowed;
}

button, input, select { font: inherit; }
button:disabled { cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #0056b3; outline-offset: 3px; }
.message:empty { display: none; }
.notice { margin: 20px 0; }
.booking-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.summary-box { position: sticky; top: 20px; }
#seat-grid-container { margin-top: 0; padding: 8px; }
.seat { flex: 0 0 44px; width: 44px; height: 44px; font-size: .85em; }
.row-label { flex: 0 0 72px; width: 72px; text-align: center; overflow-wrap: anywhere; font-size: 14px; }
.stage { background: #e2e6ea; border-radius: 50%; padding: 12px; margin: 20px auto; max-width: 400px; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin: 15px 0; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 18px; height: 18px; border: 1px solid; border-radius: 3px; }
.legend-swatch.available { background-color: var(--color-available); border-color: #80bd95; }
.legend-swatch.occupied { background-color: var(--color-occupied); border-color: var(--color-occupied); }
.legend-swatch.selected { background-color: var(--color-selected); border-color: #e0a800; }
.control-panel { flex-wrap: wrap; }
.control-panel .form-group { flex: 1 1 180px; }
@media (max-width: 850px) {
    .booking-layout { grid-template-columns: minmax(0, 1fr); }
    .summary-box { position: static; }
    header { flex-wrap: wrap; gap: 12px; padding: 15px; }
    header h1 { font-size: 1.4em; }
    .site-brand { gap: 8px; }
    .site-logo { width: 100px; height: 40px; }
    main { padding: 12px; }
}

.aisle-form { margin-top: 24px; }
.aisle-list { list-style: none; margin-top: 16px; }
.aisle-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.aisle { display: block; background: #e2e6ea; color: #56616b; }
.aisle-vertical { flex: 0 0 26px; height: 44px; border-left: 1px dashed #89949d; border-right: 1px dashed #89949d; }
.labelled-aisle { flex-basis: 80px; width: 80px; display: flex; align-items: center; justify-content: center; }
.labelled-aisle .row-label { flex: 1; width: auto; padding: 0 4px; }
.row-places { display: flex; justify-content: center; align-items: center; gap: 6px; flex: none; }
.row-half { display: flex; align-items: center; gap: 6px; flex: none; }
.row-left { justify-content: flex-end; }
.row-right { justify-content: flex-start; }
.aisle-horizontal { width: 100%; height: 28px; font-size: 12px; line-height: 26px; text-align: center; border-top: 1px dashed #89949d; border-bottom: 1px dashed #89949d; }
.seat-gap { display: block; flex: 0 0 44px; width: 44px; height: 44px; border: 1px dashed #d6dce0; border-radius: 4px; background: #f1f3f5; }
#seat-map-viewport { min-width: 0; min-height: 0; flex: 1; display: grid; place-items: center; overflow: hidden; touch-action: none; user-select: none; }
#seat-map-frame { position: relative; flex: none; }
.booking-page { touch-action: pan-x pan-y; }
.booking-page input, .booking-page select { font-size: 16px; }
.map-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; flex: none; }
.map-tools { display: flex; align-items: center; gap: 4px; }
.map-tools button { padding: 4px 8px; min-height: 32px; border: 1px solid var(--color-border); border-radius: 4px; background: white; color: var(--color-text); cursor: pointer; }
.map-tools button:disabled { opacity: .5; cursor: default; }
#map-zoom-level { min-width: 42px; text-align: center; font-size: 12px; }
#seat-map-viewport.map-zoomed { cursor: grab; }
#seat-map-viewport.map-zoomed #seat-grid { will-change: transform; }
#seat-map-viewport.map-dragging { cursor: grabbing; }

/* La sala occupa lo spazio disponibile; il riepilogo può scorrere, la mappa si ridimensiona. */
body.booking-active { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.booking-active header { flex: none; padding: 10px 16px; gap: 8px; }
.booking-active header h1 { font-size: 1.25rem; }
.booking-active #app-container { flex: 1; min-height: 0; width: 100%; max-width: none; padding: 10px; gap: 8px; }
.booking-active #app-message { flex: none; max-height: 54px; overflow: auto; margin: 0; padding: 6px; }
.booking-active #main-app { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.booking-active .control-panel { flex: none; padding: 8px; gap: 12px; }
.booking-active .control-panel label { margin-bottom: 2px; font-size: .85rem; }
.booking-active .control-panel select { padding: 6px; }
.booking-active .notice { flex: none; margin: 0; font-size: .8rem; }
.booking-active .booking-layout { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; align-items: stretch; }
.booking-active #seat-grid-container { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: white; border-radius: 8px; }
.booking-active #seat-grid-container h2 { flex: none; font-size: 1rem; }
.booking-active .stage { flex: none; width: min(70%, 400px); padding: 4px; margin: 6px auto; font-size: .85rem; }
.booking-active .legend { flex: none; margin: 4px 0; font-size: .8rem; gap: 12px; }
.booking-active .legend-swatch { width: 14px; height: 14px; }
.booking-active .summary-box { position: static; min-height: 0; display: flex; flex-direction: column; padding: 12px; overflow: hidden; }
.booking-active .summary-box h2 { font-size: 1rem; }
.booking-active #selected-count { font-size: 1.4rem; }
.selection-totals { flex: none; }
.selection-totals p { margin: 2px 0; }
#booking-dialog { margin: auto; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 20px; border: 0; border-radius: 10px; box-shadow: 0 12px 40px #0004; }
#booking-dialog::backdrop { background: #0008; }
#booking-dialog h2 { margin-bottom: 12px; }
#review-seats { margin: 12px 0; padding-left: 24px; }
#review-seats li { margin: 4px 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.dialog-actions button { flex: 1 1 180px; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: 4px; font: inherit; cursor: pointer; }
#review-confirm-btn { background: var(--color-success); color: white; border-color: var(--color-success); }
.dialog-actions button:disabled { opacity: .6; cursor: default; }
.booking-active #selected-list { min-height: 0; flex: 1; max-height: none; margin: 8px 0; padding-top: 6px; }
.booking-active #confirm-booking-btn { flex: none; font-size: 1rem; padding: 10px; margin-top: 4px; }
.booking-active #confirmation-message { flex: none; margin-top: 6px; padding: 6px; max-height: 80px; overflow: auto; }
@media (max-width: 699px), (max-width: 900px) and (max-height: 500px) {
    .booking-active .booking-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 8px; }
    .booking-active .summary-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; padding: 5px 8px; }
    .booking-active .selection-totals { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: .8rem; line-height: 1.35; }
    .booking-active .selection-totals p { margin: 0; }
    .booking-active #selected-count { font-size: 1rem; }
    .booking-active .summary-box h2 { display: none; }
    .booking-active #confirm-booking-btn { grid-column: 2; grid-row: 1; padding: 8px 10px; margin: 0; font-size: .85rem; }
    .booking-active #selected-list { display: none; }
    .booking-active #selected-list:empty { display: none; }
    .booking-active #confirmation-message { grid-column: 1 / -1; max-height: 42px; margin: 0; }
    .booking-active .control-panel { gap: 6px; }
    .booking-active .control-panel .form-group { flex: 1 1 130px; }
    .booking-active #app-container { padding: 6px; }
    .booking-active .control-panel { padding: 4px 6px; }
    .booking-active .control-panel .form-group { min-width: 0; }
    .booking-active .map-heading { gap: 2px 8px; }
}
@media (max-width: 900px) and (max-height: 500px) {
    .booking-active header { padding: 4px 10px; }
    .booking-active header h1 { font-size: 1rem; }
    .booking-active .site-logo { width: 84px; height: 34px; }
    .booking-active #app-container { padding: 6px; gap: 4px; }
    .booking-active #main-app { gap: 4px; }
    .booking-active .control-panel { flex-wrap: nowrap; padding: 4px; }
    .booking-active .control-panel .form-group { flex: 1 1 0; min-width: 0; }
    .booking-active .summary-box { padding: 4px 8px; max-height: none; }
    .booking-active .selection-totals { display: flex; flex-wrap: wrap; gap: 4px 16px; }
    .booking-active #selected-count { font-size: 1rem; }
    .booking-active #seat-grid-container { padding: 4px; }
    .booking-active .stage { margin: 2px auto; padding: 2px; }
    .booking-active .legend { margin: 2px 0; }
}
