/* Файл: frontend/static/css/orders.css */

:root {
    --bg-base: #000000;
    --bg-elevated: #1c1c1e;
    --bg-card: rgba(28, 28, 30, 0.65);
    --text-primary: #ffffff;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-card: rgba(255, 255, 255, 0.12);
    --accent: var(--tg-theme-button-color, #0a84ff);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --radius-main: 20px;
    --radius-small: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', Roboto, Helvetica, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    /* Убрали анимацию с body, чтобы position: fixed не ломался */
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 🚀 АНИМАЦИЯ ПОЯВЛЕНИЯ ТОЛЬКО ДЛЯ КОНТЕНТА */
.app-main { 
    padding-top: calc(var(--tg-safe-area-inset-top, 24px) + 124px); 
    padding-left: 16px; padding-right: 16px;
    padding-bottom: 120px;
    animation: contentFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* 🚀 АНИМАЦИЯ ЗАТУХАНИЯ КОНТЕНТА (вешается через JS) */
.main-fade-out {
    animation: contentFadeOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}
@keyframes contentFadeOut {
    to { opacity: 0; transform: scale(0.98); }
}

.loader {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Шапка */
.app-header {
    position: fixed; 
    top: calc(var(--tg-safe-area-inset-top, 24px) + 50px); 
    left: 16px; right: 16px;
    background-color: rgba(28, 28, 30, 0.8); 
    backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-card);
    border-radius: 100px; 
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 18px; z-index: 50;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6); 
}
.user-block { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 32px; height: 32px; background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: var(--text-primary); overflow: hidden;
}
.logo-title { font-weight: 800; font-size: 15px; letter-spacing: 0.8px; }

/* Блок баланса */
.balance-block {
    display: flex; align-items: center; gap: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 6px 6px 6px 12px;
    border-radius: 100px;
    font-weight: 700; font-size: 13px;
    color: var(--text-primary); cursor: pointer;
}
.add-btn {
    display: flex; align-items: center; justify-content: center;
    background-color: var(--accent); color: var(--accent-text);
    width: 24px; height: 24px; border-radius: 50%;
}

.orders-list { display: flex; flex-direction: column; gap: 14px; }

/* Разделители дат */
.time-divider {
    display: flex; align-items: center; margin: 12px 0 4px;
}
.time-divider::before, .time-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}
.time-divider span {
    margin: 0 12px; font-size: 11px; font-weight: 700; 
    color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px;
}

/* Карточка */
.order-card {
    background: var(--bg-card); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-card); border-radius: var(--radius-main);
    padding: 14px; display: flex; align-items: center; gap: 14px;
    text-decoration: none; color: var(--text-primary);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.order-card:active { transform: scale(0.97); background: rgba(28, 28, 30, 0.9); }

.order-img-wrapper {
    position: relative; width: 64px; height: 64px; border-radius: var(--radius-small);
    overflow: hidden; background-color: var(--bg-base); flex-shrink: 0; border: 1px solid var(--border-color);
}
.order-img { width: 100%; height: 100%; object-fit: cover; }
.order-info { flex-grow: 1; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.order-top-row { display: flex; justify-content: space-between; align-items: center; }
.order-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.2px; }
.order-price { font-size: 16px; font-weight: 800; color: #ffffff; letter-spacing: -0.3px; }
.order-bottom-row { display: flex; justify-content: space-between; align-items: center; }
.order-date { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

.order-status {
    font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px;
    display: flex; align-items: center; gap: 5px; text-transform: uppercase; letter-spacing: 0.3px;
}
.status-active { background-color: rgba(255, 159, 10, 0.15); color: #ff9f0a; border: 1px solid rgba(255, 159, 10, 0.3); }
.status-active::before { content: ''; width: 5px; height: 5px; background-color: #ff9f0a; border-radius: 50%; box-shadow: 0 0 8px #ff9f0a; }
.status-completed { background-color: rgba(52, 199, 89, 0.15); color: #34c759; border: 1px solid rgba(52, 199, 89, 0.3); }
.status-completed::before { content: ''; width: 5px; height: 5px; background-color: #34c759; border-radius: 50%; box-shadow: 0 0 8px #34c759; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 80px 20px; gap: 14px; }
.empty-icon-wrapper { width: 72px; height: 72px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border-card); display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 4px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.empty-title { font-size: 18px; font-weight: 700; }
.empty-desc { font-size: 14px; color: var(--text-secondary); max-width: 260px; line-height: 1.4; }
.empty-btn { margin-top: 14px; padding: 12px 28px; background-color: var(--accent); color: #fff; border-radius: 14px; font-weight: 700; text-decoration: none; box-shadow: 0 8px 20px rgba(10, 132, 255, 0.4); transition: transform 0.1s; }
.empty-btn:active { transform: scale(0.96); }

/* Нижнее меню */
.bottom-nav {
    position: fixed; bottom: calc(var(--tg-safe-area-inset-bottom, 24px) + 16px); left: 16px; right: 16px; 
    background-color: rgba(28, 28, 30, 0.85); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-card); border-radius: 100px; display: flex; justify-content: space-around;
    padding: 12px 20px; z-index: 100; box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6); 
}
.nav-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #8e8e93; font-size: 11px; gap: 4px; font-weight: 500; transition: color 0.2s; }
.nav-item.active { color: var(--text-primary); }
.nav-item.active svg { color: var(--accent); filter: drop-shadow(0 0 8px rgba(10,132,255,0.5)); }

/* ============================================================
   ПК-адаптация списка покупок (от 961px).
   Мобильная вёрстка выше не затрагивается:
   - шапка сужается и центрируется по странице;
   - меню становится левой вертикальной колонкой (как на главной);
   - список покупок ограничен по ширине.
   ============================================================ */
@media (min-width: 961px) {
    html, body {
        --road-shell: min(1240px, calc(100vw - 32px));
        --road-rail: 252px;
        --road-gutter: max(16px, calc((100vw - 1240px) / 2));
        padding-bottom: 24px;
    }

    .app-header {
        left: 50%; right: auto;
        width: var(--road-shell);
        transform: translateX(-50%);
        gap: 16px;
    }

    .app-main {
        width: var(--road-shell);
        margin: 0 auto;
        padding-left: calc(var(--road-rail) + 24px);
        padding-right: 0;
        padding-bottom: 40px;
    }

    .orders-list { max-width: 820px; gap: 12px; }

    .bottom-nav {
        z-index: 40;
        flex-direction: column;
        justify-content: flex-start;
        gap: 5px;
        top: 140px; left: var(--road-gutter); right: auto; bottom: auto;
        width: var(--road-rail);
        padding: 10px;
        border-radius: 18px;
    }

    .bottom-nav .nav-item {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        gap: 11px;
        padding: 11px 12px;
        border-radius: 11px;
        font-size: 13px;
        color: var(--text-secondary);
    }

    .bottom-nav .nav-item:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--text-primary);
    }

    .bottom-nav .nav-item.active {
        background: var(--accent);
        color: var(--accent-text);
    }

    .bottom-nav .nav-item.active svg {
        color: var(--accent-text);
        filter: none;
    }

    .bottom-nav .nav-item svg {
        width: 19px; height: 19px; flex-shrink: 0;
    }

    .order-card:hover {
        transform: translateY(-2px);
        background: rgba(28, 28, 30, 0.9);
        border-color: rgba(255, 255, 255, 0.2);
    }

    .empty-btn:hover { filter: brightness(1.12); }
}
/* ============================================================
   Светлая тема (ПК без Telegram и светлая тема Telegram).
   Базовые правила выше рассчитаны на тёмный фон, поэтому
   переопределяем жёстко заданные цвета.
   ============================================================ */
html[data-theme="light"] {
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-card: rgba(0, 0, 0, 0.08);
    --border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .app-header {
    background-color: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .avatar,
html[data-theme="light"] .balance-block {
    background-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .order-price { color: #000000; }

html[data-theme="light"] .order-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .order-card:active {
    background: rgba(255, 255, 255, 0.98);
}

html[data-theme="light"] .bottom-nav {
    background-color: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .nav-item { color: rgba(60, 60, 67, 0.6); }
html[data-theme="light"] .nav-item.active { color: #000000; }

@media (min-width: 961px) {
    html[data-theme="light"] .bottom-nav .nav-item:hover {
        background: rgba(0, 0, 0, 0.06);
        color: var(--text-primary);
    }
    html[data-theme="light"] .order-card:hover {
        background: rgba(255, 255, 255, 0.98);
        border-color: rgba(0, 0, 0, 0.15);
    }
}
