/* Модальное окно товара */
.modal {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000 !important;
    overflow-x: hidden !important;
    overflow-y: auto;
    animation: fadeIn 0.2s;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-overflow-scrolling: touch;
}

.modal::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.modal.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: calc(100% - 40px);
    max-width: 420px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    margin-top: 20px;
    animation: scaleIn 0.3s ease-out;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text);
}

.modal-close:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.2);
}

.modal-image-wrapper {
    background: var(--surface-elevated);
    padding: 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
}

.modal-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    border-radius: 12px;
}

.modal-body {
    padding: 20px;
}

.product-tag {
    display: inline-block;
    padding: 5px 10px;
    background: rgba(var(--primary-rgb, 147, 51, 234), 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(var(--primary-rgb, 147, 51, 234), 0.3);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.modal-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    flex: 1;
    margin-right: 10px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:active {
    transform: scale(0.9);
    background: var(--background);
}

.modal-price {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary-light);
    margin-bottom: 18px;
}

/* Выбор вкуса и крепости */
.variant-picker {
    margin-bottom: 16px;
}

.variant-picker-strength {
    padding-top: 4px;
}

.variant-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.variant-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.variant-section-hint {
    font-size: 11px;
    color: var(--text-secondary);
}

.variant-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.variant-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    max-width: 100%;
}

.variant-chip:active {
    transform: scale(0.98);
}

.variant-chip.active {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 147, 51, 234), 0.14);
    box-shadow: 0 0 16px rgba(var(--primary-rgb, 147, 51, 234), 0.2);
    color: var(--primary-light);
}

.variant-chip-name {
    line-height: 1.3;
}

.variant-chip-strength {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.variant-chips-strength {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.strength-chip {
    align-items: center;
    text-align: center;
    padding: 12px 10px;
}

.strength-chip-value {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.1;
}

.strength-chip-tier {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.85;
}

.tier-light {
    border-color: rgba(34, 197, 94, 0.35);
}

.tier-light.active,
.variant-chip-strength.tier-light {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.4);
}

.tier-medium {
    border-color: rgba(245, 158, 11, 0.35);
}

.tier-medium.active,
.variant-chip-strength.tier-medium {
    background: rgba(245, 158, 11, 0.12);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.4);
}

.tier-strong {
    border-color: rgba(239, 68, 68, 0.35);
}

.tier-strong.active,
.variant-chip-strength.tier-strong {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
}

.tier-unknown {
    border-color: var(--border);
}

.variant-selection-summary {
    margin: 4px 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(var(--primary-rgb, 147, 51, 234), 0.1);
    border: 1px solid rgba(var(--primary-rgb, 147, 51, 234), 0.22);
    font-size: 13px;
    color: var(--text-secondary);
}

.variant-selection-summary strong {
    color: var(--primary-light);
    font-weight: 700;
}

.variant-selection-summary-empty {
    background: var(--surface-elevated);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.flavor-section {
    margin: 20px 0;
}

.flavor-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

.flavor-select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface-elevated);
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23C084FC' d='M7 10L2 5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    padding-right: 45px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.flavor-select:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 147, 51, 234), 0.25), 0 0 20px rgba(var(--primary-rgb, 147, 51, 234), 0.1);
    transform: translateY(-1px);
}

.flavor-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 147, 51, 234), 0.2), 0 4px 12px rgba(var(--primary-rgb, 147, 51, 234), 0.3), 0 0 25px rgba(var(--primary-rgb, 147, 51, 234), 0.15);
}

.flavor-select:active {
    transform: translateY(0);
}

.quantity-section {
    margin: 18px 0 20px;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
}

.quantity-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--primary);
    background: var(--surface-elevated);
    border-radius: 12px;
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb, 147, 51, 234), 0.15);
}

.quantity-btn:hover {
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 147, 51, 234), 0.3), 0 0 15px rgba(var(--primary-rgb, 147, 51, 234), 0.2);
    transform: translateY(-1px);
}

.quantity-btn:active {
    transform: scale(0.9);
    background: var(--primary);
    color: white;
}

.quantity-value {
    font-size: 24px;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
    color: var(--text);
}

.modal-actions-row {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    align-items: stretch;
}

.btn-share {
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 147, 51, 234), 0.1) 0%, rgba(var(--primary-rgb, 147, 51, 234), 0.05) 100%);
    border: 2px solid rgba(var(--primary-rgb, 147, 51, 234), 0.2);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-share:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 147, 51, 234), 0.3);
}

.btn-share:active {
    transform: translateY(0);
}

/* ============================================
   Premium модалка товара
   ============================================ */

.product-modal.active {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.78);
}

.product-modal-content {
    position: relative;
    width: 100%;
    max-width: 520px;
    height: 92dvh;
    max-height: 92dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--background);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    animation: productModalSlideUp 0.22s ease-out;
}

#modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (min-width: 520px) {
    .product-modal.active {
        align-items: center;
        padding: 16px;
    }

    .product-modal-content {
        border-radius: 22px;
        height: min(88dvh, 780px);
        max-height: min(88dvh, 780px);
        animation: none;
    }
}

@keyframes productModalSlideUp {
    from { transform: translateY(18%); }
    to { transform: translateY(0); }
}

.product-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 12;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.product-modal-close svg {
    width: 15px;
    height: 15px;
}

.product-modal-close:active {
    transform: scale(0.94);
}

.product-modal-hero {
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(var(--primary-rgb, 147, 51, 234), 0.18) 0%, transparent 100%);
}

.product-modal-hero-mesh {
    display: none;
}

.product-modal .modal-image-wrapper {
    position: relative;
    z-index: 1;
    min-height: 120px;
    padding: 18px 20px 36px;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-modal .modal-image {
    max-width: 150px;
    max-height: 110px;
}

.product-modal-price-badge {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 2;
    padding: 7px 11px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    background: var(--primary);
}

.product-modal-hero-compact .modal-image-wrapper {
    min-height: 118px;
    padding: 14px 16px 38px;
}

.product-modal-hero-compact .modal-image {
    max-width: 148px;
    max-height: 108px;
}

.product-modal-selected-badge {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    background: #10b981;
}

.product-modal-selected-badge[hidden] {
    display: none !important;
}

.product-modal-scroll {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 8px 12px 4px;
}

.product-modal-intro {
    margin-bottom: 8px;
    flex-shrink: 0;
}

.product-modal-intro .modal-title {
    font-size: 18px;
    margin: 0 0 2px;
    letter-spacing: -0.02em;
}

.product-modal-brand {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.product-modal-footer {
    flex-shrink: 0;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--background);
}

.product-modal-cta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.product-modal-add {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    height: 52px;
    margin-top: 0 !important;
    margin-left: 0;
    padding: 8px 14px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-weight: 800;
    overflow: hidden;
}

.product-modal-add-main {
    font-size: 15px;
    line-height: 1.1;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-modal-add-meta {
    font-size: 11px;
    line-height: 1.1;
    font-weight: 700;
    opacity: 0.92;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-modal-add.is-ready {
    box-shadow: none;
}

.product-modal-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.product-modal-share {
    flex: 0 0 auto;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.product-modal-share svg {
    width: 18px;
    height: 18px;
}

.product-modal-share:active {
    transform: scale(0.94);
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* —— Flavor picker (fast + even) —— */
.flavor-picker {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.flavor-picker.has-selection {
    border-color: rgba(var(--primary-rgb, 147, 51, 234), 0.4);
}

.flavor-picker-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.flavor-picker-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
}

.flavor-picker-count {
    min-width: 28px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
}

.flavor-picker.has-selection .flavor-picker-count {
    color: #fff;
    background: var(--primary);
}

.flavor-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 54px;
    gap: 7px;
    align-content: start;
    overflow-y: auto;
    padding: 1px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    contain: content;
}

.flavor-card {
    position: relative;
    height: 54px;
    width: 100%;
    margin: 0;
    padding: 6px 8px 8px;
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    contain: layout paint;
}

.flavor-card:active {
    background: rgba(255, 255, 255, 0.08);
}

.flavor-card.is-on {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 147, 51, 234), 0.28);
    color: #fff;
}

.flavor-card-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    max-width: 100%;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.flavor-card-stock {
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1;
    opacity: 0.72;
    font-variant-numeric: tabular-nums;
}

.flavor-card.is-on .flavor-card-stock {
    opacity: 0.9;
}

.flavor-card.is-low .flavor-card-stock {
    color: #fbbf24;
    opacity: 1;
}

.product-modal-quantity-single {
    margin-top: 8px;
    padding: 18px;
    border-radius: 18px;
}

.product-modal-quantity,
.product-modal-quantity-single {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
}

.product-modal-quantity .quantity-control {
    margin-top: 6px;
}

.product-modal .quantity-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
}

.product-modal .quantity-value {
    min-width: 52px;
    font-size: 24px;
}

.product-share-toast {
    position: fixed;
    top: 78px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    padding: 12px 18px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    animation: toastIn 0.2s ease-out;
}

.product-share-toast.is-out {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.cart-burst-particle {
    position: fixed;
    pointer-events: none;
    z-index: 10002;
    font-size: 18px;
    animation: cartBurst 0.9s ease-out forwards;
}

@keyframes cartBurst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--final-x), var(--final-y)) scale(0.2); opacity: 0; }
}

@media (max-width: 360px) {
    .flavor-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 48px;
    }
    .flavor-card {
        height: 48px;
    }
}
