/* ========== Базові стилі публічної частини ========== */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
    background: #f5f6f8;
    line-height: 1.5;
}

a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ----- Шапка ----- */
.site-header {
    background: #0f172a;
    color: #fff;
    padding: .9rem 0;
    position: sticky; top: 0; z-index: 50;
}
.site-header a { color: #fff; }
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.logo {
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none !important;
}
.main-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.main-nav a, .main-nav .btn-link {
    color: #cbd5e1;
}
.main-nav a:hover, .main-nav .btn-link:hover { color: #fff; }
.user-greeting { color: #94a3b8; font-size: .9rem; }

.btn-link {
    background: none;
    border: 0;
    color: #cbd5e1;
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.inline-form { display: inline; }

.badge {
    display: inline-block;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    padding: 0 .5rem;
    margin-left: .25rem;
    font-size: .8rem;
}

/* ----- Основний контент ----- */
.site-main { padding: 2rem 1rem; }

.flash {
    padding: .75rem 1rem;
    border-radius: .375rem;
    margin-bottom: 1rem;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.hero {
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    color: #fff;
    padding: 3rem 1.5rem;
    border-radius: .75rem;
    margin-bottom: 2rem;
}
.hero h1 { margin-top: 0; }

.block { background: #fff; border-radius: .5rem; padding: 1.25rem 1.5rem; margin-bottom: 2rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.block h2 { margin-top: 0; }

/* ----- Сітки товарів ----- */
.categories-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .75rem;
}
.categories-grid li {
    background: #f1f5f9;
    border-radius: .375rem;
    padding: .75rem 1rem;
    text-align: center;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.product-card {
    background: #fff;
    border-radius: .5rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    display: flex; flex-direction: column;
}
.product-card img {
    width: 100%; height: 160px; object-fit: cover;
    border-radius: .375rem;
    margin-bottom: .5rem;
    background: #e2e8f0;
}
.product-card h3 { margin: .25rem 0; font-size: 1rem; }
.muted { color: #64748b; font-size: .9rem; }
.price { font-size: 1.15rem; font-weight: 700; color: #0f172a; margin: .25rem 0; }
.stock { font-size: .85rem; color: #475569; margin: 0; }

/* ----- Картка товару ----- */
.product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}
.product-detail-grid img { max-width: 100%; border-radius: .5rem; }
.product-info { background: #fff; padding: 1.25rem; border-radius: .5rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.add-to-cart label { display: block; margin: .75rem 0; }

/* ----- Кнопки ----- */
.btn {
    display: inline-block;
    padding: .55rem 1rem;
    background: #e2e8f0;
    color: #0f172a;
    border: 0;
    border-radius: .375rem;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
}
.btn:hover { background: #cbd5e1; text-decoration: none; }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-secondary { background: #475569; color: #fff; }
.btn-secondary:hover { background: #334155; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ----- Форми ----- */
.filters {
    display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.filters label { display: flex; flex-direction: column; gap: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel],  input[type=url],   input[type=search], select, textarea {
    padding: .5rem .65rem;
    border: 1px solid #cbd5e1;
    border-radius: .375rem;
    font: inherit;
    background: #fff;
    color: #0f172a;
}
textarea { width: 100%; }
.checkout-form, .auth-form, .admin-form {
    background: #fff;
    padding: 1.25rem;
    border-radius: .5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    max-width: 600px;
}
.admin-form { max-width: 720px; }
.checkout-form fieldset, .auth-form fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.checkout-form label, .auth-form label, .admin-form label {
    display: block; margin: .65rem 0;
}
.checkout-form input, .auth-form input, .admin-form input,
.admin-form select, .admin-form textarea {
    width: 100%;
}

.form-actions { margin-top: 1rem; display: flex; gap: .5rem; }

/* ----- Таблиці ----- */
.cart-table, .data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border-radius: .5rem;
    overflow: hidden;
}
.cart-table th, .cart-table td,
.data-table th, .data-table td {
    padding: .65rem .75rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}
.cart-table thead, .data-table thead { background: #f1f5f9; }
.text-right { text-align: right; }
.cart-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* ----- Новини ----- */
.news-list { list-style: none; padding: 0; margin: 0; }
.news-list li { padding: .5rem 0; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.news-list-detail li { display: block; }
.news-detail { background: #fff; padding: 1.5rem; border-radius: .5rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* ----- Помилки ----- */
.error-page { text-align: center; padding: 3rem 1rem; }

/* ----- AJAX-результати ----- */
.ajax-results { margin-bottom: 1rem; }
.ajax-results .ajax-item {
    background: #fff;
    padding: .5rem .75rem;
    border-radius: .375rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    display: flex; justify-content: space-between; gap: 1rem;
    margin-bottom: .25rem;
}

/* ----- Підвал ----- */
.site-footer {
    background: #0f172a;
    color: #cbd5e1;
    padding: 1rem 0;
    text-align: center;
    margin-top: 2rem;
}
