/* frontend/static/styles.css */

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    margin: 0; padding: 0; 
    background-color: #fff; 
    color: #000; 
    padding-bottom: 100px; /* Место под кнопку */
    -webkit-tap-highlight-color: transparent;
}

.header {
    display: flex;
    align-items: center; /* Центровка по вертикали */
    justify-content: space-between; /* Распределяет лево, центр и право */
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Стили для иконок в заголовке */
.header span {
    display: inline-block;
    padding: 5px; /* Увеличиваем зону нажатия */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* Убирает синий квадрат при нажатии на айфонах */
}

/* Стиль для логотипа в шапке */
.brand-logo {
    font-family: 'Inter', sans-serif; /* Наш красивый шрифт */
    font-weight: 900;       /* Самый жирный */
    font-size: 20px;        /* Крупнее обычного */
    text-transform: uppercase; /* ВСЕ ЗАГЛАВНЫЕ */
    letter-spacing: 1px;    /* Чуть раздвинем буквы (дорогой эффект) */
    background: linear-gradient(90deg, #3390ec, #2cab37); /* Градиент Синий -> Зеленый */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }

.card { 
    border: 1px solid #e0e0e0; border-radius: 8px; 
    background: #fff; display: flex; flex-direction: column; align-items: center; 
    padding-bottom: 8px; position: relative; overflow: hidden;
}
.image-container { 
    width: 100%; height: 140px; background: #f4f4f4; 
    display: flex; align-items: center; justify-content: center; 
}
.card img { width: 100%; height: 100%; object-fit: cover; }

.name { font-size: 13px; margin: 8px 4px; text-align: center; height: 32px; overflow: hidden; }
.price { font-weight: bold; color: #3390ec; margin-bottom: 8px; }

/* Кнопка добавления */
.btn-add { 
    background: #3390ec; color: #fff; border: none; padding: 10px; width: 90%; 
    border-radius: 6px; font-weight: bold; font-size: 13px; cursor: pointer;
}

/* Счетчик */
.counter { 
    display: none; align-items: center; justify-content: space-between; width: 90%; 
}
.btn-control { 
    width: 40px; height: 40px; background: #e0e0e0; border-radius: 6px; 
    display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 18px; cursor: pointer; user-select: none;
}

/* --- НАША СУПЕР-КНОПКА --- */
#my-checkout-btn {
    position: fixed;
    bottom: 15px; left: 15px; right: 15px;
    background-color: #2cab37; /* Фирменный зеленый */
    color: white;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px; font-weight: bold; text-align: center;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 9999;
    display: none; /* Скрыта пока корзина пуста */
    cursor: pointer;
    transition: transform 0.1s ease;
}
#my-checkout-btn:active {
    transform: scale(0.96);
    background-color: #259630;
}

#loading { text-align: center; padding: 40px; }

/* --- СТИЛЬ ДЛЯ ПРИЛИПАЮЩЕГО ПОИСКА --- */
.search-wrapper {
    position: -webkit-sticky;
    position: sticky;
    top: 53px; /* Высота шапки */
    z-index: 99;
    background: rgba(243, 244, 246, 0.98);
    backdrop-filter: blur(10px);
    padding: 10px 0;
    
    /* Добавляем анимацию появления */
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background-color: #f4f4f4;
    font-size: 16px; /* Чтобы iPhone не приближал экран при вводе */
    box-sizing: border-box; /* Чтобы padding не ломал ширину */
    outline: none;
    transition: all 0.2s;
}

#search-input:focus {
    background-color: #fff;
    border-color: #2cab37;
    box-shadow: 0 0 0 3px rgba(44, 171, 55, 0.1);
}

/* Скрываем пустые результаты (если понадобится) */
.hidden {
    display: none !important;
}

/* СКЕЛЕТОН (Загрузка) */
.skeleton-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
}

.skeleton-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding-bottom: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.skeleton-image {
    width: 100%;
    height: 140px;
    background: #eee;
    margin-bottom: 10px;
}

.skeleton-text {
    height: 14px;
    background: #eee;
    border-radius: 4px;
    margin-bottom: 6px;
    width: 80%;
}

.skeleton-price {
    height: 18px;
    background: #eee;
    border-radius: 4px;
    width: 40%;
    margin-bottom: 10px;
}

.skeleton-btn {
    height: 32px;
    background: #eee;
    border-radius: 6px;
    width: 90%;
}

/* Анимация мерцания */
.skeleton-image, .skeleton-text, .skeleton-price, .skeleton-btn {
    animation: shimmer 1.5s infinite linear;
    background: linear-gradient(to right, #eeeeee 8%, #f5f5f5 18%, #eeeeee 33%);
    background-size: 800px 104px;
}

@keyframes shimmer {
    0% { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}

/* КАТЕГОРИИ (СЕТКА / ГРИД) */
.categories-wrapper {
    position: -webkit-sticky;
    position: sticky;
    
    /* 👇 Фиксируем, больше никакой анимации не нужно */
    top: 54px; 
    
    z-index: 98;
    background: #fff;
    padding: 10px 0 10px 10px;
    white-space: nowrap;
    overflow-x: auto;
    border-bottom: 1px solid #f0f0f0;
}

.categories-wrapper::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    display: inline-block;
    padding: 10px 18px; /* Чуть больше воздуха */
    background: #f4f4f4;
    border-radius: 12px; /* Более квадратные (современный стиль) */
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    user-select: none;
    text-align: center;
    flex-grow: 1; /* Кнопки будут растягиваться равномерно (опционально) */
    
}

.cat-btn.active {
    background: #2cab37;
    color: #fff;
    border-color: #2cab37;
    box-shadow: 0 4px 10px rgba(44, 171, 55, 0.2);
}

/* МОДАЛЬНОЕ ОКНО */
.modal-overlay {
    display: none; /* Скрыто */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Затемнение */
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    max-height: 80vh; /* Чтобы не вылезало за экран */
}

.modal-header {
    padding: 15px;
    background: #f4f4f4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.close-btn { font-size: 24px; cursor: pointer; color: #888; }

#cart-items-list {
    padding: 15px;
    overflow-y: auto; /* Скролл если много товаров */
}

.cart-item-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px solid #f9f9f9;
    padding-bottom: 5px;
    font-size: 14px;
}
.item-name { flex: 1; margin-right: 10px; }
.item-qty { font-weight: bold; margin-right: 10px; }
.item-price { color: #888; }

.modal-footer {
    padding: 15px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
}
.total-row {
    font-size: 18px; font-weight: bold; text-align: right; margin-bottom: 15px;
}

.confirm-btn {
    width: 100%;
    background: #2cab37;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px; font-weight: bold;
    cursor: pointer;
}
.confirm-btn:active { opacity: 0.8; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ПРОСМОТР ФОТО */
#image-viewer {
    background: rgba(0, 0, 0, 0.9); /* Темный фон */
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20000; /* Поверх всего */
}

#full-image {
    /* Ставим auto, чтобы пропорции не искажались */
    width: auto;
    height: auto;
    
    /* Ограничиваем почти по границам экрана */
    max-width: 98vw;  /* 98% ширины экрана */
    max-height: 95vh; /* 95% высоты экрана */
    
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    
    /* Важно: contain показывает картинку целиком, не обрезая */
    object-fit: contain; 
    
    animation: zoomIn 0.2s;
}

.close-btn-img {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    font-weight: bold;
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ЭКРАН УСПЕХА */
.success-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #fff;
    z-index: 30000;
    display: none; /* Скрыт */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.success-overlay h2 { margin-top: 20px; color: #2cab37; font-size: 24px; }
.success-overlay p { color: #888; }

/* Анимация галочки */
.success-icon {
    width: 80px; height: 80px;
    position: relative;
    border-radius: 50%;
    box-sizing: content-box;
    border: 4px solid #2cab37;
}
.success-icon::before {
    top: 3px; left: -2px; width: 30px; 
    transform-origin: 100% 50%; border-radius: 100px 0 0 100px;
}
.success-icon::after {
    top: 0; left: 30px; width: 60px; 
    transform-origin: 0 50%; border-radius: 0 100px 100px 0;
    animation: rotate-circle 4.25s ease-in;
}
.success-icon-line {
    height: 5px; background-color: #2cab37; display: block; 
    border-radius: 2px; position: absolute; z-index: 10;
}
.success-icon-line.tip {
    top: 46px; left: 14px; width: 25px; transform: rotate(45deg);
    animation: icon-line-tip 0.75s;
}
.success-icon-line.long {
    top: 38px; right: 8px; width: 47px; transform: rotate(-45deg);
    animation: icon-line-long 0.75s;
}
.success-icon-circle {
    top: -4px; left: -4px; z-index: 10; width: 80px; height: 80px; 
    border-radius: 50%; position: absolute; box-sizing: content-box; 
    border: 4px solid rgba(44, 171, 55, .5);
}
.success-icon-fix {
    top: 8px; width: 5px; left: 26px; z-index: 1; height: 85px; 
    position: absolute; transform: rotate(-45deg); background-color: #fff;
}

@keyframes icon-line-tip {
    0% { width: 0; left: 1px; top: 19px; }
    54% { width: 0; left: 1px; top: 19px; }
    70% { width: 50px; left: -8px; top: 37px; }
    84% { width: 17px; left: 21px; top: 48px; }
    100% { width: 25px; left: 14px; top: 46px; }
}
@keyframes icon-line-long {
    0% { width: 0; right: 46px; top: 54px; }
    65% { width: 0; right: 46px; top: 54px; }
    84% { width: 55px; right: 0px; top: 35px; }
    100% { width: 47px; right: 8px; top: 38px; }
}

/* КАРТОЧКА ЗАКАЗА В ИСТОРИИ */
.history-card {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

/* frontend/static/styles.css */

.history-status {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    
    /* ВАЖНО: Убираем любые цвета отсюда. Они будут приходить из JS. */
    color: #000; 
    background: #eee;
}

.history-sum {
    font-size: 16px;
    font-weight: bold;
    color: #2cab37;
    text-align: right;
    margin-top: 8px;
}

.history-details {
    margin-top: 10px;
    padding-top: 5px;
    border-top: 1px solid #eee;
    display: none;
    background: #fdfdfd;
}

.history-details.show { display: block; }

/* Красивая строка товара */
.hist-item-row {
    padding: 10px 0;
    border-bottom: 1px dashed #e0e0e0;
}
.hist-item-row:last-child { border-bottom: none; }

.hist-name {
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.3;
}

.hist-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #777;
}

.hist-total {
    font-weight: bold;
    color: #000;
}

.toggle-details {
    color: #3390ec;
    font-size: 12px;
    cursor: pointer;
    margin-top: 5px;
    display: inline-block;
}

/* Профиль */
.profile-body {
    padding: 15px;
    text-align: left;
}

.profile-item {
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.profile-label {
    font-size: 12px;
    color: #888;
    display: block;
    margin-bottom: 2px;
}

.profile-value {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

/* --- ПОДВАЛ (АВТОРСТВО) --- */
.app-footer {
    text-align: center;
    padding: 30px 0 10px; /* Отступы сверху и снизу */
    margin-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.05); /* Тонкая линия-разделитель */
}

.app-footer p {
    margin: 4px 0;
    font-size: 12px;
    color: var(--text-sec); /* Серый цвет */
}

.app-footer .developer {
    font-size: 11px;
    opacity: 0.7;
}

.app-footer a {
    color: var(--primary); /* Синий цвет ссылки */
    text-decoration: none;
    font-weight: 600;
}
/* СТИЛИ ДЛЯ ОСТАТКОВ */
.stock-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
}

/* Когда товар есть */
.in-stock {
    background-color: rgba(44, 171, 55, 0.1);
    color: #2cab37;
}

/* Когда товара нет */
.out-stock {
    background-color: #f3f4f6;
    color: #9ca3af;
    border: 1px solid #e5e7eb;
}

/* СТИЛИ ПУНКТОВ МЕНЮ */
.sidebar-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    font-size: 16px;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-item:active {
    background: #f0f0f0;
}

.sidebar-item.active {
    background: rgba(44, 171, 55, 0.1); /* Светло-зеленый фон */
    color: #2cab37; /* Зеленый текст */
    font-weight: 600;
    border-left: 4px solid #2cab37; /* Полоска слева */
}

/* Стрелочка справа */
.sidebar-arrow {
    color: #ccc;
    font-size: 14px;
}
.sidebar-item.active .sidebar-arrow {
    color: #2cab37;
}