/* ===== БАЗА ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    background: #2d2d2d;
    margin: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "Helvetica Neue", system-ui, sans-serif;
}

/* Экран телефона: делаем как один столбец по центру */
.phone {
    max-width: 100%;
    margin: 0 auto;
    background: #2d2d2d;
    position: relative;
}

/* На мобильных устройствах убираем ограничение ширины */
@media (max-width: 430px) {
    .phone {
        max-width: 100%;
    }
}

/* Вся "аппа" */
.app {
    width: 100%;
    background: #2d2d2d;
    /* Отступ сверху для фиксированной шапки с учетом safe-area */
    padding-top: calc(48px + env(safe-area-inset-top, 0px));
}

/* ===== ВЕРХНЯЯ ПАНЕЛЬ (красная) ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 48px;
    padding-top: env(safe-area-inset-top, 0px);
    background: #c84b3a;
    color: #fff;
    display: flex;
    align-items: center;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 0;
    font-size: 16px;
    z-index: 1000;
    box-sizing: border-box;
}

.top-bar .back {
    font-size: 16px;
}

.top-bar .back::before {
    content: "‹ ";
    font-size: 20px;
}

.top-bar .title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    margin-right: 30px;
}

/* ===== ВКЛАДКИ Active / Expired ===== */
.tabs {
    width: 100%;
    height: 44px;
    background: #000;
    display: flex;
    align-items: flex-end;
    font-size: 15px;
}

.tab {
    flex: 1;
    text-align: center;
    color: #fff;
    position: relative;
    padding-bottom: 8px;
    font-weight: 400;
}

.tab.active {
    font-weight: 500;
}

.tab.active::after {
    content: "";
    position: absolute;
    left: 25%;
    bottom: 0;
    width: 50%;
    height: 2px;
    background: #c84b3a;
    border-radius: 999px;
}

/* ===== БИЛЕТ ===== */

/* контейнер билета */
.ticket-wrapper {
    width: 100%;
    padding: 0 2px;
    background: #2d2d2d;
    margin-top: 2px;
    margin-bottom: 12px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

/* На мобильных уменьшаем боковые отступы для большей ширины билета */
@media (max-width: 430px) {
    .ticket-wrapper {
        padding: 0 2px;
    }
}

@media (max-width: 375px) {
    .ticket-wrapper {
        padding: 0 1px;
    }
}

/* внутренний контейнер с картинкой билета */
.ticket {
    position: relative;
    width: 100%;
    max-width: 490px;
    cursor: default;
    overflow: hidden;
    box-sizing: border-box;
}

/* Картинка билета */
.ticket__bg {
    width: 100%;
    height: auto;
    display: block;
    max-width: 100%;
    position: relative;
    z-index: 1;
}

/* Двигающийся баннер с диагональными полосами */
.ticket-banner {
    position: absolute;
    left: 2%;
    top: 25.5%;
    right: 33%;
    height: 5%;
    background: repeating-linear-gradient(
        135deg,
        #cf4026 0px,
        #cf4026 12px,
        #000000 12px,
        #000000 24px
    );
    background-size: 33.94px 33.94px;
    background-position: 0 0;
    animation: bannerMove 4s linear infinite;
    z-index: 5;
    border-radius: 1px;
    overflow: hidden;
    box-sizing: border-box;
}

/* Анимация движения баннера (влево) */
@keyframes bannerMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: -33.94px -33.94px;
    }
}

/* ===== ТЕКСТ ВАЛИДНОСТИ ===== */
.ticket-validity {
    position: absolute;
    left: 50%;
    top: 14%;
    transform: translateX(-50%);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "Helvetica Neue", system-ui, sans-serif;
    font-size: clamp(18px, 4.5vw, 22px);
    font-weight: 700;
    color: #000000;
    line-height: 1.2;
    letter-spacing: -0.035em;
    text-align: center;
    white-space: nowrap;
    z-index: 10;
}

.ticket-category {
    position: absolute;
    left: 50%;
    top: 18.5%;
    transform: translateX(-50%);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "Helvetica Neue", system-ui, sans-serif;
    font-size: clamp(18px, 4.5vw, 20px);
    font-weight: 700;
    color: #000000;
    line-height: 1.2;
    letter-spacing: -0.035em;
    text-align: center;
    white-space: nowrap;
    z-index: 10;
}

/* Информация о VAT и деталях покупки */
.ticket-vat {
    position: absolute;
    left: 6.74%;
    top: 48.80%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "Helvetica Neue", system-ui, sans-serif;
    font-size: clamp(14px, 2.8vw, 17px);
    font-weight: 400;
    color: #000000;
    line-height: 1.35;
    text-align: left;
    white-space: pre-line;
    z-index: 10;
}

/* Кликабельная зона иконки человечка (правый нижний угол) */
.person-icon-click-area {
    position: absolute;
    right: 8%;
    bottom: 12%;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    z-index: 20;
    /* Увеличиваем зону для удобства на мобильных */
    transform: scale(1.2);
    transform-origin: center;
}


/* ===== ОВЕРЛЕЙ ЗАГРУЗКИ ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease-out, visibility 200ms ease-out;
}

.loading-overlay.active {
    opacity: 0.7;
    visibility: visible;
    pointer-events: all;
}

/* Спиннер загрузки */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 136, 0, 0.2);
    border-top-color: #ff8800;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10001;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ===== QR VIEW ===== */
.qr-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.qr-view.fade-in {
    opacity: 1;
}

.qr-container {
    text-align: center;
}

.qr-code {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 2px;
    color: #000;
}

.qr-number {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 30px;
    color: #000;
}

.qr-image {
    width: 280px;
    max-width: calc(100% - 40px);
    margin: 0 auto 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qr-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    display: block;
    max-width: 100%;
}

/* Адаптивность для мобильных */
@media (max-width: 375px) {
    .qr-image {
        width: 100%;
        max-width: calc(100vw - 40px);
    }
}

.tap-to-close {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: #000;
    cursor: pointer;
    z-index: 2001;
}

.tap-to-close:hover {
    opacity: 0.7;
}

.phone {
    transition: opacity 200ms ease-in;
}
