/* Подключаем шрифт Exo 2 из Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Exo 2', -apple-system, BlinkMacSystemFont, sans-serif;
    background-image: url('/img/fon1_2.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100vh;
    padding: 20px;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Шапка */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    background: transparent;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 40px;
}

.header-logo {
    height: 50px;
    width: auto;
    display: block;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.7px;
}

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

/* Часы */
.time {
    font-size: 1.1rem;
    font-weight: 500;
    color: #ffffff;
    padding: 8px 5px;
}

/* ============================================================ */
/* КОНТЕНТ — трёхколоночный layout                              */
/* ============================================================ */
#content {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 16px;
    padding: 16px 0;
    align-items: stretch;
}

/* Боковая колонка (очередь и стоянка) */
.side-column {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.column-header {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    text-align: center;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
}

.column-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 4px;
}

.column-items::-webkit-scrollbar {
    width: 6px;
}

.column-items::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.column-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Плитка очереди */
.queue-item {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px 14px;
    border-left: 5px solid #f5a623;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.queue-item:hover {
    transform: translateX(3px);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.queue-model {
    font-size: 0.95rem;
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
    line-height: 1.2;
}

.queue-sign {
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    letter-spacing: 0.5px;
}

/* Плитка стоянки */
.parking-item {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px 14px;
    border-left: 5px solid #2196F3;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.parking-item:hover {
    transform: translateX(-3px);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.parking-model {
    font-size: 0.95rem;
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
    line-height: 1.2;
}

.parking-sign {
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    letter-spacing: 0.5px;
}

/* Сообщение "пусто" */
.empty-message {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px 10px;
    font-style: italic;
}

/* Основная колонка (боксы) */
.main-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Сетка боксов */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    width: 100%;
    height: 100%;
    align-content: start;
}

/* Карточка бокса */
.box-card {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 60px 60px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    opacity: 1;
    transform: translateY(0);
}

.box-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.95);
}

.box-card.free {
    border-left: 15px solid #4CAF50;
}

.box-card.occupied {
    border-left: 15px solid #d32f2f;
}

/* ============================================================ */
/* АНИМАЦИЯ ПОЯВЛЕНИЯ (при первой загрузке и для новых плиток)  */
/* ============================================================ */
.box-card.appear,
.queue-item.appear,
.parking-item.appear {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================ */
/* АНИМАЦИЯ ИЗМЕНЕНИЯ ДАННЫХ (только для изменившихся плиток)    */
/* ============================================================ */
.box-card.changed {
    animation: highlightChange 1s ease;
}

@keyframes highlightChange {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }
    30% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(247, 201, 72, 0.9), 0 0 60px rgba(247, 201, 72, 0.5);
        background: rgba(255, 255, 255, 0.95);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }
}

/* Название бокса */
.box-code {
    font-size: 1.1rem;
    font-weight: 700;
    color: #000;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.box-status {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 30px;
    margin-bottom: 8px;
}

.box-card.free .box-status {
    color: #2E7D32;
    background: rgba(76, 175, 80, 0.12);
}

.box-card.occupied .box-status {
    color: #c62828;
    background: rgba(211, 47, 47, 0.12);
}

/* Модель автомобиля */
.box-car {
    font-size: 1.43rem;
    font-weight: 500;
    color: #000;
    padding: 0 10px;
}

.box-sign {
    font-size: 1.3rem;
    font-weight: 700;
    color: #000;
    margin-top: 4px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    letter-spacing: 1px;
}

.box-time {
    font-size: 0.8rem;
    font-weight: 400;
    color: #666;
    margin-top: 8px;
}

.free-icon {
    font-size: 2.8rem;
    margin-bottom: 6px;
}

/* ============================================================ */
/* ТАЙМЕР ОБРАТНОГО ОТСЧЁТА                                     */
/* ============================================================ */
.box-time.countdown {
    font-size: 0.85rem;
    font-weight: 500;
    color: #e65100;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

.box-time.countdown .countdown-value {
    font-weight: 700;
    color: #d84315;
    font-size: 1rem;
}

.box-time.finished {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2E7D32;
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(76, 175, 80, 0.12);
    border-radius: 20px;
    display: inline-block;
}

/* ============================================================ */
/* АНИМАЦИЯ "ПОДГОТОВКА К ВЫДАЧЕ" (когда endtime прошёл)         */
/* ============================================================ */

.box-card.finished-state {
    animation: borderBlink 1s ease-in-out infinite;
    border: 10px solid #4CAF50;
	background: #ffffff;
}

@keyframes borderBlink {
    0%, 100% {
        border-color: #4CAF50;
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    }
    50% {
        border-color: #A5D6A7;
        box-shadow: 0 0 30px rgba(76, 175, 80, 1);
    }
}

/* Модель и номер — более заметные */
.box-card.finished-state .box-car,
.box-card.finished-state .box-sign {
    color: #4CAF50;
}

/* Загрузка */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    flex-direction: column;
    gap: 20px;
}

.loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Ошибка */
.error {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 100%;
    align-self: center;
}

.error .icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error h2 {
    color: #D32F2F;
    margin-bottom: 10px;
    font-weight: 600;
}

.error p {
    color: #333;
}

.error .retry-btn {
    margin-top: 20px;
    background: rgba(211, 47, 47, 0.1);
    color: #D32F2F;
    border: 1px solid rgba(211, 47, 47, 0.3);
    padding: 12px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Exo 2', sans-serif;
    font-weight: 500;
    transition: all 0.3s;
}

.error .retry-btn:hover {
    background: rgba(211, 47, 47, 0.2);
}

.details {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #666;
    background: rgba(0, 0, 0, 0.04);
    padding: 12px 20px;
    border-radius: 8px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    word-break: break-all;
}

/* Подвал */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: transparent;
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

.last-update {
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 400;
}

.status {
    color: #ffffff;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

/* ============================================================ */
/* АДАПТИВНОСТЬ                                                 */
/* ============================================================ */

@media (max-width: 1200px) {
    .side-column { width: 180px; }
    .column-header { font-size: 0.9rem; padding: 6px 10px; }
    .queue-model, .parking-model { font-size: 0.85rem; }
    .queue-sign, .parking-sign { font-size: 0.75rem; }
}

@media (max-width: 1024px) {
    .grid { gap: 16px; }
}

@media (max-width: 900px) {
    #content { flex-direction: column; gap: 12px; overflow-y: auto; }
    .side-column { width: 100%; max-height: 150px; }
    .column-items { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
    .queue-item, .parking-item { min-width: 150px; flex-shrink: 0; }
    .main-column { min-height: 400px; }
}

@media (max-width: 768px) {
    body { padding: 12px; overflow-y: auto; }
    .container { height: auto; min-height: 100%; }
    .header { flex-direction: column; gap: 12px; padding: 16px 20px; }
    .header-left { width: 100%; justify-content: center; }
    .header h1 { font-size: 1.5rem; }
    .header-logo { height: 32px; }
    #content { padding: 12px 0; min-height: 300px; }
    .grid { gap: 14px; height: auto; align-content: start; }
    .box-card { padding: 16px 12px; min-height: 100px; }
    .box-code { font-size: 1rem; }
    .box-sign { font-size: 1rem; }
    .box-car { font-size: 1.2rem; }
}

@media (max-width: 480px) {
    body { padding: 8px; }
    .header { padding: 12px 14px; border-radius: 12px; }
    .header h1 { font-size: 1.1rem; }
    .header-logo { height: 26px; }
    .side-column { max-height: 120px; }
    .queue-item, .parking-item { min-width: 130px; padding: 10px 12px; }
    .queue-model, .parking-model { font-size: 0.8rem; }
    .queue-sign, .parking-sign { font-size: 0.7rem; }
    .grid { gap: 10px; }
    .box-card { padding: 12px 8px; min-height: 80px; border-radius: 12px; }
    .box-code { font-size: 0.85rem; }
    .box-sign { font-size: 0.85rem; padding: 2px 8px; }
    .box-car { font-size: 1rem; }
    .box-status { font-size: 0.7rem; padding: 2px 10px; }
    .box-time { font-size: 0.7rem; }
    .free-icon { font-size: 2rem; }
    .header-info { flex-direction: column; width: 100%; }
    .time { font-size: 0.9rem; padding: 6px 5px; width: 100%; text-align: center; }
    .footer { flex-direction: column; text-align: center; padding: 10px 14px; }
    .last-update { font-size: 0.75rem; }
    .status { font-size: 0.75rem; }
    .loading p { font-size: 0.9rem; }
}

@media (max-width: 360px) {
    .grid { gap: 8px; }
    .box-card { padding: 8px 6px; min-height: 70px; border-radius: 10px; border-left-width: 8px; }
    .box-code { font-size: 0.75rem; margin-bottom: 4px; }
    .box-sign { font-size: 0.7rem; }
    .box-car { font-size: 0.85rem; }
    .box-status { font-size: 0.6rem; padding: 2px 8px; margin-bottom: 4px; }
    .free-icon { font-size: 1.6rem; margin-bottom: 2px; }
    .header h1 { font-size: 0.9rem; }
    .header-logo { height: 20px; }
}

@media (min-height: 900px) {
    .box-card { min-height: 180px; padding: 24px 20px; }
    .box-code { font-size: 1.4rem; }
    .box-sign { font-size: 1.6rem; }
    .box-car { font-size: 1.8rem; }
    .free-icon { font-size: 3.5rem; }
    .header h1 { font-size: 2.5rem; }
    .box-time.countdown { font-size: 1rem; }
    .box-time.countdown .countdown-value { font-size: 1.2rem; }
    .box-time.finished { font-size: 1.1rem; padding: 6px 16px; }
}

@media (min-height: 1100px) {
    .box-card { min-height: 220px; padding: 30px 24px; border-radius: 20px; }
    .box-code { font-size: 1.6rem; }
    .box-sign { font-size: 1.8rem; padding: 6px 16px; }
    .box-car { font-size: 2rem; }
    .box-status { font-size: 1rem; padding: 6px 18px; }
    .free-icon { font-size: 4rem; }
    .header h1 { font-size: 3rem; }
    .header-logo { height: 50px; }
    .time { font-size: 1.4rem; }
    .last-update, .status { font-size: 1rem; }
    .box-time.countdown { font-size: 1.2rem; }
    .box-time.countdown .countdown-value { font-size: 1.5rem; }
    .box-time.finished { font-size: 1.3rem; padding: 8px 20px; }
}

@media (min-width: 1600px) {
    .grid { gap: 24px; }
    .side-column { width: 260px; }
}