/* Основные стили проекта EskiTuski */
:root {
    --primary-color: #25D366; /* Зеленый WhatsApp */
    --bg-color: #f4f7f6;
    --text-color: #333;
    --card-bg: #fff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-bottom: 70px; /* Отступ для нижнего меню */
    padding-top: 0 !important; /* Отступ для верхней навигации и поиска */
}

/* Верхняя навигация */
.top-nav {
    position: fixed;
    top: 0;
    right: 0;
    right: 0;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.nav-brand {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links a {
    text-decoration: none;
    color: #666;
    margin-left: 15px;
    font-size: 14px;
}

.nav-links a.active {
    color: var(--primary-color);
    font-weight: bold;
}

.cart-link {
    position: relative;
}

.badge {
    position: absolute;
    top: -8px;
    right: -12px;
    background: red;
    color: #fff;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
}

/* Поиск */
.search-header {
    position: fixed;
    top: 45px;
    right: 0;
    right: 0;
    background: #fff;
    padding: 10px 15px;
    z-index: 999;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.search-bar {
    display: flex;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 5px 15px;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
}

.search-bar button {
    border: none;
    background: transparent;
    cursor: pointer;
}

/* Лента объявлений (2 в ряд) */
.main-content {
    padding: 15px;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.item-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.item-photo {
    height: 150px;
    background-size: cover;
    background-position: center;
    background-color: #ddd;
}

.item-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
}

.item-title {
    font-size: 14px;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Фиксированное нижнее меню (Категории) */
.bottom-categories {
    position: fixed;
    bottom: 0;
    right: 0;
    right: 0;
    background: #fff;
    padding: 10px 0;
    z-index: 1000;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.05);
}

.categories-scroll {
    display: flex;
    overflow-x: auto;
    padding: 0 10px;
}

.categories-scroll::-webkit-scrollbar {
    display: none; /* Скрываем скроллбар */
}

.cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    margin: 0 12px;
    min-width: 60px;
}

.cat-emoji {
    font-size: 24px;
    margin-bottom: 4px;
}

.cat-name {
    font-size: 11px;
    white-space: nowrap;
}

/* Страница входа */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}

.login-card {
    background: #fff;
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    color: var(--primary-color);
    margin-bottom: 5px;
}

.login-card p {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.form-group {
    text-align: left;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    font-size: 16px;
}

.btn-whatsapp {
    width: 100%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-whatsapp:hover {
    background: #20bd5a;
}

.login-footer {
    margin-top: 15px;
}

.login-footer a {
    color: #666;
    font-size: 12px;
    text-decoration: none;
}

/* Новые стили для сетки и сайдбара */
.items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (min-width: 768px) {
    .items-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.item-photo {
    width: 100%;
    aspect-ratio: 1 / 1 !important; /* Делаем квадратными */
    object-fit: cover;
}

.burger-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 50px;
    height: 50px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 24px;
    border: none;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 250px;
    height: 100%;
    background: #fff;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    right: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar .sidebar-nav {
    display: flex;
    flex-direction: column;
    margin-top: 50px;
}

.sidebar .sidebar-nav a {
    padding: 15px;
    text-decoration: none;
    color: #333;
    font-size: 16px;
    border-bottom: 1px solid #eee;
}

.sidebar .sidebar-nav a.active {
    color: #25D366;
    font-weight: bold;
}

/* Премиум стили для бургера и сайдбара */
.burger-btn {
    position: fixed;
    top: 20px;
    right: 20px !important;
    left: auto !important;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border: none;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.burger-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.burger-btn span {
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.burger-btn.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.burger-btn.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.burger-btn.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 280px;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    transition: all 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0);
    box-shadow: -5px 0 25px rgba(0,0,0,0.05);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    right: 0;
}

.sidebar .sidebar-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.sidebar .sidebar-header .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.sidebar .sidebar-nav a {
    padding: 14px 20px;
    text-decoration: none;
    color: #4A4A4A;
    font-size: 16px;
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.sidebar .sidebar-nav a:hover {
    background: rgba(37, 211, 102, 0.1);
    color: #128C7E;
    transform: translateX(5px);
}

.sidebar .sidebar-nav a.active {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Принудительное переопределение для правой стороны */
.burger-btn {
    left: auto !important;
    right: 20px !important;
}
.sidebar {
    left: auto !important;
    right: -320px !important;
}
.sidebar.active {
    left: auto !important;
    right: 0 !important;
}

/* Фикс наложения поиска на бургер */
.search-header {
    position: fixed !important;
    top: 15px !important;
    right: 80px !important;
    left: auto !important;
    z-index: 999 !important;
}

/* Премиум стили для круглой кнопки поиска и раскрывающейся панели */
.search-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 20px;
    border: none;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.search-btn:hover {
    transform: rotate(15deg) scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.search-header {
    position: fixed !important;
    top: 20px !important;
    left: 80px !important;
    right: auto !important;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px);
    border-radius: 25px !important;
    padding: 0 !important;
    height: 50px;
    display: flex !important;
    align-items: center;
    width: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05) !important;
    z-index: 1000 !important;
}

.search-header.active {
    width: 260px;
    opacity: 1;
    padding: 0 20px !important;
}

.search-header input {
    border: none !important;
    background: transparent !important;
    outline: none !important;
    width: 100% !important;
    font-size: 16px !important;
    color: #333 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.search-header button {
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 18px !important;
    color: #25D366 !important;
    padding: 0 !important;
    margin-left: 10px !important;
}

/* Стили для детальной страницы товара */
.item-detail-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

@media (min-width: 768px) {
    .item-detail-container {
        grid-template-columns: 1.2fr 0.8fr;
        padding: 40px 20px;
    }
}

.gallery-container {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

.main-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #eee;
}

.thumbnails {
    display: flex;
    gap: 10px;
    padding: 15px;
    overflow-x: auto;
    border-top: 1px solid #eee;
}

.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.thumbnail.active {
    border-color: #25D366;
    transform: scale(1.05);
}

.item-info-card {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: fit-content;
}

.item-title {
    font-size: 28px;
    font-weight: 700;
    color: #1A1A1A;
    margin-bottom: 10px;
}

.item-price {
    font-size: 32px;
    font-weight: 800;
    color: #25D366;
    margin-bottom: 20px;
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.item-price span {
    font-size: 16px;
    font-weight: 500;
    color: #666;
}

.item-description {
    font-size: 16px;
    color: #4A4A4A;
    line-height: 1.6;
    margin-bottom: 30px;
}

.seller-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #F7F7F7;
    border-radius: 12px;
    margin-bottom: 30px;
}

.seller-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-buy-wa {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
}

.btn-buy-wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.btn-add-cart {
    background: #fff;
    color: #333;
    border: 2px solid #E0E0E0;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-add-cart:hover {
    border-color: #333;
    background: #F7F7F7;
}

/* Стили для кастомного модального окна */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.custom-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-modal.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.modal-message {
    font-size: 16px;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.btn-modal-close {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.2);
    transition: all 0.3s ease;
}

.btn-modal-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.3);
}

/* Стили для премиум лоадера бесконечности */
.loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.loader-wrapper.active {
    opacity: 1;
    visibility: visible;
}

.infinity-container {
    position: relative;
    width: 200px;
    height: 100px;
}

.infinity-bg-path {
    fill: none;
    stroke: rgba(37, 211, 102, 0.1);
    stroke-width: 4;
    stroke-linecap: round;
}

/* Точки, бегущие по траектории */
.loader-dot {
    width: 14px;
    height: 14px;
    background: #25D366;
    border-radius: 50%;
    position: absolute;
    /* Траектория бесконечности */
    offset-path: path('M 20 50 C 20 10, 80 10, 100 50 C 120 90, 180 90, 180 50 C 180 10, 120 10, 100 50 C 80 90, 20 90, 20 50 Z');
    animation: follow-path 2s infinite linear;
    box-shadow: 0 0 15px #25D366, 0 0 5px #128C7E;
}

/* Создаем эффект шлейфа за счет задержки и уменьшения размера/прозрачности */
.loader-dot:nth-child(2) { animation-delay: -0.05s; opacity: 0.9; width: 12px; height: 12px; }
.loader-dot:nth-child(3) { animation-delay: -0.10s; opacity: 0.7; width: 10px; height: 10px; }
.loader-dot:nth-child(4) { animation-delay: -0.15s; opacity: 0.5; width: 8px; height: 8px; }
.loader-dot:nth-child(5) { animation-delay: -0.20s; opacity: 0.3; width: 6px; height: 6px; }
.loader-dot:nth-child(6) { animation-delay: -0.25s; opacity: 0.1; width: 4px; height: 4px; }

@keyframes follow-path {
    0% { offset-distance: 0%; }
    100% { offset-distance: 100%; }
}

/* Стили для простого лоадера */
.simple-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loader-pulse-dot {
    width: 20px;
    height: 20px;
    background: #25D366;
    border-radius: 50%;
    animation: pulse 1s infinite ease-in-out;
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.3);
}

.loader-text {
    font-size: 16px;
    color: #333;
    font-weight: 500;
    font-family: inherit;
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.6; }
}

/* Фикс для прижатия хедера к верху */
body {
    padding-top: 0 !important;
    margin-top: 0 !important;
}
.top-header-row {
    padding-top: 10px !important; /* Уменьшаем внутренний отступ сверху */
    margin-top: 0 !important;
}
