/* CSS переменные для адаптивности */
:root {
    --seat-size: 35px;
    --seat-gap: 1.5px;
    --seat-margin: 2px;
    --row-gap: 6px;
    --container-gap: 10px;
    --screen-width: calc(9 * 35px);
    --seat-font-size: 0.7rem;
    --screen-font-size: 0.8rem;
    --row-label-font-size: 1rem;
    --max-container-width: 1500px;
}

/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Улучшения для мобильных устройств */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #7085a7 0%, #7085a7 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Заголовок */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Контейнер зала */
.hall-container {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: var(--max-container-width);
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Экран */
.screen {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
    text-align: center;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-size: var(--screen-font-size);
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: var(--screen-width); /* Используем CSS переменную */
    max-width: calc(100vw - 95px); /* Ограничиваем максимальную ширину */
    margin-left: auto;
    margin-right: auto;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

/* Контейнер мест */
.seats-container {
    display: flex;
    flex-direction: column;
    gap: var(--container-gap);
    align-items: center;
    width: 100%;
    max-width: var(--max-container-width);
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Ряд */
.row {
    display: flex;
    align-items: center;
    gap: var(--row-gap);
    position: relative;
    justify-content: center; /* Центрируем все ряды */
    max-width: var(--max-container-width);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 10px;
    box-sizing: border-box;
}

/* Специальные стили для рядов 1-5 */
.row.row-1-5 {
    justify-content: center; /* Центрируем все 15 мест */
    padding-left: 0; /* Убираем смещение, так как теперь у нас 15 мест */
}

.row-label {
    min-width: 60px;
    font-weight: bold;
    font-size: var(--row-label-font-size);
    color: #2c3e50;
    text-align: center;
}

/* Места */
.seats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--seat-gap);
    box-sizing: border-box;
    width: 85%;
}

.seat {
    width: var(--seat-size);
    height: var(--seat-size);
    border: 2px solid #3498db;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: var(--seat-font-size);
    cursor: pointer;
    transition: all 0.3s ease;
    background: #ecf0f1;
    color: #2c3e50;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
    flex-shrink: 0;
    gap: var(--seat-gap);
    min-width: 1px;
    min-height: 1px;
    max-width: calc((100vw - 40px) / 20);
    max-height: calc((100vw - 40px) / 20);
    box-sizing: border-box;
}

.seat:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.seat.booked {
    background: #e74c3c;
    border-color: #c0392b;
    color: white;
    cursor: not-allowed;
}

.seat.booked:hover {
    transform: none;
    box-shadow: none;
}

/* Цветовое кодирование для разных пользователей */
.seat.booked.user-1 {
    background: #e74c3c; /* Красный */
    border-color: #c0392b;
}

.seat.booked.user-2 {
    background: #3498db; /* Синий */
    border-color: #2980b9;
}

.seat.booked.user-3 {
    background: #2ecc71; /* Зеленый */
    border-color: #27ae60;
}

.seat.booked.user-4 {
    background: #f39c12; /* Оранжевый */
    border-color: #e67e22;
}

.seat.booked.user-5 {
    background: #9b59b6; /* Фиолетовый */
    border-color: #8e44ad;
}

.seat.booked.user-6 {
    background: #1abc9c; /* Бирюзовый */
    border-color: #16a085;
}

.seat.booked.user-7 {
    background: #c222e6; /* Морковный */
    border-color: #8a1ba2;
}

.seat.booked.user-8 {
    background: #34495e; /* Темно-синий */
    border-color: #2c3e50;
}

.seat.booked.user-9 {
    background: #f8ccc6; /* Желтый */
    border-color: #af8f8a;
}

.seat.booked.user-10 {
    background: #e91e63; /* Розовый */
    border-color: #c2185b;
}
.seat.booked.user-11 {
    background: #2f7105; /* Розовый */
    border-color: #4b4b2b;
}
.seat.booked.user-12 {
    background: #58f3f3; /* Розовый */
    border-color: #3ba1a1;
}
.seat.booked.user-13 {
    background: #3486f1; /* Розовый */
    border-color: #246464;
}
.seat.booked.user-14 {
    background: #78fcc0; /* Розовый */
    border-color: #54b086;
}
.seat.booked.user-15 {
    background: #d33b5e; /* Розовый */
    border-color: #8f2c43;
}


.seat.empty {
    background: transparent;
    border: 2px solid transparent;
    cursor: default;
    color: transparent;
    width: var(--seat-size);
    height: var(--seat-size);
    gap: var(--seat-gap);
    font-size: var(--seat-font-size);
    min-width: 1px;
    min-height: 1px;
    max-width: calc((100vw - 40px) / 5);
    max-height: calc((100vw - 40px) / 5);
    box-sizing: border-box;
}

.seat.empty:hover {
    transform: none;
    box-shadow: none;
}


/* Кнопки */
.actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: #000;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Административная панель */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-card h3 {
    color: #7f8c8d;
    margin-bottom: 10px;
    font-size: 1rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.bookings-list {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.bookings-list h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.bookings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.bookings-table th,
.bookings-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.bookings-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #2c3e50;
}

.bookings-table tr:hover {
    background-color: #f8f9fa;
}

.no-bookings {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* Страница входа */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-form {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

.error-message {
    background: #e74c3c;
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.success-message {
    background: #27ae60;
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.form-footer {
    margin-top: 20px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.form-footer a {
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
}

.form-footer a:hover {
    text-decoration: underline;
}

.user-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    backdrop-filter: blur(10px);
}

.user-info p {
    margin: 5px 0;
    font-size: 1rem;
}

/* Управление паролями */
.passwords-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.passwords-section h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.password-controls {
    display: flex;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.password-controls .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
}

.generated-password {
    background: #ecf0f1;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #27ae60;
}

.generated-password h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.password-display {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.password-display span {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: #27ae60;
    background: white;
    padding: 10px 15px;
    border-radius: 6px;
    border: 2px solid #27ae60;
}

.passwords-list h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.passwords-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.passwords-table th,
.passwords-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.passwords-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #2c3e50;
}

.passwords-table tr:hover {
    background-color: #f8f9fa;
}

.passwords-table code {
    background: #ecf0f1;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
}

.status.active {
    background: #27ae60;
    color: white;
}

.status.inactive {
    background: #e74c3c;
    color: white;
}

.no-passwords {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 1.1rem;
}


@media (min-width: 462px) {
    /* Стили для 6-го ряда */
    .row.row-6 {
        justify-content: center;
        padding-left: 0; /* Без дополнительного смещения */
    }
}

/* Адаптивность */
@media (max-width: 485px) {
    .row {
        gap: 8px;
    }

    .seats-container {
        gap: 6px;
    }

    .container {
        padding: 3px;
    }
    .hall-container {
        background: white;
        border-radius: 5px;
        padding: 0px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        margin-bottom: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
    }
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    header p {
        font-size: 1rem;
    }

    .hall-container {
        padding: 10px;
        border-radius: 5px;
    }

    /* Экран */
    .screen {
        background: linear-gradient(45deg, #2c3e50, #34495e);
        color: white;
        text-align: center;
        padding: 10px;
        border-radius: 5px;
        margin-bottom: 30px;
        font-size: var(--screen-font-size);
        font-weight: bold;
        box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        width: calc(100vw - 60px); /* Используем CSS переменную */
        max-width: calc(100vw - 60px); /* Ограничиваем максимальную ширину */
        margin-left: auto;
        margin-right: auto;
        transition: all 0.3s ease;
        box-sizing: border-box;
    }

    .seats-container {
        gap: 6px;
    }

    .row {
        gap: 4px;
        flex-direction: column;
        align-items: flex-start;
    }

    .row-label {
        min-width: auto;
        font-size: 0.9rem;
        margin-bottom: 5px;
        align-self: center;
    }

    .seats {
        gap: 1px;
        justify-content: center;
        width: 100%;
    }

    .seat {
        margin: 1px;
        min-width: 11px;
        min-height: 11px;
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
        border-radius: 2px;
    }
    .seat.empty {
        margin: 1px;
        min-width: 11px;
        min-height: 11px;
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
        border-radius: 2px;
    }
    .legend {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .legend-item {
        font-size: 0.9rem;
    }

    .admin-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card h3 {
        font-size: 0.9rem;
    }

    .stat-number {
        font-size: 2rem;
    }

    .bookings-list {
        padding: 20px;
    }

    .bookings-list h2 {
        font-size: 1.3rem;
    }

    .bookings-table {
        font-size: 0.85rem;
    }

    .bookings-table th,
    .bookings-table td {
        padding: 8px 6px;
    }

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

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .actions {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}