:root {
    --bg-dark: #121212;
    --bg-darker: #0a0a0a;
    --bg-card: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-color: #6200ea;
    --accent-hover: #7c4dff;
    --danger-color: #d32f2f;
    --danger-hover: #f44336;
    --success-color: #388e3c;
    --border-color: #333333;


    /* Новые цвета для светлых элементов */
    --light-bg: #f5f5f5;
    --light-text: #000000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

.admin-container, .main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.main-header {
    text-align: center;
    padding: 2rem 0;
}

.main-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.main-header p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.admin-header h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

nav {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

nav a {
    color: var(--accent-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: rgba(98, 0, 234, 0.1);
}

/* Формы и кнопки */
.form-group {
    margin-bottom: 1rem;
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
    margin-top: 0.5rem;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(98, 0, 234, 0.2);
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    margin-right: 0.5rem;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-edit {
    background-color: #f39c12;
    color: white;
}

.btn-edit:hover {
    background-color: #e67e22;
}

.btn-cart {
    background-color: var(--success-color);
    color: white;
    width: 100%;
    margin-top: 1rem;
}

/* Таблицы */
.table-container {
    overflow-x: auto;
    margin: 1rem 0;
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-darker);
    font-weight: 600;
}

tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Карточки товаров */
.product-grid {
    margin: 2rem 0;
}

.product-grid h2 {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.product-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
}

.product-image {
    height: auto;
    background-color: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    margin: 20px 0;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.no-image {
    color: var(--text-secondary);
}

.product-info {
    padding: 1.5rem;
}

.product-info h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.product-price {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-color);
    margin: 0.5rem 0;
}

.product-stock {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Сообщения */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    color: white;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    background-color: var(--success-color);
}

.toast.error {
    background-color: var(--danger-color);
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.loading, .empty, .error {
    text-align: center;
    padding: 2rem;
    grid-column: 1 / -1;
    color: var(--text-secondary);
}

.error {
    color: var(--danger-color);
}

/* Адаптивность */
@media (max-width: 768px) {
    .products-container {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .admin-container, .main-container {
        padding: 1rem;
    }
}

/* Категории */
#categories-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.category {
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.category:hover {
    background: var(--bg-darker);
}

.category.active {
    background-color: var(--accent-color);
    color: white;
}

/* Детали товара */
.product-detail {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 8px;
}

.product-detail img {
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
}

/* Вкладки админки */
.admin-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    background-color: var(--bg-card);
    color: var(--text-primary);
    margin-right: 0.5rem;
    border-radius: 6px 6px 0 0;
    transition: all 0.3s;
}

.admin-tab.active {
    background-color: var(--accent-color);
    color: white;
}

.tab-content {
    display: none;
    padding: 1.5rem;
    background-color: var(--bg-card);
    border-radius: 0 8px 8px 8px;
}

.tab-content.active {
    display: block;
}

/* Формы в админке */
.add-product-form, .add-category-form {
    background-color: var(--bg-darker);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.add-product-form h2, .add-category-form h2 {
    margin-bottom: 1.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Product Page Styles */
.product-container {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.product-image-container {
    flex: 1;
    min-width: 300px;
    background: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.product-image-container img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

#product-details {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.product-details .price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 1rem 0;
}

.product-details .stock {
    color: #27ae60;
    margin-bottom: 1.5rem;
}

.product-details .description {
    line-height: 1.6;
    margin-bottom: 2rem;
}

.no-image {
    color: #7f8c8d;
    font-style: italic;
}

@media (max-width: 768px) {
    .product-container {
        flex-direction: column;
    }
}

.product {
    cursor: pointer;
}

/* Стили для страницы деталей товара */
.product-detail-container {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.product-detail {
    display: flex;
    gap: 40px;
    margin-top: 20px;
}

.product-detail .product-image {
    flex: 1;
    max-width: 500px;
}

.product-detail .product-image img {
    width: 100%;
    border-radius: 8px;
}

.product-detail .product-info {
    flex: 1;
}

.product-detail .product-description {
    margin: 20px 0;
    padding: 20px;
    background: var(--light-bg);
    border-radius: 8px;
    color: var(--light-text);
}

.product-detail .product-description h3 {
    color: var(--light-text);
    margin-bottom: 10px;
}
.product-detail .product-description p {
    color: var(--light-text);
    line-height: 1.6;
}

.btn-back {
    display: inline-block;
    padding: 8px 16px;
    background: var(--success-color); /* Используем зеленый цвет из переменных */
    color: white !important; /* Белый текст для контраста */
    text-decoration: none;
    border-radius: 4px;
    margin-bottom: 20px;
    transition: background-color 0.3s;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-back:hover {
    background: #2e7d32; /* Темно-зеленый при наведении */
}

@media (max-width: 768px) {
    .product-detail {
        flex-direction: column;
    }

    .product-detail .product-image {
        max-width: 100%;
    }
}
.cart-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}
.cart-icon img {
    width: 100px; /* Уменьшаем размер иконки */
    height: 100px;
    transition: transform 0.3s;
}

.cart-icon img:hover {
    transform: scale(1.1);
}

.cart-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none; /* По умолчанию скрыт */
}

/* Стили корзины */
.cart-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}


.cart-item-image {
    width: 60px; /* Фиксированный размер */
    height: 60px;
    margin-right: 15px;
    object-fit: contain; /* Сохраняет пропорции изображения */
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-title {
    font-size: 16px;
    margin-bottom: 5px;
}

.cart-item-price {
    font-weight: bold;
    color: #333;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    margin-top: 10px;
}
.quantity-controls {
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.quantity-btn {
    width: 25px;
    height: 25px;
    background: #f0f0f0;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
}

.quantity-input {
    width: 40px;
    text-align: center;
    margin: 0 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 2px;
}


.remove-item {
    color: #ff4757;
    cursor: pointer;
    margin-left: 15px;
    font-size: 14px;
}

.cart-summary {
    margin-top: 30px;
    text-align: right;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 5px;
}

/* Стиль для блока итого (не трогаем id, работаем через класс) */
.cart-summary h3 {
    color: #000000; /* Чёрный цвет */
    font-size: 1.2em;
    margin-bottom: 15px;
}

/* Дополнительно можно стилизовать сумму */
.cart-summary #cartTotal {
    font-weight: bold;
    color: #000000; /* Также чёрный для суммы */
}


.btn-checkout {
    background: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
}

.empty-cart {
    text-align: center;
    padding: 50px;
    font-size: 18px;
}
.cart-item-image img {
    max-width: 60px;
    max-height: 60px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.cart-item-image .no-image {
    width: 60px;
    height: 60px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.cart-summary .total-price {
    background: #f5f5f5;
}
/* Медиа-запросы для мобильных */
@media (max-width: 768px) {
    .product-card {
        width: 100%;
        margin: 10px 0;
    }

    .cart-item {
        flex-direction: column;
    }

    /* Другие адаптивные стили */
}