/* ========================================
   BOOKINGS LIST REDESIGN 2026 - OSPITAMENTE
   Clean, modern, mobile-first with cards
======================================== */

:root {
    --bl-bg: #f8f9fc;
    --bl-surface: #ffffff;
    --bl-border: #e8ecf1;
    --bl-border-light: #f0f2f5;
    --bl-text: #1a1f36;
    --bl-text-secondary: #6b7280;
    --bl-text-muted: #9ca3af;
    --bl-accent: #3b82f6;
    --bl-accent-light: #eff6ff;
    --bl-confirmed: #10b981;
    --bl-pending: #f59e0b;
    --bl-checked-in: #3b82f6;
    --bl-checked-out: #94a3b8;
    --bl-cancelled: #ef4444;
    --bl-no-show: #8b5cf6;
    --bl-radius: 10px;
    --bl-radius-sm: 6px;
    --bl-shadow: 0 1px 3px rgba(0,0,0,0.06);
    --bl-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --bl-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   BASE
============================================ */
.bl-module {
    background: var(--bl-bg);
    font-family: var(--bl-font);
}

/* ============================================
   TOP BAR
============================================ */
.bl-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bl-surface);
    border-bottom: 1px solid var(--bl-border);
}

.bl-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--bl-text);
    margin: 0;
    letter-spacing: -0.3px;
}

.bl-actions {
    display: flex;
    gap: 8px;
}

.bl-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--bl-border);
    border-radius: 8px;
    background: var(--bl-surface);
    color: var(--bl-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--bl-font);
}

.bl-btn:hover {
    background: var(--bl-border-light);
}

.bl-btn-accent {
    background: var(--bl-accent);
    color: white;
    border-color: var(--bl-accent);
}

.bl-btn-accent:hover {
    background: #2563eb;
}

/* ============================================
   FILTRI
============================================ */
.bl-filters {
    padding: 12px 20px;
    background: var(--bl-surface);
    border-bottom: 1px solid var(--bl-border);
}

.bl-filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.bl-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.bl-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bl-text-muted);
    pointer-events: none;
}

.bl-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--bl-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--bl-font);
    color: var(--bl-text);
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.bl-search:focus {
    border-color: var(--bl-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.bl-select, .bl-date {
    padding: 8px 12px;
    border: 1px solid var(--bl-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--bl-font);
    color: var(--bl-text);
    background: var(--bl-surface);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.bl-select:focus, .bl-date:focus {
    border-color: var(--bl-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* Toggle */
.bl-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.bl-toggle:hover { background: var(--bl-border-light); }
.bl-toggle input { display: none; }

.bl-toggle-switch {
    width: 34px;
    height: 18px;
    background: #d1d5db;
    border-radius: 9px;
    position: relative;
    transition: background 0.3s;
}

.bl-toggle-switch::after {
    content: '';
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.bl-toggle input:checked + .bl-toggle-switch {
    background: var(--bl-accent);
}

.bl-toggle input:checked + .bl-toggle-switch::after {
    transform: translateX(16px);
}

.bl-toggle-text {
    font-size: 13px;
    color: var(--bl-text-secondary);
    font-weight: 500;
}

/* ============================================
   STATS
============================================ */
.bl-stats {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bl-surface);
    border-bottom: 1px solid var(--bl-border);
    overflow-x: auto;
}

.bl-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bl-bg);
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.bl-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--bl-text);
}

.bl-stat-label {
    font-size: 11px;
    color: var(--bl-text-muted);
    font-weight: 500;
}

.bl-stat.st-confirmed .bl-stat-value { color: var(--bl-confirmed); }
.bl-stat.st-pending .bl-stat-value { color: var(--bl-pending); }
.bl-stat.st-checkedin .bl-stat-value { color: var(--bl-checked-in); }
.bl-stat.st-cancelled .bl-stat-value { color: var(--bl-cancelled); }

/* ============================================
   TABELLA DESKTOP
============================================ */
.bl-table-wrap {
    overflow-x: auto;
    background: var(--bl-surface);
    -webkit-overflow-scrolling: touch;
}

.bl-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.bl-table thead th {
    background: var(--bl-bg);
    color: var(--bl-text-secondary);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--bl-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

.bl-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--bl-border-light);
    color: var(--bl-text);
    vertical-align: middle;
}

.bl-table tbody tr {
    transition: background 0.15s;
}

.bl-table tbody tr:hover {
    background: var(--bl-accent-light);
}

/* Stili celle specifiche */
.bl-table td strong {
    color: var(--bl-text);
}

.bl-table td small {
    color: var(--bl-text-muted);
    display: block;
    margin-top: 2px;
}

/* ============================================
   STATUS BADGES
============================================ */
.status-badge, .payment-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.status-confirmed { background: #d1fae5; color: #065f46; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-checked_in { background: #dbeafe; color: #1e40af; }
.status-checked_out { background: #e5e7eb; color: #374151; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-no_show { background: #ede9fe; color: #5b21b6; }

.payment-full { background: #d1fae5; color: #065f46; }
.payment-partial { background: #fef3c7; color: #92400e; }
.payment-unpaid { background: #fee2e2; color: #991b1b; }

/* ============================================
   ACTION BUTTONS
============================================ */
.action-buttons {
    display: flex;
    gap: 4px;
}

.action-buttons .btn {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--bl-border);
    background: var(--bl-surface);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    line-height: 1;
}

.action-buttons .btn:hover {
    background: var(--bl-border-light);
    transform: translateY(-1px);
}

/* ============================================
   RIGHE CANCELLATE / NO-SHOW
============================================ */
.bl-table tr.row-cancelled {
    opacity: 0.55;
}

.bl-table tr.row-cancelled td {
    text-decoration: line-through;
    text-decoration-color: var(--bl-cancelled);
}

.bl-table tr.row-cancelled td:last-child,
.bl-table tr.row-cancelled td .status-badge {
    text-decoration: none;
}

.bl-table tr.row-no_show {
    opacity: 0.55;
}

.bl-table tr.row-no_show td {
    text-decoration: line-through;
    text-decoration-color: var(--bl-no-show);
}

.bl-table tr.row-no_show td:last-child,
.bl-table tr.row-no_show td .status-badge {
    text-decoration: none;
}

/* ============================================
   CARDS MOBILE (nascosto su desktop)
============================================ */
.bl-cards {
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}

.bl-card {
    background: var(--bl-surface);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius);
    padding: 14px;
    transition: box-shadow 0.2s;
    border-left: 4px solid var(--bl-border);
}

.bl-card:active {
    box-shadow: var(--bl-shadow-md);
}

.bl-card.card-confirmed { border-left-color: var(--bl-confirmed); }
.bl-card.card-pending { border-left-color: var(--bl-pending); }
.bl-card.card-checked_in { border-left-color: var(--bl-checked-in); }
.bl-card.card-checked_out { border-left-color: var(--bl-checked-out); }
.bl-card.card-cancelled { border-left-color: var(--bl-cancelled); opacity: 0.6; }
.bl-card.card-no_show { border-left-color: var(--bl-no-show); opacity: 0.6; }

.bl-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.bl-card-guest {
    font-weight: 700;
    font-size: 15px;
    color: var(--bl-text);
}

.bl-card-code {
    font-size: 11px;
    color: var(--bl-text-muted);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.bl-card-status {
    flex-shrink: 0;
}

.bl-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 13px;
}

.bl-card-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.bl-card-label {
    font-size: 10px;
    color: var(--bl-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.bl-card-val {
    color: var(--bl-text);
    font-weight: 500;
}

.bl-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--bl-border-light);
}

.bl-card-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--bl-text);
}

.bl-card-actions {
    display: flex;
    gap: 8px;
}

.bl-card-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bl-border);
    border-radius: 8px;
    background: var(--bl-surface);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.bl-card-btn:hover {
    background: var(--bl-border-light);
}

/* ============================================
   EMPTY STATE
============================================ */
.bl-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--bl-text-muted);
}

.bl-empty p {
    font-size: 16px;
    margin: 12px 0 4px;
    font-weight: 600;
    color: var(--bl-text-secondary);
}

.bl-empty small {
    font-size: 13px;
}

/* ============================================
   MODALS (override legacy)
============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bl-surface);
    margin: 3% auto;
    padding: 28px;
    border-radius: 14px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    position: relative;
}

.modal .close {
    color: var(--bl-text-muted);
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.modal .close:hover { color: var(--bl-text); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 16px 0;
}

.detail-section {
    background: var(--bl-bg);
    padding: 16px;
    border-radius: var(--bl-radius);
    border: 1px solid var(--bl-border-light);
}

.detail-section h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--bl-text);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bl-accent);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--bl-border-light);
    font-size: 13px;
}

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

.detail-label { color: var(--bl-text-secondary); font-weight: 500; }
.detail-value { color: var(--bl-text); font-weight: 600; }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--bl-border);
}

/* ============================================
   LEGACY COMPAT
============================================ */
.bookings-list-module > .module-header { display: none; }
.bookings-list-module > .filters-section { display: none; }
.bookings-list-module > .stats-row { display: none; }
.bookings-list-module > .table-container { display: none; }

.filter-row { display: none; }
.stats-row { display: none; }

/* ============================================
   MOBILE RESPONSIVE
============================================ */
@media (max-width: 768px) {
    .bl-top-bar {
        padding: 12px 14px;
    }

    .bl-title { font-size: 18px; }

    .bl-btn-text { display: none; }

    .bl-filters {
        padding: 10px 14px;
    }

    .bl-filter-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .bl-search-wrap {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .bl-toggle {
        grid-column: 1 / -1;
        justify-content: center;
    }

    .bl-stats {
        padding: 8px 14px;
        gap: 6px;
    }

    .bl-stat {
        padding: 4px 10px;
        gap: 4px;
    }

    .bl-stat-value { font-size: 13px; }
    .bl-stat-label { font-size: 10px; }

    /* NASCONDO TABELLA, MOSTRO CARDS */
    .bl-table-wrap { display: none !important; }
    .bl-cards { display: flex !important; }

    .modal-content {
        margin: 2% auto;
        padding: 20px;
        width: 95%;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .bl-top-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .bl-actions {
        width: 100%;
    }

    .bl-actions .bl-btn {
        flex: 1;
        justify-content: center;
    }

    .bl-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .bl-stat {
        justify-content: center;
        flex-direction: column;
        gap: 0;
        text-align: center;
        padding: 6px 4px;
    }

    .bl-card-body {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================
   PRINT
============================================ */
@media print {
    .bl-filters, .bl-stats, .bl-actions, .bl-toggle { display: none; }
    .bl-cards { display: none !important; }
    .bl-table-wrap { display: block !important; }
    .bl-table tbody tr:hover { background: none; }
}
/* Fix room-header in nuova prenotazione */
#booking-rooms-container .room-header {
    background: #f8fafc !important;
    color: #1a1f36 !important;
    min-width: unset !important;
    max-width: unset !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px !important;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 14px !important;
}
/* Fix select tipologia nuova prenotazione mobile */
#booking-rooms-container .room-type,
#booking-rooms-container .room-plan {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}