/* Общие стили */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #fff8f0;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.section {
    position: relative; /* anchor ::before border to the section box */
    padding: 60px 20px;
    width: calc(100% - 40px); /* keep side gutters even on narrow screens */
    max-width: 1200px;
    margin: 20px auto;
    background-clip: content-box;
    background-color: #f8c471;
    /*box-shadow: inset 0px 0px 0px 2px #000;*/
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));/*тень*/
}

.section::before {
    content: '';
    position: absolute;
    top: 59px; /* Регулируйте значение для ширины рамки */
    left: 20px; /* Регулируйте значение для ширины рамки */
    right: 20px; /* Регулируйте значение для ширины рамки */
    bottom: 59px; /* Регулируйте значение для ширины рамки */
    border: 2px solid #000; /* Собственно, сама рамка */
    z-index: -1; /* Помещаем рамку за содержимым */
}

h1, h2 {
    text-align: center;
    color: #d2691e;
}

p {
    text-align: center;
    font-size: 1.1em;
    line-height: 1.6;
}

ul {
    list-style: none;
    padding: 0;
    text-align: center;
}

ul li {
    margin: 10px 0;
}

/* Навигационная панель */
.navbar, .footer-nav {
    background-color: #f8c471;
    padding: 15px 0;
    position: relative;
}

.navbar::before, .footer-nav::before { /*рамка для навигационной панели*/
    content: '';
    position: absolute;
    top: -2px; /* Регулируйте значение для ширины рамки */
    left: -2px; /* Регулируйте значение для ширины рамки */
    right: -2px; /* Регулируйте значение для ширины рамки */
    bottom: -2px; /* Регулируйте значение для ширины рамки */
    border: 2px solid #000; /* Собственно, сама рамка */
    z-index: -1; /* Помещаем рамку за содержимым */
}

.navbar ul, .footer-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.navbar li, .footer-nav li {
    margin: 0 15px;
}

.navbar a, .footer-nav a {
    text-decoration: none;
    color: #fff;
    font-weight: bold;
    transition: color 0.3s;
}

.navbar a:hover, .footer-nav a:hover {
    color: #333;
}

/* Корзина и заказы в навбаре */
.nav-actions {
    position: absolute;
    right: 20px;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.orders,
.cart {
    position: relative;
    cursor: pointer;
}

.orders img,
.cart img {
    width: 24px;
    height: 24px;
}

#cart-count {
    background-color: #e74c3c;
    color: #fff;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.8em;
    position: relative;
    top: -10px;
    left: -10px;
}

/* Каталог товаров */
.product-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.catalog-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.catalog-controls select,
.catalog-controls input[type="search"] {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 180px;
    font-size: 0.95em;
}

.catalog-controls .search-box {
    display: flex;
    gap: 10px;
}

.catalog-empty {
    text-align: center;
    font-size: 1rem;
    color: #555;
    margin-top: 10px;
}

.hidden {
    display: none !important;
}

/* Форма заказа в попапе корзины */
.checkout-form {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.checkout-form h3 {
    margin: 10px 0;
    text-align: center;
    color: #d2691e;
}

.checkout-form .form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.checkout-form input,
.checkout-form textarea,
.checkout-form select {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95em;
    min-width: 0; /* allow flex items to shrink inside modal */
}

.checkout-form textarea {
    resize: vertical;
}

.checkout-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.checkout-form .form-actions .secondary {
    background-color: #c0392b;
}

.checkout-form .form-actions .secondary:hover {
    background-color: #e74c3c;
}

@media (max-width: 768px) {
    .checkout-form .form-row {
        flex-direction: column;
    }
}

.product-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 300px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.product-item img {
    max-width: 100%;
    border-radius: 8px;
}

.product-item h3 {
    color: #d2691e;
    margin: 15px 0 10px 0;
}

.product-item p {
    font-size: 0.95em;
    color: #555;
}

.price {
    display: block;
    margin: 10px 0;
    font-size: 1.2em;
    color: #e67e22;
    font-weight: bold;
}

button {
    background-color: #d35400;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #e67e22;
}

/* Нижняя панель */
footer {
    position: relative;
    background-color: #f8c471;
    padding: 20px 0;
    margin-top: auto; /* sticky footer when page content is short */
}

footer::before {
    content: '';
    position: absolute;
    top: -2px; /* Регулируйте значение для ширины рамки */
    left: -2px; /* Регулируйте значение для ширины рамки */
    right: -2px; /* Регулируйте значение для ширины рамки */
    bottom: -2px; /* Регулируйте значение для ширины рамки */
    border: 2px solid #000; /* Собственно, сама рамка */
    z-index: -1; /* Помещаем рамку за содержимым */
}


.footer-nav ul {
    margin-bottom: 10px;
}

.footer-nav p {
    text-align: center;
    color: #fff;
    font-size: 0.9em;
}

/* Корзина (попап) */
.cart-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    width: 90%;
    max-width: 600px;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 1001;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}

.cart-popup.hidden {
    display: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.overlay.hidden {
    display: none;
}

.cart-popup h2 {
    margin-top: 0;
    text-align: center;
}

#orders-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.order-row {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.order-main {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.order-inline-actions button {
    margin-left: auto;
}

.order-id {
    font-weight: bold;
    color: #d2691e;
}

.order-meta {
    font-size: 0.9em;
    color: #555;
}

.order-status {
    font-size: 0.9em;
    color: #27ae60;
}

.order-pay-status {
    font-size: 0.9em;
    color: #555;
}

.order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.order-items {
    background: #fff8f0;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 8px;
    font-size: 0.95em;
}

.order-item-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid #f0e6d8;
}

.order-item-row span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-item-row span:last-child {
    white-space: nowrap;
}

.order-item-row:last-child {
    border-bottom: none;
}

.order-items.error {
    color: #c0392b;
    border-color: #c0392b;
}

#cart-items {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

.cart-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

.cart-item-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.cart-item-details {
    margin-left: 10px;
}

.cart-item-details h4 {
    margin: 0 0 5px 0;
    font-size: 1em;
    color: #333;
}

.cart-item-details p {
    margin: 0;
    font-size: 0.9em;
    color: #777;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-item-actions input {
    width: 50px;
    padding: 5px;
    text-align: center;
}

.remove-item {
    background-color: #c0392b;
    padding: 5px 10px;
    border: none;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.remove-item:hover {
    background-color: #e74c3c;
}

.cart-total {
    text-align: right;
    font-size: 1.2em;
}

#close-cart, #checkout {
    display: inline-block;
    margin: 10px 5px 0 5px;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

#close-cart {
    background-color: #c0392b;
    color: #fff;
}

#close-cart:hover {
    background-color: #e74c3c;
}

#checkout {
    background-color: #27ae60;
    color: #fff;
}

#checkout:hover {
    background-color: #2ecc71;
}

/* Popup уведомления */
#notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #2ecc71;
    color: #fff;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 1002;
    display: none;
}

#notification.error {
    background-color: #e74c3c;
}

/* Адаптивность */
@media (max-width: 768px) {
    .navbar ul, .footer-nav ul {
        flex-direction: column;
    }

    .navbar li, .footer-nav li {
        margin: 10px 0;
    }

    .product-grid {
        flex-direction: column;
        align-items: center;
    }

    .nav-actions {
        position: static;
        justify-content: center;
        margin-top: 10px;
    }

    .cart-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-item-actions {
        margin-top: 10px;
    }
}
