/* === ГЛОБАЛЬНЫЕ НАСТРОЙКИ И ПЕРЕМЕННЫЕ === */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --success-color: #28a745;
    --success-hover: #218838;
    --info-color: #17a2b8;
    --info-hover: #138496;
    --warning-color: #ffc107;

    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --white-color: #ffffff;
    --gray-color: #6c757d;
    --border-color: #dee2e6;
    
    --body-bg: #f4f6f9;
    --card-bg: var(--white-color);
    --text-color: #212529;

    --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 0.375rem;
    --box-shadow: 0 0 1px rgba(0,0,0,.13), 0 1px 3px rgba(0,0,0,.2);
    --sidebar-width: 250px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family-base);
    background-color: var(--body-bg);
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

/* === ТИПОГРАФИКА === */
h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 500;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
    background-color: transparent;
}
a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* === АДАПТИВНЫЙ МАКЕТ ПАНЕЛЕЙ УПРАВЛЕНИЯ === */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--dark-color);
    color: var(--white-color);
    z-index: 1030;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex-grow: 1;
    width: 100%;
    padding-top: 70px; /* Отступ для мобильной кнопки */
    transition: padding-left 0.3s ease-in-out;
}

.sidebar-toggle {
    display: block;
    position: fixed;
    top: 10px;
    left: 15px;
    z-index: 1031;
    background: var(--dark-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle:hover {
    background: #495057;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1029;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

body.sidebar-open .sidebar { transform: translateX(0); }
body.sidebar-open .sidebar-overlay { 
    display: block; 
    opacity: 1;
}

@media (min-width: 992px) {
    .main-content { padding-top: 0; padding-left: var(--sidebar-width); }
    .sidebar { transform: translateX(0); }
    .sidebar-toggle, .sidebar-overlay { display: none !important; }
}


/* === КОМПОНЕНТЫ === */

/* Шапка контента */
.header {
    background-color: var(--card-bg);
    box-shadow: var(--box-shadow);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}
.header-content { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.header .page-title, .header .hotel-name { font-weight: 600; font-size: 1.25rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .logout { color: var(--danger-color); text-decoration: none; font-weight: 500; white-space: nowrap; }

/* Навигация гостя */
.nav { display: flex; background-color: var(--dark-color); margin-bottom: 1.5rem; }
.nav a { color: white; padding: 1rem; text-decoration: none; text-align: center; flex-grow: 1; font-weight: 500; border-bottom: 3px solid transparent; transition: background-color 0.2s; }
.nav a.active { background-color: var(--primary-color); }
.nav a:hover { background-color: rgba(255, 255, 255, 0.1); }


/* Карточки */
.card { 
    background: var(--card-bg); 
    border-radius: var(--border-radius); 
    margin-bottom: 1.5rem; 
    padding: 1.5rem; 
    box-shadow: var(--box-shadow); 
    border: 0; 
}
.card h2 { margin-top: 0; margin-bottom: 1.5rem; font-size: 1.25rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem;}

/* Таблицы */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
th, td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle; 
}
th { 
    font-weight: 600; 
    white-space: nowrap;
    background-color: #f8f9fa;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #f4f6f9; }

/* Формы и кнопки */
.input-group { margin-bottom: 1.25rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
.input-group input, .input-group textarea, .input-group select { 
    display: block; 
    width: 100%; 
    padding: 0.6rem 0.8rem; 
    font-size: 1rem; 
    line-height: 1.5; 
    color: var(--text-color); 
    background-color: var(--white-color); 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out; 
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus { 
    outline: 0; 
    border-color: #86b7fe; 
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,.25); 
}
.btn { 
    display: inline-block; 
    padding: 0.6rem 1.25rem; 
    border: none; 
    border-radius: var(--border-radius); 
    color: white; 
    text-decoration: none; 
    text-align: center; 
    cursor: pointer; 
    font-weight: 500; 
    font-size: 0.95rem; 
    transition: all 0.2s; 
    vertical-align: middle; 
    user-select: none;
}
.btn:hover { 
    color: white !important;
    text-decoration: none; 
    transform: translateY(-1px); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.15); 
}
.btn-full-width { width: 100%; }

/* Цвета кнопок */
.btn-primary { background-color: var(--primary-color); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-success { background-color: var(--success-color); }
.btn-success:hover { background-color: var(--success-hover); }
.btn-danger, .actions a.danger { background-color: var(--danger-color) !important; color: white !important; }
.btn-danger:hover, .actions a.danger:hover { background-color: var(--danger-hover) !important; }
.btn-info, .actions a.info { background-color: var(--info-color) !important; color: white !important; }
.btn-info:hover, .actions a.info:hover { background-color: var(--info-hover) !important; }

/* Статусы и плашки */
.status, .role-badge { padding: 0.25em 0.6em; border-radius: 1rem; font-size: 0.85em; font-weight: 600; white-space: nowrap; color: white; }
.status-new, .role-admin { background-color: var(--primary-color); }
.status-in_progress, .role-pending { background-color: var(--warning-color); color: var(--text-color); }
.status-completed, .role-hotelier { background-color: var(--success-color); }
.status-cancelled, .role-guest { background-color: var(--gray-color); }
.role-reception { background-color: var(--info-color); }
.role-partner { background-color: #6f42c1; }

/* Действия в таблицах */
.actions { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    flex-wrap: wrap; 
}
.actions a, .actions button, .actions .btn {
    font-size: 0.875em;
    padding: 0.35rem 0.75rem;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
}
.actions form { margin: 0; }

/* === ОСНОВНАЯ И БОКОВАЯ КОЛОНКИ === */
.grid-container { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 1.5rem; 
}
@media (min-width: 992px) { 
    .grid-container { 
        grid-template-columns: 2fr 1fr; 
    } 
}

/* Новый макет для страниц с основной частью и боковой колонкой */
.layout-grid-main-aside {
    display: grid;
    grid-template-columns: 1fr; /* Одна колонка по умолчанию для мобильных */
    gap: 1.5rem;
    align-items: flex-start;
}

@media (min-width: 992px) {
    .layout-grid-main-aside {
        /* Две колонки на больших экранах */
        grid-template-columns: 1fr 350px;
    }
}

/* Строка с полями формы, адаптирующаяся к ширине */
@media (min-width: 768px) {
    .form-grid-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: flex-end; gap: 1rem; }
    .form-grid-row .input-group { margin-bottom: 0; }
}

/* === СТИЛИ ДЛЯ КОНКРЕТНЫХ СТРАНИЦ === */

/* Страницы ошибок */
.error-page-container { display: flex; align-items: center; justify-content: center; min-height: 80vh; text-align: center; padding: 2rem; }
.error-code { font-size: 6rem; font-weight: bold; color: var(--border-color); margin: 0; line-height: 1; }
.error-title { font-size: 2rem; font-weight: 500; margin-top: 0.5rem; margin-bottom: 1rem; }
.error-message { font-size: 1.1rem; color: var(--gray-color); margin-bottom: 2rem; }

/* Страница авторизации */
.body-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #e0eafc; background: linear-gradient(to right, #e0eafc, #cfdef3); padding: 1rem; }
.auth-container { background: var(--card-bg); padding: 2.5rem; border-radius: var(--border-radius); box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 100%; max-width: 420px; border-top: 4px solid var(--primary-color); }
.tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; }
.tab-link { flex-grow: 1; padding: 1rem 0; cursor: pointer; border: none; background: none; font-size: 1.1rem; color: var(--gray-color); font-weight: 500; border-bottom: 3px solid transparent; transition: all 0.2s ease-in-out; }
.tab-link:focus { outline: none; }
.tab-link.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.form-content { display: none; }
.form-content.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.auth-container h1 { text-align: center; margin-top: 0; margin-bottom: 2rem; font-weight: 600; font-size: 1.75rem;}

/* Сообщения (успех/ошибка) */
.message { padding: 1rem; margin-bottom: 1.5rem; border-radius: var(--border-radius); border: 1px solid transparent; }
.message.success { background-color: #d1e7dd; color: #0f5132; border-color: #badbcc; }
.message.error { background-color: #f8d7da; color: #842029; border-color: #f5c2c7; }

/* Стили бокового меню */
.sidebar-header { padding: 1.2rem; margin: 0; background-color: rgba(255,255,255,0.05); font-size: 1.1rem; text-align: center; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-nav { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex-grow: 1; }
.sidebar-nav-section { padding: 1.5rem 1.2rem 0.5rem; font-size: 0.8rem; color: #869099; text-transform: uppercase; font-weight: bold; }
.sidebar-nav li a { display: block; color: #c2c7d0; text-decoration: none; padding: 0.8rem 1.2rem; border-left: 4px solid transparent; transition: all 0.2s ease-in-out; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav li a:hover { background-color: rgba(255,255,255,0.1); color: white; }
.sidebar-nav li a.active, .sidebar-nav li a.active-hotel { background-color: var(--primary-color); color: white; border-left-color: #92c5ff;}
.sub-nav { list-style: none; padding: 0; margin: 0; background-color: rgba(0,0,0,0.2); }
.sub-nav li a { padding-left: 2.5rem; font-size: 0.95em; }
.sub-nav li a.active { border-left-color: var(--light-color); font-weight: normal; background: rgba(255,255,255,0.05); }
.sub-nav li a:hover { background-color: rgba(255,255,255,0.1); }

/* Стили для FlexTable (альтернатива таблицам) */
.flex-table {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    /* === ИСПРАВЛЕНИЕ ЗДЕСЬ: было `overflow: hidden`, что обрезало выпадающее меню === */
    overflow: visible; 
}

.flex-table-header,
.flex-table-row {
    display: flex;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    align-items: center; 
}

.flex-table-header {
    background-color: #f8f9fa;
    font-weight: 600;
}

.flex-table-row:last-child {
    border-bottom: none;
}

.flex-table-row:hover {
    background-color: #f4f6f9;
}

.flex-table-cell {
    padding: 0.85rem 1rem;
    flex-grow: 1;
    flex-basis: 0; 
    overflow-wrap: break-word;
    word-wrap: break-word; 
}

/* Стили для FlexTable на мобильных устройствах */
@media (max-width: 768px) {
    .flex-table-header {
        display: none; 
    }
    .flex-table-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    .flex-table-cell {
        display: flex;
        width: 100%;
        padding: 0.5rem 0;
    }
    .flex-table-cell::before {
        content: attr(data-label);
        font-weight: 600;
        width: 120px;
        flex-shrink: 0;
        margin-right: 1rem;
    }
    .flex-table-cell.actions-cell::before {
        display: none;
    }
    .flex-table-cell.actions-cell {
        margin-top: 0.5rem;
    }
}

/* Стили для переключателя (toggle switch) */
.switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success-color); }
input:checked + .slider:before { transform: translateX(26px); }

/* Стили для выпадающего меню действий */
.actions-menu { position: relative; }
.actions-menu-button { background: #6c757d; color: white; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; }
.actions-menu-content { display: none; position: absolute; right: 0; background-color: white; min-width: 160px; box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); z-index: 100; border-radius: 5px; overflow: hidden; }
.actions-menu-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; }
.actions-menu-content a:hover { background-color: #f1f1f1; }
.actions-menu.show .actions-menu-content { display: block; }

/* Стили для модального окна */
.modal { display: none; position: fixed; z-index: 1050; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 20px; border: 1px solid #888; width: 80%; max-width: 500px; border-radius: var(--border-radius); position: relative; }
.modal-close { color: #aaa; position: absolute; top: 10px; right: 20px; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-close:hover, .modal-close:focus { color: black; text-decoration: none; }
.modal h2 { margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }

/* Стили для виджетов на главной админ-панели */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-card .icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white-color);
}
.stat-card .icon svg {
    width: 28px;
    height: 28px;
}

.stat-card .info .title {
    font-size: 0.9rem;
    color: var(--gray-color);
    margin-bottom: 0.25rem;
}
.stat-card .info .value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--dark-color);
}

.icon.bg-blue { background-color: var(--primary-color); }
.icon.bg-orange { background-color: #fd7e14; }
.icon.bg-green { background-color: var(--success-color); }
.icon.bg-red { background-color: var(--danger-color); }

/* Лента активности */
.activity-feed {
    list-style: none;
    padding: 0;
    margin: 0;
}
.activity-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}
.activity-item:last-child {
    border-bottom: none;
}

.activity-item .icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white-color);
}
.activity-item .icon svg {
    width: 20px;
    height: 20px;
}

.activity-item .details {
    display: flex;
    flex-direction: column;
}
.activity-item .details .description {
    font-size: 0.95rem;
}
.activity-item .details .time {
    font-size: 0.8rem;
    color: var(--gray-color);
}