/* style.css - Непрерывная шкала времени с поддержкой ночных броней */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #dc3545;
    --primary-dark: #c82333;
    --primary-light: #ff6b6b;
    --overnight: #9c27b0;
    --overnight-dark: #6a1b9a;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-tertiary: #adb5bd;
    --border: #e9ecef;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #6c6c6c;
    --border: #2c2c2c;
}

body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 16px;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.title-section h1 {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 28px;
    font-weight: 700;
}

.title-section h1 i {
    background: none;
    -webkit-text-fill-color: var(--primary);
    margin-right: 10px;
}

.title-section .subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 18px;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    transform: rotate(15deg);
}

.date-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 4px;
}

.date-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 32px;
    transition: all 0.2s;
}

.date-nav-btn:hover {
    background: var(--primary);
    color: white;
}

.current-date-info {
    padding: 8px 20px;
    text-align: center;
    min-width: 150px;
}

.current-date {
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    display: block;
}

.weekday-name {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
    margin-top: 2px;
}

.date-picker {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 32px;
    font-size: 14px;
    cursor: pointer;
}

.date-picker:focus {
    outline: none;
    border-color: var(--primary);
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    padding: 0;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 24px;
    border-radius: 32px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.filter-btn i {
    margin-right: 8px;
}

.filter-btn:hover, .filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Legend */
.legend {
    display: flex;
    gap: 24px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-dot.available {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.legend-dot.selected-area {
    background: var(--primary);
    opacity: 0.6;
    border: 2px solid var(--primary);
}

.legend-dot.booked {
    background: var(--primary);
    opacity: 0.5;
}

.legend-dot.overnight {
    background: linear-gradient(135deg, #9c27b0, #6a1b9a);
}

/* Timeline - непрерывная шкала */
.timeline-wrapper {
    width: 100%;
    overflow-x: auto;
    background: var(--bg-primary);
    border-radius: 20px;
    border: 1px solid var(--border);
    position: relative;
    margin: 20px 0;
}

.timeline-container {
    position: relative;
    min-width: 100%;
    display: flex;
    flex-direction: column;
}

/* Шкала времени (линейка) */
.timeline-ruler {
    height: 50px;
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    flex-shrink: 0;
}

/* Контейнер для комнат */
.rooms-timeline {
    position: relative;
    flex: 1;
}

/* Ряд комнаты */
.room-timeline-row {
    position: relative;
    min-height: 80px;
    border-bottom: 1px solid var(--border);
    display: flex;
    cursor: pointer;
    transition: background 0.2s;
}

.room-timeline-row:hover {
    background: rgba(220, 53, 69, 0.05);
}

/* Фиксированная метка комнаты */
.room-label {
    position: sticky;
    left: 0;
    width: 100px;
    min-width: 100px;
    background: var(--bg-secondary);
    border-right: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 15;
    font-weight: 600;
    padding: 10px;
    flex-direction: column;
    flex-shrink: 0;
}

.room-number {
    color: var(--primary);
    font-size: 14px;
    font-weight: 700;
}

.room-type {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.room-type.classic { background: rgba(220, 53, 69, 0.2); color: var(--primary); }
.room-type.comfort { background: rgba(76, 175, 80, 0.2); color: #4caf50; }
.room-type.vip { background: rgba(255, 215, 0, 0.2); color: #ffd700; }

/* Трек для броней */
.timeline-track {
    flex: 1;
    position: relative;
    min-height: 80px;
    background: var(--bg-primary);
}

/* Блоки бронирований */
.booking-block {
    position: absolute;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.booking-block.overnight {
    background: linear-gradient(135deg, #9c27b0, #6a1b9a);
}

.booking-block:hover {
    transform: scaleY(1.05);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
    z-index: 15;
}

.booking-block.overnight:hover {
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.booking-block-content {
    padding: 6px 8px;
    color: white;
    font-size: 11px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.booking-block-time {
    font-weight: 600;
    font-size: 10px;
    opacity: 0.9;
}

.booking-block-name {
    font-size: 10px;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overnight-indicator {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.7;
}

/* Область выбора */
.selection-area {
    position: absolute;
    background: var(--primary);
    opacity: 0.4;
    border: 2px solid var(--primary);
    border-radius: 4px;
    pointer-events: none;
    z-index: 20;
    transition: all 0.05s linear;
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 0;
    margin: 10px 0;
}

.btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 24px;
    border-radius: 32px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn i {
    margin-right: 8px;
}

.btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #218838);
    border-color: #28a745;
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #218838, #28a745);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.summary {
    margin-left: auto;
    background: var(--bg-tertiary);
    padding: 8px 20px;
    border-radius: 32px;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.summary span {
    color: var(--primary);
    font-weight: 700;
    margin: 0 4px;
    font-size: 18px;
}

/* Bookings Panel */
.bookings-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 10px;
}

.bookings-panel h3 {
    padding: 20px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    font-size: 18px;
    font-weight: 600;
}

.bookings-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-height: 400px;
}

.booking-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    border-left: 3px solid var(--primary);
    transition: all 0.2s;
}

.booking-item.overnight-booking {
    border-left-color: #9c27b0;
}

.booking-item:hover {
    transform: translateX(-4px);
    box-shadow: var(--shadow-hover);
}

.booking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.booking-room {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
}

.booking-item.overnight-booking .booking-room {
    color: #9c27b0;
}

.booking-time-range {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(220, 53, 69, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
    font-family: monospace;
}

.booking-item.overnight-booking .booking-time-range {
    background: rgba(156, 39, 176, 0.1);
}

.booking-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 8px 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.booking-customer {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.booking-cancel {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    cursor: pointer;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    margin-top: 10px;
    width: 100%;
}

.booking-cancel:hover {
    background: var(--primary);
    color: white;
}

.empty-bookings {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px 20px;
    font-size: 13px;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-modal);
    animation: slideUp 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-sm {
    max-width: 400px;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.modal-header h2 i {
    margin-right: 10px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
}

.modal-close:hover {
    color: var(--primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-footer button {
    padding: 10px 20px;
    border-radius: 32px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    border: none;
}

.modal-footer .btn-primary {
    background: var(--primary);
    color: white;
}

.modal-footer .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.modal-footer .btn-danger {
    background: var(--danger);
    color: white;
}

.modal-footer .btn-primary:hover,
.modal-footer .btn-secondary:hover,
.modal-footer .btn-danger:hover {
    transform: translateY(-2px);
}

.modal-info {
    background: rgba(220, 53, 69, 0.1);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-left: 3px solid var(--primary);
}

.modal-info.warning {
    background: rgba(255, 193, 7, 0.1);
    border-left-color: var(--warning);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.form-group label i {
    margin-right: 6px;
    color: var(--primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.duration-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
}

.duration-input-group input {
    width: auto;
    padding: 8px;
    background: transparent;
    border: none;
    text-align: center;
}

.duration-input-group span {
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.notification-text {
    text-align: center;
    padding: 10px 0;
    color: var(--text-secondary);
}

/* Scrollbar */
.timeline-wrapper::-webkit-scrollbar,
.bookings-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.timeline-wrapper::-webkit-scrollbar-track,
.bookings-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.timeline-wrapper::-webkit-scrollbar-thumb,
.bookings-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .room-label {
        width: 80px;
        min-width: 80px;
    }
    
    .booking-block-content {
        padding: 4px 6px;
        font-size: 9px;
    }
    
    .controls {
        flex-wrap: wrap;
    }
    
    .summary {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
    
    .filters {
        justify-content: center;
    }
    
    .legend {
        justify-content: center;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer button {
        width: 100%;
    }
}

/* Ruler marks */
.ruler-mark {
    position: absolute;
    bottom: 0;
    font-size: 10px;
    color: var(--text-secondary);
    transform: translateX(-50%);
    white-space: nowrap;
}

.ruler-mark div {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 15px;
    background-color: var(--border);
}

.ruler-mark.hour-mark div {
    height: 20px;
    background-color: var(--text-secondary);
}

.ruler-mark:first-child div,
.ruler-mark:last-child div {
    background-color: var(--text-primary);
}