/* Основные стили */
:root {
    --primary-color: #D90D18;
    --primary-dark: #A00A12;
    --primary-light: #FF4A52;
    --secondary-color: #FFFFFF;
    --success-color: #D90D18;
    --danger-color: #A00A12;
    --warning-color: #FF4A52;
    --dark-color: #1C1C1E;
    --light-color: #FFF5F5;
    --gray-color: #8E8E93;
    --border-color: #FFE5E5;

    /* Telegram theme variables */
    --tg-theme-bg-color: #FFFFFF;
    --tg-theme-text-color: #1C1C1E;
    --tg-theme-button-color: #D90D18;
    --tg-theme-button-text-color: #FFFFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: #FFFFFF !important;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #FFFFFF !important;
    color: var(--tg-theme-text-color);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    position: relative;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
}

.container {
    max-width: 100%;
    padding: 0 15px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
}

/* Шапка */
.header {
    padding: 20px 0;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 0 0 20px 20px;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(220, 20, 60, 0.3);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 0 10px;
}

.logo {
    height: 50px;
    width: auto;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.logo-text h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    font-family: 'Nunito', sans-serif;
    letter-spacing: 0.5px;
}

.logo-text p {
    font-size: 14px;
    opacity: 0.9;
}

/* Поиск */
.search-container {
    padding: 0 10px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    padding: 10px 20px;
    box-shadow: 0 4px 15px rgba(220, 20, 60, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.search-box i {
    color: var(--gray-color);
    margin-right: 10px;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--dark-color);
    outline: none;
}

.search-box input::placeholder {
    color: var(--gray-color);
}

.search-clear {
    background: transparent;
    border: none;
    color: var(--gray-color);
    cursor: pointer;
    padding: 5px;
    display: none;
}

.search-clear.active {
    display: block;
}

/* Категории */
.categories-container {
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.categories-scroll {
    display: flex;
    gap: 10px;
    padding: 10px 5px;
    min-width: min-content;
}

.category-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    background: var(--light-color);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 80px;
    font-weight: 600;
}

.category-tab.active {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 20, 60, 0.4);
    border-color: var(--primary-color);
}

.category-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.category-name {
    font-size: 12px;
    font-weight: 500;
}

/* Фильтры */
.filters-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.filters {
    display: flex;
    gap: 10px;
}

.filter-select {
    padding: 8px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.filter-select:hover {
    border-color: var(--primary-light);
}

.filter-select:focus {
    border-color: var(--primary-color);
}

.products-count {
    font-size: 14px;
    color: var(--primary-dark);
    font-weight: 600;
}

/* Сетка товаров */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    padding: 0 10px;
    margin-bottom: 30px;
}

.product-card {
    background: var(--tg-theme-bg-color);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(220, 20, 60, 0.1);
    border: 2px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(220, 20, 60, 0.2);
    border-color: var(--primary-light);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(45deg, #f5f5f5, #e0e0e0);
}

.product-info {
    padding: 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.current-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Nunito', sans-serif;
}

.old-price {
    font-size: 14px;
    color: var(--gray-color);
    text-decoration: line-through;
}

.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.tag {
    font-size: 10px;
    padding: 3px 8px;
    background: var(--light-color);
    border-radius: 10px;
    color: var(--primary-dark);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Загрузка */
.loading-spinner {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--light-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Кнопка наверх */
.scroll-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(220, 20, 60, 0.4);
    transition: all 0.3s ease;
    display: none;
    z-index: 1000;
}

.scroll-top-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.scroll-top-btn.show {
    display: block;
}

/* Страница товара */
.back-button {
    padding: 15px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.back-link {
    display: inline-block;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.back-link:hover {
    color: var(--primary-dark);
}

.product-detail {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (min-width: 768px) {
    .product-detail {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        margin-bottom: 40px;
    }
}

.product-gallery {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

@media (min-width: 768px) {
    .product-gallery {
        position: sticky;
        top: 20px;
    }
}

.main-image-container {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.main-image {
    position: relative;
    width: 100%;
    height: auto;
}

.main-image img {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
    background: #FFFFFF;
    box-sizing: border-box;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    color: var(--primary-color);
    font-size: 18px;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.gallery-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.gallery-nav-prev {
    left: 15px;
}

.gallery-nav-next {
    right: 15px;
}

.image-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
}

.discount-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.4);
}

.thumbnails {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 5px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.thumbnail {
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.thumbnail:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.thumbnail.active {
    opacity: 1;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(217, 13, 24, 0.3);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-header {
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.product-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
    font-family: 'Nunito', sans-serif;
    color: var(--primary-dark);
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .product-title {
        font-size: 24px;
    }
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stars {
    display: flex;
    align-items: center;
    gap: 3px;
}

.stars i {
    color: #FFD700;
}

.stars i.filled {
    color: #FF9500;
}

.rating-value {
    font-weight: 600;
    margin-left: 5px;
}

.reviews-count {
    color: var(--gray-color);
    font-size: 14px;
}

.product-price {
    margin-bottom: 20px;
}

.current-price {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Nunito', sans-serif;
}

.old-price {
    font-size: 20px;
    color: var(--gray-color);
    text-decoration: line-through;
    margin-left: 10px;
}

.product-description {
    margin-bottom: 25px;
    padding: 20px;
    background: var(--light-color);
    border-radius: 15px;
    border: 2px solid var(--border-color);
    color: var(--dark-color);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.product-description h3 {
    margin-bottom: 10px;
    font-size: 18px;
    color: var(--primary-dark);
}

.product-description p {
    color: var(--dark-color);
    line-height: 1.7;
    font-size: 15px;
    white-space: pre-line;
}

.size-selection {
    margin-bottom: 25px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.size-selection h3 {
    margin-bottom: 15px;
    font-size: 18px;
    font-family: 'Nunito', sans-serif;
    color: var(--primary-dark);
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.size-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.size-button {
    padding: 12px 20px;
    border: 2px solid var(--primary-color);
    background: #FFFFFF;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    max-width: 100%;
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(217, 13, 24, 0.15);
    box-sizing: border-box;
}

.size-button.available {
    background: #FFFFFF;
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.size-button.available:hover {
    border-color: var(--primary-dark);
    background: var(--light-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(217, 13, 24, 0.25);
}

.size-button.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(217, 13, 24, 0.4);
}

.size-button.out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
    background: #F5F5F5;
    border-color: var(--gray-color);
    color: var(--gray-color);
    box-shadow: none;
}

.size-button-disabled {
    cursor: default !important;
    pointer-events: none;
}

.size-button-disabled:hover {
    border-color: var(--primary-color) !important;
    transform: none !important;
}

.size-button-disabled.available {
    opacity: 1;
    background: #FFFFFF;
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.stock-info {
    font-size: 11px;
    font-weight: normal;
    margin-top: 5px;
}

.one-size-button {
    background: #FFFFFF !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-dark) !important;
    font-weight: 700;
    min-width: 120px;
}

.size-table {
    margin-top: 15px;
}

.size-table summary {
    padding: 10px;
    background: var(--light-color);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
}

.size-table table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
}

.size-table th,
.size-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.size-table th {
    background: var(--light-color);
    font-weight: 600;
}

.color-selection {
    margin-bottom: 25px;
}

.color-selection h3 {
    margin-bottom: 15px;
    font-size: 18px;
    font-family: 'Nunito', sans-serif;
    color: var(--primary-dark);
}

.color-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-button {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.color-button.selected {
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
}

/* Кнопки действий */
.action-buttons {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.btn {
    padding: 18px;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--primary-dark);
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-success:hover {
    background: var(--primary-color);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Стили для ссылки покупки */
.btn-buy {
    text-decoration: none;
    color: white;
}

.btn-buy:hover {
    text-decoration: none;
    color: white;
}

.secondary-actions {
    display: flex;
    gap: 15px;
}

.btn-secondary {
    flex: 1;
    padding: 15px;
    border: 2px solid var(--primary-color);
    background: transparent;
    border-radius: 15px;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--light-color);
    border-color: var(--primary-dark);
    color: var(--primary-dark);
}

/* Похожие товары */
.similar-products {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.similar-products h2 {
    margin-bottom: 20px;
    font-size: 24px;
    font-family: 'Nunito', sans-serif;
    color: var(--primary-dark);
}

.similar-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.similar-product-card {
    text-decoration: none;
    color: inherit;
    background: var(--tg-theme-bg-color);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s;
}

.similar-product-card:hover {
    transform: translateY(-3px);
}

.similar-product-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #FFFFFF;
}

.similar-product-info {
    padding: 15px;
}

.similar-product-info h4 {
    font-size: 14px;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.similar-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Nunito', sans-serif;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--tg-theme-bg-color);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-color);
}

.modal-body {
    padding: 20px;
}

.try-on-placeholder {
    text-align: center;
    padding: 40px 20px;
    background: var(--light-color);
    border-radius: 15px;
    margin-bottom: 20px;
}

.try-on-placeholder i {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.try-on-steps {
    background: var(--light-color);
    padding: 20px;
    border-radius: 15px;
}

.try-on-steps h4 {
    margin-bottom: 15px;
    font-size: 18px;
}

.try-on-steps ol {
    padding-left: 20px;
}

.try-on-steps li {
    margin-bottom: 10px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
}

/* Адаптивность */
@media (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .product-title {
        font-size: 20px;
    }

    .current-price {
        font-size: 28px;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .secondary-actions {
        flex-direction: column;
    }
    
    /* Оптимизация изображений для мобильных */
    .main-image img {
        max-height: 60vh;
        object-fit: contain;
    }
    
    .thumbnail {
        width: 65px;
        height: 65px;
        min-width: 65px;
        min-height: 65px;
    }
    
    .similar-product-card img {
        height: 160px;
    }
    
    .product-gallery {
        position: relative;
    }
    
    .main-image-container {
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .categories-scroll {
        padding: 10px 0;
    }

    .category-tab {
        padding: 10px 15px;
        min-width: 70px;
    }
    
    /* Дополнительная оптимизация для маленьких экранов */
    .main-image img {
        max-height: 55vh;
    }
    
    .thumbnail {
        width: 60px;
        height: 60px;
        min-width: 60px;
        min-height: 60px;
    }
    
    .similar-product-card img {
        height: 140px;
    }
    
    .product-detail {
        gap: 20px;
    }
    
    .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .gallery-nav-prev {
        left: 10px;
    }
    
    .gallery-nav-next {
        right: 10px;
    }
}
}
}