/*
 * Общий CSS для клиентской части и админки.
 * Стили сделаны максимально простыми и понятными.
 */

:root {
    --bg: #f5f1ec;
    --text: #2a221d;
    --muted: #776a61;
    --primary: #6a3f24;
    --primary-dark: #4e2d1a;
    --primary-soft: #efe3d9;
    --accent: #b07a49;
    --danger: #b3261e;
    --white: #ffffff;
    --border: #d8cec4;
    --panel-border: #e8ddd2;
    --shadow-soft: 0 8px 24px rgba(58, 34, 18, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
}

h1,
h2,
h3 {
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: 0.01em;
    color: var(--primary-dark);
}

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

.site-header,
.admin-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    box-shadow: var(--shadow-soft);
    position: relative;
}

.site-header::before,
.admin-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-dark), var(--accent));
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    min-height: 72px;
    padding: 12px 0;
}

.logo {
    color: var(--primary);
    text-decoration: none;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
    font-size: 20px;
    line-height: 1.2;
}

.main-nav,
.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 12px;
}

.admin-header-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 0 12px;
}

.admin-header h1 {
    margin: 0;
    font-size: 38px;
    line-height: 1.1;
}

.admin-nav {
    padding: 0;
    margin: 0;
    align-items: center;
}

.main-nav a,
.admin-nav a {
    text-decoration: none;
    color: var(--text);
    background: #f1ece7;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid #e7ddd4;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.main-nav a:hover,
.admin-nav a:hover {
    background: #e8dbce;
    color: var(--primary-dark);
}

.admin-nav a.active {
    background: linear-gradient(180deg, #7b4b2d 0%, #5f3a20 100%);
    color: #fff;
    border-color: #5f3a20;
    box-shadow: 0 6px 14px rgba(87, 52, 28, 0.22);
}

.hero {
    background: linear-gradient(140deg, #ffffff 0%, #fbf7f2 100%);
    padding: 28px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -70px;
    top: -80px;
    border-radius: 50%;
    background: radial-gradient(circle at center, #ead5c2 0%, rgba(234, 213, 194, 0) 70%);
    pointer-events: none;
}

.hero h1 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.hero p {
    margin: 0;
    color: #6f5f53;
}

.hero-home {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.hero-home-text {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hero-home-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-home-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.stat-card {
    background: #fffdfa;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.stat-value {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
}

.stat-label {
    color: #6f5f53;
    font-size: 14px;
}

.category-hero {
    margin-bottom: 18px;
}

.category-hero h1 {
    margin: 8px 0 8px;
}

.category-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.back-link {
    font-weight: 600;
    text-decoration: none;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: #eadbce;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
}

.product-hero {
    margin-bottom: 16px;
}

.product-hero h1 {
    margin: 8px 0 8px;
}

.cart-hero {
    margin-bottom: 16px;
}

.cart-hero h1 {
    margin: 8px 0 8px;
}

.success-hero {
    margin-bottom: 16px;
}

.success-card {
    padding: 24px;
}

.success-order-number {
    margin: 0 0 8px;
    font-size: 20px;
}

.success-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.layout-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
}

.sidebar {
    background: var(--white);
    border-radius: 12px;
    padding: 18px;
    height: fit-content;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
}

.sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar li {
    margin-bottom: 8px;
}

.sidebar a {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    display: inline-block;
    padding: 4px 0;
}

.sidebar a:hover {
    color: var(--primary-dark);
}

.home-categories h2 {
    margin-top: 0;
}

.category-list li {
    margin-bottom: 10px;
}

.category-link {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px !important;
    border-radius: 8px;
    background: #fcf8f4;
    border: 1px solid var(--panel-border);
    font-weight: 600;
}

.category-link:hover {
    background: #f5e8db;
}

.category-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: #eadbce;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
}

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

.home-products-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.home-products-head h2 {
    margin: 0;
}

.card {
    background: var(--white);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(58, 34, 18, 0.12);
}

.card h3 {
    margin-bottom: 6px;
}

.product-card-home {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.product-card-home .btn {
    margin-top: auto;
}

.price-line {
    margin: 8px 0 10px;
}

.empty-state-card {
    text-align: center;
    padding: 24px;
}

.product-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    background: #f1f1f1;
}

.product-page {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    background: var(--white);
    padding: 22px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
}

.product-page-enhanced {
    align-items: start;
}

.product-media-card,
.product-info-card {
    background: #fffdfa;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 12px;
}

.product-info-card h1 {
    margin: 2px 0 0;
}

.product-page h1 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 34px;
}

.product-image-lg {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eadfce;
    box-shadow: 0 8px 26px rgba(52, 31, 16, 0.14);
}

.muted {
    color: var(--muted);
}

.price {
    font-size: 30px;
    font-weight: bold;
    color: var(--primary);
    margin: 10px 0 14px;
}

.btn {
    background: linear-gradient(180deg, #77492b 0%, #5f3a20 100%);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.btn:hover {
    opacity: 0.96;
}

.btn:active {
    transform: translateY(1px);
}

.btn-light {
    background: linear-gradient(180deg, #7a7a7a 0%, #676767 100%);
}

.btn-danger {
    background: linear-gradient(180deg, #c74239 0%, #ab2a22 100%);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
}

.table th,
.table td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 12px 10px;
    vertical-align: top;
    font-size: 14px;
    word-break: break-word;
}

.table td .btn {
    padding: 7px 12px;
    font-size: 13px;
}

.admin-thumb {
    width: 80px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f8f4f0;
}

.actions-cell {
    min-width: 180px;
}

.table th {
    background: #f8f3ee;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #474747;
}

.table tr:nth-child(even) td {
    background: #fdfbf9;
}

.panel {
    background: var(--white);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
}

.panel h3 {
    margin: 0;
    font-size: 24px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.panel-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0;
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.admin-modal-header h3 {
    margin: 0;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
}

.admin-products-form {
    grid-template-columns: repeat(4, minmax(200px, 1fr));
    align-items: start;
    gap: 16px;
}

.admin-products-form label:nth-of-type(7) {
    grid-column: span 2;
}

.admin-products-form label:nth-of-type(12) {
    grid-column: span 2;
}

.admin-products-form .btn,
.admin-products-form > a.btn {
    width: 100%;
}

.admin-products-form > .btn {
    grid-column: span 2;
    min-height: 42px;
    align-self: end;
}

.admin-products-form label {
    margin: 0;
}

.admin-products-form input,
.admin-products-form select {
    min-height: 42px;
}

.admin-products-form textarea {
    min-height: 82px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

input,
select,
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fffdfa;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236a3f24' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
    padding-right: 34px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #e7c8ab;
    outline-offset: 0;
    border-color: #c7986f;
}

textarea {
    min-height: 86px;
    resize: vertical;
}

.admin-form-grid > .btn,
.admin-form-grid > a.btn {
    align-self: end;
    min-height: 40px;
    text-align: center;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.inline-form form {
    margin: 0;
}

.order-actions-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.order-actions-form select {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
}

.order-actions-form .btn {
    white-space: nowrap;
}

.orders-table td {
    vertical-align: middle;
}

.products-table td,
.categories-table td {
    vertical-align: middle;
}

.cart-card {
    padding: 0;
    overflow: hidden;
}

.cart-table td {
    vertical-align: middle;
}

.cart-product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--panel-border);
    background: #fcf8f4;
}

.cart-summary .price {
    margin: 0;
}

.specs {
    padding-left: 18px;
    margin-top: 16px;
}

.rating-card,
.specs-card {
    background: #fcf8f4;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 12px;
}

.specs-card {
    padding-left: 28px;
}

.product-buy-form {
    align-items: end;
    gap: 12px;
    margin-top: 6px;
}

.product-buy-form input[type="number"] {
    width: 120px;
}

.rating-block p {
    margin: 8px 0;
    font-weight: 600;
    color: #4f4036;
}

.star {
    display: inline-block;
    font-size: 20px;
    line-height: 1;
    color: #d0c6bd;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.08);
}

.star + .star {
    margin-left: 1px;
}

.star.full {
    color: #e3a93b;
}

.star.half {
    background: linear-gradient(90deg, #e3a93b 50%, #d0c6bd 50%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.site-footer {
    margin-top: 30px;
    border-top: 1px solid var(--border);
    background: var(--white);
    padding: 14px 0;
    box-shadow: var(--shadow-soft);
}

.site-footer p {
    margin: 8px 0;
    color: #6e5d51;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 540px;
    border-radius: 12px;
    padding: 16px;
}

.modal-content.large {
    max-width: 980px;
    max-height: calc(100vh - 40px);
    overflow: auto;
}

.payment-modal-content {
    max-width: 680px;
    padding: 18px;
}

.payment-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.payment-section {
    background: #fcf8f4;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 12px;
}

.payment-section h3 {
    margin: 0 0 10px;
    font-size: 20px;
}

.payment-card-grid {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 10px;
}

.payment-actions {
    margin-top: 0;
    justify-content: flex-start;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.order-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 10px 16px;
    margin-bottom: 14px;
}

.order-details-grid > div {
    background: #fcf8f4;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 10px;
}

.success-box,
.success {
    background: #eef8e9;
    border: 1px solid #b8d5aa;
    padding: 14px;
    border-radius: 10px;
}

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

    .product-page {
        grid-template-columns: 1fr;
    }

    .hero-home {
        grid-template-columns: 1fr;
    }

    .category-hero-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .home-products-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .table {
        display: block;
        overflow-x: auto;
    }

    .admin-form-grid > .btn,
    .admin-form-grid > a.btn {
        width: 100%;
    }

    .admin-header h1 {
        font-size: 32px;
    }

    .panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-actions {
        width: 100%;
    }

    .panel-actions .btn {
        width: 100%;
    }

    .admin-products-form {
        grid-template-columns: 1fr;
    }

    .admin-products-form label:nth-of-type(7) {
        grid-column: auto;
    }

    .admin-products-form label:nth-of-type(12) {
        grid-column: auto;
    }

    .admin-products-form > .btn {
        grid-column: auto;
    }

    .product-page h1 {
        font-size: 28px;
    }

    .price {
        font-size: 26px;
    }

    .order-details-grid {
        grid-template-columns: 1fr;
    }

    .cart-summary {
        flex-direction: column;
        align-items: stretch;
    }

    .cart-summary .btn {
        width: 100%;
    }

    .success-actions .btn {
        width: 100%;
    }

    .payment-card-grid {
        grid-template-columns: 1fr;
    }

    .payment-actions .btn {
        width: 100%;
    }
}

