/* ============================================
   Katalog Frontend - Vanilla CSS
   Renkler admin/settings.php'den JS ile --f-* değişkenlerine enjekte edilir.
   ============================================ */

:root {
    --f-primary: #1a73e8;
    --f-accent: #e4141c;
    --f-category-bg: #f1f5f9;
    --f-button: #1a73e8;
    --f-button-text: #ffffff;
    --f-bg: #f8fafc;
    --f-surface: #ffffff;
    --f-border: #e2e8f0;
    --f-text: #1e293b;
    --f-text-muted: #64748b;
    --f-radius: 12px;
    --f-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--f-bg);
    color: var(--f-text);
    font-size: 15px;
    line-height: 1.5;
}

.empty-state { color: var(--f-text-muted); padding: 30px; text-align: center; }

/* ---------- Layout ---------- */
.f-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 22px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 18px;
}

.f-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
}

.f-sidebar-title {
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--f-text-muted);
    margin-bottom: 10px;
    padding: 0 4px;
}

.f-category-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cat-btn {
    text-align: left;
    border: none;
    background: transparent;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--f-text);
    cursor: pointer;
    transition: background .15s, color .15s;
    font-family: inherit;
}
.cat-btn:hover { background: var(--f-category-bg); }
.cat-btn.active {
    background: var(--f-category-bg);
    color: var(--f-primary);
    font-weight: 700;
}

/* Kategori sidebar'ında 3 seviyeyi renk tonuyla ayırt ettiren "merdiven": "Tümü" marka
   kırmızısı (en üstte/en dikkat çekici) → Ana Kategori koyu marka rengi dolu zemin →
   Alt Kategori açık/tint zemin → En Alt Kategori düz zemin + soluk yazı (en hafif). */
.cat-btn[data-cat="all"] {
    background: var(--f-accent);
    color: #fff;
    font-weight: 700;
}
.cat-btn[data-cat="all"]:hover,
.cat-btn[data-cat="all"].active {
    background: color-mix(in srgb, var(--f-accent) 82%, black);
    color: #fff;
}

/* Ana Kategori (depth 0) — koyu marka rengi dolu zemin. */
.f-category-list > .cat-btn[data-depth="0"] {
    background: var(--f-primary);
    color: #fff;
    font-weight: 700;
}
.f-category-list > .cat-btn[data-depth="0"]:hover,
.f-category-list > .cat-btn[data-depth="0"].active {
    background: color-mix(in srgb, var(--f-primary) 82%, black);
    color: #fff;
}

.cat-subgroup {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 2px 0 6px 10px;
    padding-left: 8px;
    border-left: 2px solid var(--f-category-bg);
}
.cat-btn-sub {
    font-size: 13px;
    font-weight: 400;
    padding: 7px 12px;
    border-radius: 7px;
}

/* Alt Kategori (depth 1) — marka renginin açık tonuyla dolu zemin + koyu marka rengi yazı,
   Ana'dan (dolu koyu) ve En Alt'tan (düz/şeffaf) net ayrışsın diye. */
.cat-btn-sub[data-depth="1"] {
    background: color-mix(in srgb, var(--f-primary) 14%, white);
    color: var(--f-primary);
    font-weight: 700;
    font-size: 13.5px;
}
.cat-btn-sub[data-depth="1"]:hover,
.cat-btn-sub[data-depth="1"].active {
    background: color-mix(in srgb, var(--f-primary) 26%, white);
    color: var(--f-primary);
}

/* En Alt Kategori (depth 2) — düz/şeffaf zemin, soluk gri yazı: en hafif/en az vurgulu seviye. */
.cat-btn-sub[data-depth="2"] {
    background: transparent;
    color: var(--f-text-muted);
    font-weight: 500;
    font-size: 12.5px;
}
.cat-btn-sub[data-depth="2"]:hover,
.cat-btn-sub[data-depth="2"].active {
    background: var(--f-category-bg);
    color: var(--f-primary);
}

/* En Alt Kategoriler (Alt Kategori'nin çocukları) varsayılan olarak kapalı — Alt Kategori
   butonuna tıklanınca JS ile hidden kaldırılır (bkz. app.js bindEvents). */
.cat-subgroup-collapsible[hidden] { display: none; }

.f-main { flex: 1; min-width: 0; }

/* ---------- Ürün Grid ---------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}

.product-card {
    background: var(--f-surface);
    border-radius: var(--f-radius);
    box-shadow: var(--f-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .15s, box-shadow .15s;
}
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15,23,42,0.1);
}

.product-thumb {
    aspect-ratio: 4 / 3;
    background: var(--f-category-bg);
    cursor: pointer;
    overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--f-text-muted);
}

.product-info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.product-name {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    cursor: pointer;
}
.product-name:hover { color: var(--f-primary); }

.product-desc {
    font-size: 13px;
    color: var(--f-text-muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
}

.btn-detail, .btn-add {
    flex: 1;
    padding: 9px 10px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-detail {
    background: var(--f-category-bg);
    color: var(--f-text);
}
.btn-detail:hover { filter: brightness(0.96); }
.btn-add {
    background: var(--f-button);
    color: var(--f-button-text);
}
.btn-add:hover { filter: brightness(0.92); }

/* ---------- Sabit "Listem" butonu ---------- */
.cart-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: var(--f-button);
    color: var(--f-button-text);
    padding: 14px 22px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    box-shadow: 0 10px 25px rgba(15,23,42,0.25);
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform .15s;
}
.cart-fab:hover { transform: translateY(-2px); text-decoration: none; color: var(--f-button-text); }

/* ---------- Modal (ürün detay) ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 100;
}
.modal-overlay.open { display: flex; }

.product-modal {
    background: #fff;
    border-radius: var(--f-radius);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--f-category-bg);
    font-size: 15px;
    cursor: pointer;
}
.modal-close:hover { background: #e2e8f0; }

.modal-loading { padding: 40px; text-align: center; color: var(--f-text-muted); }

.modal-product-title { font-size: 19px; margin: 0 26px 14px 0; }

.modal-slider {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--f-category-bg);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}
.modal-slider img { width: 100%; height: 100%; object-fit: cover; display: block; }

.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.85);
    font-size: 18px;
    cursor: pointer;
}
.slider-prev { left: 10px; }
.slider-next { right: 10px; }
.slider-nav:hover { background: #fff; }

.slider-dots {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
}
.slider-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
    cursor: pointer;
}
.slider-dot.active { background: #fff; }

.modal-desc { font-size: 14px; color: var(--f-text-muted); margin: 0 0 16px; }

.specs-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
    font-size: 13.5px;
}
.specs-table th, .specs-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--f-border);
    text-align: left;
}
.specs-table th {
    width: 40%;
    color: var(--f-text-muted);
    font-weight: 600;
}

.variants-table-wrap { overflow-x: auto; margin-bottom: 18px; }
.variants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}
.variants-table th, .variants-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--f-border);
    text-align: left;
}
.variants-table th {
    color: var(--f-text-muted);
    font-weight: 600;
    background: var(--f-category-bg);
}
.variants-table tbody tr { cursor: pointer; }
.variants-table tr:hover td { background: var(--f-category-bg); }
.variants-table tr.selected td { background: #e3ecf9; font-weight: 600; }

.modal-options { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.modal-option { flex: 1 1 180px; display: flex; flex-direction: column; gap: 5px; }
.modal-option span { font-size: 12.5px; font-weight: 600; color: var(--f-text-muted); }
.modal-option select {
    padding: 9px 10px;
    border: 1px solid var(--f-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fafbfc;
}

.btn-add-modal {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

/* ---------- Toast ---------- */
.f-toast-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
    max-width: calc(100vw - 40px);
}
.f-toast {
    background: #1e293b;
    color: #fff;
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .2s, transform .2s;
}
.f-toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Liste (Sepet) Sayfası ---------- */
.cart-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 18px 18px 60px;
}

.cart-page-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}
.back-link {
    color: var(--f-text-muted);
    font-size: 13.5px;
    font-weight: 600;
}
.cart-page-header h1 { margin: 0; font-size: 22px; }

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}

.cart-item {
    background: var(--f-surface);
    border-radius: var(--f-radius);
    box-shadow: var(--f-shadow);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-item-img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--f-category-bg);
}
.cart-item-img.thumb-placeholder { display: flex; align-items: center; justify-content: center; font-size: 22px; }

.cart-item { align-items: flex-start; }
.cart-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cart-item-name { font-size: 14px; font-weight: 600; }

.cart-item-options { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cart-item-options select {
    padding: 7px 10px;
    border: 1px solid var(--f-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fafbfc;
    max-width: 100%;
}
.cart-item-options select:focus { outline: none; border-color: var(--f-primary); background: #fff; }
.opt-fixed { font-size: 13px; color: var(--f-text-muted); }

.cart-item-qty-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cart-item-duplicate {
    border: none;
    background: none;
    padding: 0;
    color: var(--f-primary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.cart-item-duplicate:hover { text-decoration: underline; }
.cart-item-hint { font-size: 12px; color: var(--f-text-muted); }

.cart-item-invalid { box-shadow: 0 0 0 2px var(--f-accent); }

.qty-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--f-border);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--f-category-bg);
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
}
.qty-btn:hover { filter: brightness(0.95); }
.qty-input {
    width: 64px;
    height: 30px;
    border: none;
    border-left: 1px solid var(--f-border);
    border-right: 1px solid var(--f-border);
    text-align: center;
    font-size: 13px;
    -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-item-remove {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #fdecea;
    color: #d93025;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}
.cart-item-remove:hover { background: #f8d3cf; }

.cart-form-panel {
    background: var(--f-surface);
    border-radius: var(--f-radius);
    box-shadow: var(--f-shadow);
    padding: 22px;
}
.cart-form-panel h2 { font-size: 16px; margin: 0 0 16px; }

.cart-form-panel .form-group { margin-bottom: 14px; }
.cart-form-panel label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--f-text-muted);
    margin-bottom: 6px;
}
.cart-form-panel input,
.cart-form-panel textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--f-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fafbfc;
}
.cart-form-panel input:focus,
.cart-form-panel textarea:focus {
    outline: none;
    border-color: var(--f-primary);
    background: #fff;
}

.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-whatsapp, .btn-email {
    padding: 13px;
    border: none;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { filter: brightness(0.95); }
.btn-whatsapp:disabled, .btn-email:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-email { background: var(--f-button); color: var(--f-button-text); }
.btn-email:hover { filter: brightness(0.92); }

.success-modal {
    text-align: center;
    max-width: 380px;
}
.success-icon { font-size: 44px; margin-bottom: 10px; }
.success-modal h2 { margin: 0 0 8px; font-size: 19px; }
.success-modal p { color: var(--f-text-muted); font-size: 14px; margin: 0 0 20px; }
.btn-pdf {
    display: block;
    margin: 0 0 12px;
    padding: 11px;
    border: 1px solid var(--f-border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--f-text);
    text-decoration: none;
}
.btn-pdf:hover { background: var(--f-category-bg); }
.btn-pdf[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
    .f-wrapper { flex-direction: column; padding: 12px; gap: 12px; }
    .f-sidebar { width: 100%; position: static; }
    .f-category-list {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 4px;
        gap: 8px;
    }
    .cat-btn { white-space: nowrap; }
    .cat-subgroup { display: contents; }
    .cat-btn-sub { white-space: nowrap; background: var(--f-category-bg); }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .cart-fab { right: 14px; bottom: 14px; padding: 12px 18px; font-size: 13px; }
    .f-toast-container { bottom: 80px; right: 14px; }
}
