/* ================================
   Skidka PWA — Mobile-First Styles
   Inspired by: "Центр помощи населению" + Figma "Личный кабинет спортсмена"
   ================================ */

:root {
    /* Primary gradient  */
    --grad-start: #6366f1;
    --grad-mid: #818cf8;
    --grad-end: #a5b4fc;

    /* Accent */
    --accent: #4f46e5;
    --accent-light: #eef2ff;

    /* Surfaces */
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-bg-solid: #ffffff;
    --page-bg: #f0f2f8;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-on-gradient: #ffffff;

    /* Sizes */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --nav-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--page-bg);
}

/* ===== Screens ===== */
.screen {
    display: none;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}
.screen.active {
    display: block;
}

/* ===== Hero Header (gradient like "Центр помощи") ===== */
.hero-header {
    background: linear-gradient(145deg, var(--grad-start), var(--grad-mid), var(--grad-end));
    padding: 48px 24px 32px;
    border-radius: 0 0 28px 28px;
    color: var(--text-on-gradient);
    position: relative;
    overflow: hidden;
}

.hero-header::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.hero-header h1 {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.1;
    position: relative;
    z-index: 1;
}

.hero-sub {
    font-size: 16px;
    font-weight: 300;
    opacity: 0.85;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* ===== Search Bar ===== */
.search-wrap {
    padding: 0 16px;
    margin-top: -22px;
    position: relative;
    z-index: 5;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--card-bg-solid);
    border-radius: var(--radius-md);
    padding: 0 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    height: 48px;
}

.search-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-right: 12px;
}

.search-bar input {
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    width: 100%;
    background: transparent;
    color: var(--text-primary);
}
.search-bar input::placeholder {
    color: var(--text-secondary);
}

/* ===== Stores Horizontal Carousel ===== */
.stores-carousel {
    display: flex;
    gap: 10px;
    padding: 20px 16px 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.stores-carousel::-webkit-scrollbar {
    display: none;
}

.store-chip {
    flex-shrink: 0;
    padding: 10px 18px;
    background: var(--card-bg-solid);
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    border: 2px solid transparent;
}

.store-chip:active {
    transform: scale(0.95);
}

.store-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

/* ===== Section Title ===== */
.section-title {
    padding: 16px 16px 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ===== Catalog Dropdown ===== */
.catalog-dropdown-wrap {
    padding: 0 16px 8px;
}

.catalog-dropdown {
    width: 100%;
    padding: 12px 16px;
    padding-right: 40px;
    background: var(--card-bg-solid);
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: border-color 0.2s;
}

.catalog-dropdown:focus {
    border-color: var(--accent);
}

/* ===== Offers List ===== */
.offers-list {
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.store-section-header {
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: 0.3px;
}

/* ===== Offer Card ===== */
.offer-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.offer-card:active {
    transform: scale(0.98);
}

.offer-card .card-cat {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 4px;
}

.offer-card .card-store {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.offer-card .card-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.offer-card .card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.offer-card .card-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.offer-card .card-price .rub {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
}

.offer-card .card-fav {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.offer-card .card-fav.liked {
    background: #fef2f2;
    color: #ef4444;
}

.offer-card .card-desc {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.05);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.empty-state p {
    font-size: 15px;
    line-height: 1.5;
}

/* ===== Sub-Header ===== */
.sub-header {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 12px;
    background: var(--card-bg-solid);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 10;
}
.sub-header h2 {
    font-size: 18px;
    font-weight: 600;
}
.back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.search-bar-inline {
    flex-grow: 1;
    height: 40px;
    padding: 0 12px;
    box-shadow: none;
    border: 1px solid rgba(0,0,0,0.08);
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--card-bg-solid);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.06);
    z-index: 100;
    border-radius: 20px 20px 0 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 12px;
    transition: color 0.2s;
}

.nav-item svg {
    transition: all 0.2s;
}

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

.nav-item.active svg {
    stroke: var(--accent);
}

/* ===== Loader ===== */
.loader-screen {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(79, 70, 229, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Responsive tweaks ===== */
@media (min-width: 481px) {
    #app {
        box-shadow: 0 0 40px rgba(0,0,0,0.08);
    }
}
