body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f6f8;
}

header {
    background-color: #728EB8;
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.header-container, .header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-top-row {
    margin-bottom: 10px;
}

.header-bottom-row {
    justify-content: flex-start;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-middle {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.controls-row, .filters-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #34495e;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

/* Спінер на кнопці "Зберегти" під час запиту — щоб було видно, що йде збереження,
   а не незрозуміла тиша, і не спокушало тикати повторно чи закривати вікно. */
.btn-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: 0.85;
    margin-right: 7px;
    vertical-align: -2px;
    animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}
button:disabled {
    cursor: not-allowed;
    opacity: 0.75;
}
.btn-icon:hover {
    background: #ecf0f1;
}

h1 {
    margin: 0;
    color: #415678;
    font-size: 24px;
    font-weight: 700;
}

.controls {
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

button {
    padding: 11px 18px;
    min-height: 44px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    color: white;
    background-color: #415678;
    transition: background-color 0.2s;
}
button:hover { background-color: #2f3e57; }

/* Компактні кнопки дій у таблицях (редагувати/видалити) — все одно з touch-зручним
   мінімумом висоти, просто вужчі, а не крихітні inline-стилі як раніше */
.btn-row-action {
    padding: 8px 14px;
    min-height: 38px;
    font-size: 13px;
}

.btn-submit { background-color: #2ecc71; }
.btn-submit:hover { background-color: #27ae60; }
.btn-submit:disabled { background-color: #95a5a6; cursor: not-allowed; }

.btn-cancel { background-color: #e74c3c; }
.btn-cancel:hover { background-color: #c0392b; }

main {
    padding: 20px;
}

/* Flexbox Timeline Styles */
#calendar-grid {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    min-width: fit-content;
}

.timeline-row {
    display: flex;
    border-bottom: 1px solid #d5d8dc;
    position: relative; /* important for absolute booking blocks */
}

.timeline-header-row {
    background-color: #ecf0f1;
    font-weight: bold;
    border-bottom: 2px solid #bdc3c7;
    position: sticky;
    top: 0;
    z-index: 30;
}

.room-col {
    width: 200px;
    flex-shrink: 0;
    border-right: 2px solid #bdc3c7;
    padding: 10px;
    background-color: #fafafa;
    position: sticky;
    left: 0;
    z-index: 20;
    display: flex;
    align-items: center;

    box-sizing: border-box;}

.date-col {
    width: 80px; /* Base width per day */
    flex-shrink: 0;
    border-right: 1px solid #c0c6cc;
    padding: 10px 0;
    text-align: center;
    box-sizing: border-box;
}
.timeline-row .date-col {
    cursor: pointer;
    position: relative;
    min-height: 40px;
}
.timeline-row .date-col:hover {
    background-color: #f1f8ff;
}

/* Booking Blocks (Absolute positioning) */
.booking-block {
    position: absolute;
    top: 5px;
    bottom: 5px;
    border-radius: 4px;
    color: white;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.status-confirmed { background-color: #e74c3c; } /* Red */
.status-checked_in { background-color: #415678; } /* Blue */
.status-checked_out { background-color: #95a5a6; } /* Gray */
.status-cancelled { background-color: #7f8c8d; opacity: 0.6; text-decoration: line-through; } /* Dark gray */

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #34495e;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 11px 10px;
    min-height: 44px;
    font-size: 16px; /* достатньо велике, щоб не викликати авто-zoom на iOS */
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    box-sizing: border-box;
}
/* Радіо/чекбокси не мають розтягуватись на всю ширину й мати min-height 44px */
.form-group input[type="radio"],
.form-group input[type="checkbox"] {
    width: auto;
    min-height: 0;
    padding: 0;
    flex: none;
    margin: 0;
}

/* Пошук гостя (ПІБ) у бронюванні — filter-as-you-type замість тісного <select>
   на весь список гостей (тепер до 2000). Дропдаун рендериться під полем. */
.mh-guest-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
    background: white; border: 1px solid #bdc3c7; border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-height: 260px; overflow-y: auto;
}
.mh-guest-dropdown-item {
    padding: 10px 12px; cursor: pointer; font-size: 14.5px; color: #2c3e50;
    border-bottom: 1px solid #f0f0f0;
}
.mh-guest-dropdown-item:last-child { border-bottom: none; }
.mh-guest-dropdown-item:hover { background: #eef2f7; }
.mh-guest-dropdown-item.mh-guest-dropdown-clear { color: #7f8c8d; font-style: italic; }
.mh-guest-dropdown-phone { color: #95a5a6; font-size: 12px; margin-left: 6px; }
.mh-guest-dropdown-empty { padding: 12px; color: #95a5a6; font-style: italic; font-size: 13.5px; text-align: center; }

/* Список вибору з чекбоксами замість тісного <select multiple> —
   кожен варіант це окрема, добре відчутна для пальця зона дотику */
.checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    background: #fafafa;
}
.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    min-height: 44px;
    background: white;
    border: 1px solid #dde2e6;
    border-radius: 6px;
    cursor: pointer;
    font-weight: normal;
    font-size: 14px;
    box-sizing: border-box;
    user-select: none;
}
.checkbox-list label:has(input:checked) {
    background: #eaf3ff;
    border-color: #415678;
    font-weight: bold;
}
.checkbox-list input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: #415678;
}

/* Крок +/- для кількісних полів (напр. типи ліжок) — легше для пальця,
   ніж крихітні нативні стрілки number-інпута */
.qty-stepper {
    display: flex;
    align-items: stretch;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    overflow: hidden;
}
.qty-stepper button {
    min-width: 44px;
    min-height: 44px;
    border-radius: 0;
    font-size: 20px;
    line-height: 1;
    padding: 0;
}
.qty-stepper input {
    border: none !important;
    border-left: 1px solid #bdc3c7 !important;
    border-right: 1px solid #bdc3c7 !important;
    border-radius: 0 !important;
    text-align: center;
    min-width: 0;
    width: 100%;
}

.form-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}
.form-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #415678;
    font-size: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.preferences-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.preferences-grid label {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: normal;
    color: #333;
    cursor: pointer;
}
.preferences-grid label:hover {
    background: #f1f8ff;
}
.preferences-grid input {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-right: 10px;
    accent-color: #415678;
}

.room-warning-border {
    border: 3px solid #ff3b30 !important;
    box-shadow: inset 0 0 10px rgba(255, 59, 48, 0.3);
}

/* Custom Tooltip */

.booking-tooltip.show {
    opacity: 1;
}


.hidden { display: none !important; }

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    width: 750px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
}

.large-modal {
    width: 700px;
}


.booking-tooltip {
    position: fixed;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    border: 1px solid #1a252f;
    backdrop-filter: blur(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(5px);
    white-space: pre-line;
    min-width: 250px;
}
.booking-tooltip.show {
    transform: translateY(0);
}


/* =========================================
   PWA & Mobile Responsive Overrides
========================================= */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        padding: 0;
        margin: 0;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 15px;
        position: sticky;
        top: 0;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    header .header-controls {
        width: 100%;
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
    }

    /* Grid */
    .grid-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
        padding-bottom: 20px;
    }
    
    .grid-header, .grid-row {
        min-width: 800px; /* Force scroll instead of breaking layout */
    }

    /* Modals */
    .modal-content {
        width: 95% !important;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-group input, 
    .form-group select {
        width: 100%;
        padding: 10px;
        font-size: 16px; /* Prevents iOS auto-zoom on focus */
    }

    /* Make buttons larger for touch */
    button {
        padding: 12px 15px;
        font-size: 16px;
    }

    /* Admin Panel specifics */
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding: 10px;
    }

    .admin-sidebar ul li {
        display: inline-block;
        margin-bottom: 0;
        margin-right: 10px;
    }

    .admin-content {
        padding: 15px;
    }
}

/* BOOKINGS LIST FILTER */
.bookings-filter-btn {
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
}
.bookings-filter-btn.active {
    background: #415678;
    color: white;
    border-color: #415678;
}

/* STATUS BUTTONS */
.status-btn-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 5px;
}
.status-btn {
    flex: 1;
    min-width: 45%;
    padding: 8px 5px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    color: #333;
}
.status-btn:hover {
    background: #eef2f5;
}
.status-btn[data-status="confirmed"].active { background: #3498db; color: white; border-color: #3498db; }
.status-btn[data-status="checked_in"].active { background: #2ecc71; color: white; border-color: #2ecc71; }
.status-btn[data-status="checked_out"].active { background: #95a5a6; color: white; border-color: #95a5a6; }
.status-btn[data-status="cancelled"].active { background: #e74c3c; color: white; border-color: #e74c3c; }
