/* --- Сброс и База --- */
body {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #fcfcfc;
    color: #333;
    line-height: 1.5;
}

h1, h2, h3 {
    font-weight: 700;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Хедер --- */
header {
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(139, 69, 19, 0.1);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 3px solid #8b4513;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    height: 70px;
    transition: transform 0.3s;
    cursor: pointer;
}

.logo:hover {
    transform: scale(1.05);
}

.header-text {
    flex-grow: 1;
    margin-left: 20px;
}

.header-text h1 {
    font-family: 'Playfair Display', serif;
    margin: 0;
    color: #8b4513; /* Хлебный цвет */
    font-size: 2.2em;
}

.tagline {
    font-family: 'Caveat', cursive;
    font-size: 1.3em;
    margin: 0;
    color: #666;
}

.cart-indicator {
    background: #8b4513;
    color: #fff;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    white-space: nowrap;
}

/* --- Админ Панель --- */
.admin-controls {
    display: none; /* Скрыто по умолчанию */
    background: #fff3e0;
    border: 2px dashed #ff9800;
    padding: 20px;
    margin: 20px 0;
    border-radius: 10px;
    flex-direction: column;
    align-items: center;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 15px;
}

.big-btn {
    background: #ff9800;
    color: white;
    font-size: 1.1em;
    padding: 10px 25px;
    border-radius: 50px;
}

.logout-btn {
    background: transparent;
    border: 1px solid #d32f2f;
    color: #d32f2f;
}

/* --- Сетка Товаров --- */
#products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding: 40px 0;
}

.product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid #eee;
}

.product-card:hover {
    transform: translateY(-7px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.card-img-wrapper {
    height: 220px;
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
}

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

.admin-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    background: rgba(255,255,255,0.8);
    padding: 5px;
    border-radius: 20px;
}

.card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.category-tag {
    font-size: 0.75em;
    color: #8b4513;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.card-content h3 {
    margin: 5px 0 10px;
    font-size: 1.2em;
    line-height: 1.2;
}

.desc {
    font-size: 0.9em;
    color: #666;
    flex-grow: 1;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.price {
    font-weight: 700;
    font-size: 1.3em;
    color: #2c3e50;
}

/* --- Кнопки --- */
button {
    cursor: pointer;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: 0.2s;
    font-family: inherit;
    font-weight: 600;
}

.add-btn {
    background-color: #8b4513;
    color: white;
}

.add-btn:hover {
    background-color: #6d360f;
}

.icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.edit-icon { background: #ff9800; color: white; }
.delete-icon { background: #f44336; color: white; }

/* --- Корзина --- */
.cart-section {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 60px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
}

.cart-section h2 {
    margin-top: 0;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed #eee;
}

.cart-item-info {
    font-weight: 500;
}

.remove-btn {
    background: #ffebee;
    color: #d32f2f;
    padding: 4px 8px;
    margin-left: 10px;
    font-size: 1.1em;
}
.remove-btn:hover {
    background: #ffcdd2;
}

.total {
    font-size: 1.5em;
    font-weight: 800;
    text-align: right;
    margin: 20px 0;
    color: #2c3e50;
}

.checkout-btn {
    width: 100%;
    background: #4caf50;
    color: white;
    padding: 18px;
    font-size: 1.2em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.checkout-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.checkout-btn:hover:not(:disabled) {
    background: #43a047;
}

/* --- Футер --- */
footer {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 40px 0;
    text-align: center;
    margin-top: auto;
}
footer p {
    margin: 5px 0;
    opacity: 0.8;
}

/* --- Модальное окно --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 200; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.6); 
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto; 
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: black;
}

/* Форма в модалке */
label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9em;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    box-sizing: border-box; /* Важно для отступов */
}

textarea {
    resize: vertical;
}

.row {
    display: flex;
    gap: 15px;
}
.col {
    flex: 1;
}

#img-preview-container {
    margin: 10px 0;
    text-align: center;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
}
#img-preview {
    max-width: 100%;
    max-height: 200px;
    display: none;
    border-radius: 4px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.primary-btn {
    background: #8b4513;
    color: white;
}
.secondary-btn {
    background: #e0e0e0;
    color: #333;
}

/* Адаптив для мобильных */
@media (max-width: 600px) {
    .header-container {
        flex-direction: column;
        text-align: center;
    }
    .header-text {
        margin: 10px 0;
    }
    .header-text h1 {
        font-size: 1.8em;
    }
    .tagline {
        font-size: 1em;
    }
}