:root {
    --c-bg: #f3f5fa;
    --c-ink: #1b2236;
    --c-brand: #12203f;
    --c-brand-2: #1d3566;
    --c-accent: #19b394;
    --c-accent-dark: #129079;
    --c-muted: #6b7488;
    --c-danger: #d64545;
    --radius: 12px;
}

* { box-sizing: border-box; }

body { font-family: "Segoe UI", system-ui, -apple-system, sans-serif; margin: 0; background: var(--c-bg); color: var(--c-ink); }
h1 { font-size: 1.7rem; margin: 0 0 18px; }
a { color: var(--c-brand-2); }

/* ---------- Макет магазину ---------- */
.shop-body { min-height: 100vh; display: flex; flex-direction: column; }
.shop-body main { flex: 1; width: 100%; }

.site-header {
    background: linear-gradient(90deg, var(--c-brand), var(--c-brand-2));
    box-shadow: 0 2px 10px rgba(18, 32, 63, 0.35);
    position: sticky; top: 0; z-index: 100;
}
.site-header-inner { max-width: 1100px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 28px; }
.site-logo { color: #fff; font-size: 1.15rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.site-logo:hover { color: var(--c-accent); }

.site-nav { display: flex; gap: 6px; flex: 1; }
.site-nav a { color: #cfd8ee; text-decoration: none; padding: 6px 12px; border-radius: 8px; }
.site-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.site-auth { display: flex; align-items: center; gap: 10px; }
.site-auth form { margin: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; color: #fff; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--c-accent); color: #fff; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

.site-footer { background: var(--c-brand); color: #9fb0d6; padding: 16px 24px; font-size: 0.9rem; text-align: center; }

main { padding: 28px 24px; max-width: 1100px; margin: 0 auto; }

/* ---------- Кнопки, бейджі, повідомлення ---------- */
.btn {
    display: inline-block; padding: 8px 18px; background: var(--c-accent); color: #fff;
    border: 1px solid var(--c-accent); text-decoration: none; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600;
}
.btn:hover { background: var(--c-accent-dark); border-color: var(--c-accent-dark); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-outline { background: transparent; color: var(--c-brand-2); border-color: #b9c3dd; }
.btn-outline:hover { background: #e8ecf7; color: var(--c-brand); border-color: #b9c3dd; }
.site-header .btn-outline, .admin-sidebar .btn-outline { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.site-header .btn-outline:hover, .admin-sidebar .btn-outline:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); }
.btn-danger:hover { background: #b83232; border-color: #b83232; }

.link-button { background: none; border: none; color: #eee; cursor: pointer; font: inherit; padding: 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; background: #e3e8f5; color: var(--c-brand-2); font-size: 0.78rem; font-weight: 700; margin-right: 4px; }
.badge-admin { background: #ffe9c7; color: #8a5200; }

.alert { padding: 11px 16px; border-radius: 8px; margin-bottom: 18px; }
.alert-success { background: #def5ec; color: #14694f; }
.alert-error { background: #fbe3e3; color: #962b2b; }

.text-danger { color: var(--c-danger); }
.muted { color: #8b93a7; }
.error { color: var(--c-danger); }

/* ---------- Каталог ---------- */
.filter-form { display: flex; gap: 12px; margin-bottom: 20px; }
.filter-form select { padding: 8px 12px; border: 1px solid #cfd6e6; border-radius: 8px; background: #fff; }

.product-grid { display: flex; flex-wrap: wrap; gap: 20px; }
.product-card { width: 230px; background: #fff; border-radius: var(--radius); padding: 12px; box-shadow: 0 2px 8px rgba(18, 32, 63, 0.08); transition: transform 0.15s, box-shadow 0.15s; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(18, 32, 63, 0.16); }
.product-photo { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; background: #eee; }
.product-card h3 { margin: 10px 0 4px; font-size: 16px; }
.product-card h3 a { color: var(--c-ink); text-decoration: none; }
.product-brand { color: #777; font-size: 13px; margin: 2px 0; }
.product-price { color: var(--c-accent-dark); font-weight: 700; }

.product-details { display: flex; gap: 32px; background: #fff; padding: 24px; border-radius: var(--radius); }
.product-gallery { display: flex; flex-direction: column; gap: 8px; width: 300px; }
.main-photo { width: 100%; border-radius: 8px; }
.thumb-photo { width: 100%; border-radius: 6px; opacity: 0.8; }
.product-info { flex: 1; }

.category-columns { display: flex; gap: 40px; }
.category-columns ul { list-style: none; padding: 0; }
.category-columns li { padding: 6px 0; }
.category-columns a { color: var(--c-ink); text-decoration: none; cursor: pointer; }
.category-columns a:hover { color: var(--c-accent-dark); }
#add-category-form { display: flex; gap: 10px; margin-top: 10px; }
#add-category-form input, #add-category-form select { padding: 8px 12px; border: 1px solid #cfd6e6; border-radius: 8px; }

/* ---------- Форми ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; }
.form-group input[type=text], .form-group input[type=email], .form-group input[type=password], .form-group input:not([type]) {
    width: 100%; padding: 9px 12px; border: 1px solid #cfd6e6; border-radius: 8px; font: inherit;
}
.form-group input:focus { outline: 2px solid rgba(25, 179, 148, 0.4); border-color: var(--c-accent); }
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.auth-form { max-width: 400px; margin: 10px auto; background: #fff; padding: 26px; border-radius: var(--radius); box-shadow: 0 4px 18px rgba(18, 32, 63, 0.12); }
.auth-form p { margin: 14px 0 0; }
.auth-footer { color: var(--c-muted); }
.auth-divider { display: flex; align-items: center; color: var(--c-muted); margin: 18px 0; font-size: 0.85rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #dfe3ee; }
.auth-divider span { padding: 0 10px; }
.provider-form { margin: 0 0 8px; }
.btn-provider { display: block; width: 100%; padding: 9px; border: 1px solid #d5daea; border-radius: 8px; background: #fff; color: var(--c-ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn-provider:hover { background: #f3f5fa; }
.btn-google { border-left: 4px solid #ea4335; }
.btn-github { background: #24292f; color: #fff; border-color: #24292f; }
.btn-github:hover { background: #161a1d; }

h1 + .auth-form, main > h1 { text-align: left; }

/* ---------- Адмін-панель ---------- */
.admin-body { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 240px; background: var(--c-brand); color: #fff; padding: 20px 16px;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.admin-brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; margin-bottom: 24px; }
.admin-menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.admin-menu a { color: #cfd8ee; text-decoration: none; padding: 9px 12px; border-radius: 8px; }
.admin-menu a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.admin-user { border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 14px; }
.admin-user-label { font-size: 0.8rem; color: #9fb0d6; }
.admin-user-name { font-weight: 600; margin-bottom: 10px; word-break: break-word; }
.admin-content { flex: 1; padding: 28px 36px; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-head h1 { margin: 0; }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 8px rgba(18, 32, 63, 0.08); }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid #eef0f6; }
.data-table th { background: #eaeef8; color: var(--c-brand-2); font-size: 0.9rem; }
.data-table .actions { text-align: right; white-space: nowrap; }

.form-card { max-width: 480px; background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: 0 2px 8px rgba(18, 32, 63, 0.08); }

/* ---------- Додатково: товари/категорії в адмін-панелі, профіль ---------- */
.user-link { color: #fff; text-decoration: none; }
.user-link:hover { color: var(--c-accent); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #eee; }
.thumb-lg { width: 140px; border-radius: 8px; background: #eee; display: block; margin-bottom: 8px; }
.form-group select, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid #cfd6e6; border-radius: 8px; font: inherit; background: #fff; }
.indent { padding-left: 24px; color: var(--c-muted); }

/* ---------- Макет _AuthLayout (вхід, реєстрація) ---------- */
.auth-body {
    min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--c-brand), var(--c-brand-2));
}
.auth-wrap { width: 100%; max-width: 460px; padding: 24px; }
.auth-logo { display: block; text-align: center; color: #fff; font-size: 1.6rem; font-weight: 700; text-decoration: none; margin-bottom: 18px; }
.auth-wrap > h1 { color: #fff; text-align: center; }
.auth-wrap .auth-form { margin: 0 auto; }
.auth-form h1 { color: var(--c-ink); text-align: center; }
.auth-back { display: block; text-align: center; color: #9fb0d6; margin-top: 18px; text-decoration: none; }
.auth-back:hover { color: #fff; }

/* ---------- Деталі (товар, бренд, категорія) ---------- */
.detail-card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: 0 2px 8px rgba(18, 32, 63, 0.08); margin-bottom: 24px; }
.detail-with-gallery { display: flex; gap: 32px; align-items: flex-start; }
.detail-list { display: grid; grid-template-columns: 190px 1fr; gap: 10px 16px; margin: 0; flex: 1; }
.detail-list dt { color: var(--c-muted); font-weight: 600; }
.detail-list dd { margin: 0; }
.gallery { width: 280px; display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.gallery-main { width: 100%; border-radius: 10px; background: #eee; }
.gallery-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; background: #eee; }
.gallery-empty { width: 100%; padding: 60px 0; text-align: center; color: var(--c-muted); background: #f0f2f8; border-radius: 10px; }
.plain-list { padding-left: 20px; }

/* ---------- Каталог на AJAX ---------- */
.catalog-layout { display: flex; gap: 28px; align-items: flex-start; }
.catalog-sidebar { width: 230px; flex-shrink: 0; background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 2px 8px rgba(18, 32, 63, 0.08); }
.catalog-sidebar h3 { margin: 0 0 10px; }
.cat-list, .cat-sublist { list-style: none; margin: 0; padding: 0; }
.cat-sublist { padding-left: 16px; }
.cat-list li { margin: 2px 0; }
.cat-link { display: block; padding: 6px 10px; border-radius: 8px; color: var(--c-ink); text-decoration: none; }
.cat-link:hover { background: #eef1f9; }
.cat-link.active { background: var(--c-accent); color: #fff; font-weight: 600; }

.catalog-content { flex: 1; min-width: 0; }
.brand-bar { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.brand-bar-title { font-weight: 600; padding-top: 7px; }
#brand-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.brand-chip { border: 1px solid #cfd6e6; background: #fff; color: var(--c-ink); padding: 6px 14px; border-radius: 20px; cursor: pointer; font: inherit; }
.brand-chip:hover { background: #eef1f9; }
.brand-chip.active { background: var(--c-brand-2); border-color: var(--c-brand-2); color: #fff; }
.chip-count { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 10px; background: rgba(0, 0, 0, 0.1); font-size: 0.8rem; }

.ajax-target { transition: opacity 0.15s; }
.ajax-target.loading { opacity: 0.45; pointer-events: none; }
.product-photo-empty { display: flex; align-items: center; justify-content: center; color: var(--c-muted); font-size: 0.9rem; }
.stock-ok { color: #14694f; font-size: 0.85rem; margin: 4px 0 0; }
.stock-out { color: var(--c-danger); font-size: 0.85rem; margin: 4px 0 0; }

/* ---------- Керування фото (AJAX) ---------- */
.upload-card { max-width: none; margin-bottom: 20px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.photo-card { width: 200px; background: #fff; border-radius: var(--radius); padding: 10px; box-shadow: 0 2px 8px rgba(18, 32, 63, 0.08); border: 2px solid transparent; }
.photo-card.photo-main { border-color: var(--c-accent); }
.photo-card img { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; background: #eee; }
.photo-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }

@media (max-width: 800px) {
    .catalog-layout { flex-direction: column; }
    .catalog-sidebar { width: 100%; }
}

/* ---------- Кошик ---------- */
.cart-link { color: #fff; text-decoration: none; background: rgba(255, 255, 255, 0.12); padding: 5px 12px; border-radius: 20px; white-space: nowrap; }
.cart-link:hover { background: rgba(255, 255, 255, 0.22); color: #fff; }
.cart-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--c-accent); text-align: center; font-size: 0.8rem; font-weight: 700; }
.add-to-cart-form { margin: 8px 0; display: inline-block; }
.cart-table { background: #fff; }
.list-group-item.active { background: var(--c-accent); border-color: var(--c-accent); }

/* Стани кнопок: перекривають Bootstrap на сторінці кошика */
.btn:hover, .btn:focus, .btn:active, .btn:first-child:active { color: #fff; background: var(--c-accent-dark); border-color: var(--c-accent-dark); }
.btn-danger:hover, .btn-danger:focus, .btn-danger:active, .btn-danger:first-child:active { color: #fff; background: #b83232; border-color: #b83232; }
.btn-outline:hover, .btn-outline:focus, .btn-outline:active, .btn-outline:first-child:active { color: var(--c-brand); background: #e8ecf7; border-color: #b9c3dd; }
.site-header .btn-outline:hover, .site-header .btn-outline:active { color: #fff; background: rgba(255, 255, 255, 0.15); }

/* ---------- Кошик: кнопки кількості та повідомлення ---------- */
.cart-table .btn-outline-secondary { background: transparent; color: #6c757d; border-color: #6c757d; min-width: 32px; padding: 2px 8px; }
.cart-table .btn-outline-secondary:hover, .cart-table .btn-outline-secondary:active, .cart-table .btn-outline-secondary:focus { background: #6c757d; color: #fff; border-color: #6c757d; }
.cart-table .qty { min-width: 24px; display: inline-block; }
.cart-flash { margin-left: 8px; font-size: 0.85rem; color: #14694f; }
.cart-flash.error { color: var(--c-danger); }
#cart-content.loading { opacity: 0.5; pointer-events: none; }
