/* ==========================================================================
   GENEL SIFIRLAMA & TEMEL AYARLAR
   ========================================================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f1f5f9;
    margin: 0;
    padding-bottom: 50px;
    color: #1e293b;
    line-height: 1.4;
}

/* ==========================================================================
   NAVBAR (MASAÜSTÜ & MOBİL AÇILIR MENÜ)
   ========================================================================== */
.navbar {
    background: #1e293b;
    padding: 14px 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.navbar a {
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-block;
}

.navbar a.active, .navbar a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

/* Hamburger Menü Butonu (Masaüstünde Gizli) */
.nav-mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.6rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    margin: 0;
    width: auto;
}

.nav-mobile-brand {
    display: none;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
}

/* ==========================================================================
   KONTEYNER & KARTLAR
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 16px;
    width: 100%;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: #ffffff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

/* ==========================================================================
   FORM ELEMANLARI & BUTONLAR
   ========================================================================== */
input, select, button {
    width: 100%;
    padding: 9px 12px;
    margin: 6px 0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.92rem;
    outline: none;
}

input:focus, select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

button {
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:active {
    transform: scale(0.98);
}

.btn-primary { background: #2563eb; color: #fff; border: none; }
.btn-primary:hover { background: #1d4ed8; }

.btn-success { background: #16a34a; color: #fff; border: none; }
.btn-success:hover { background: #15803d; }

.btn-print { background: #475569; color: #fff; border: none; }
.btn-print:hover { background: #334155; }

.btn-savings { background: #9333ea; color: #fff; border: none; }
.btn-savings:hover { background: #7e22ce; }

.btn-danger { background: #dc2626; color: #fff; border: none; }
.btn-danger:hover { background: #b91c1c; }

/* ==========================================================================
   AKORDİYON (compare.php)
   ========================================================================== */
.accordion-item {
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    transition: background 0.3s;
}

.accordion-item.all-updated {
    background-color: #f0fdf4;
    border-color: #bbf7d0;
}

.accordion-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}

.accordion-content {
    display: none;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: rgba(255,255,255,0.85);
}

.accordion-content.open {
    display: block;
}

.market-row {
    display: grid;
    grid-template-columns: 150px 140px 40px 120px 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
}

.market-row:last-child {
    border-bottom: none;
}

.market-row input {
    margin: 0;
    padding: 6px 8px;
}

.link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    text-decoration: none;
    border-radius: 6px;
    height: 34px;
    color: #475569;
}

.link-btn-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e0f2fe;
    text-decoration: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
}

.badge {
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    display: inline-block;
}

.badge-updated { background: #dcfce7; color: #166534; }
.badge-check { background: #ffedd5; color: #9a3412; }

.highlight-card {
    border: 2px solid #16a34a;
    background: #f0fdf4;
}

/* ==========================================================================
   SEPET TABLOLARI (cart.php)
   ========================================================================== */
.cart-group {
    margin-bottom: 20px;
    border-left: 4px solid #2563eb;
    padding-left: 12px;
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.cart-table th, .cart-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: middle;
}

.cart-total-box {
    text-align: right;
    margin-top: 16px;
    font-size: 1.15rem;
}

/* ==========================================================================
   BİLDİRİMLER & TOAST
   ========================================================================== */
.form-feedback {
    display: none;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
}

.form-feedback.success {
    display: block;
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.form-feedback.error {
    display: block;
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-box {
    min-width: 250px;
    max-width: 90vw;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(-15px);
    animation: toastSlideDown 0.3s forwards ease;
    transition: opacity 0.4s ease;
}

.toast-success { background-color: #16a34a; }
.toast-error { background-color: #dc2626; }
.toast-info { background-color: #0284c7; }

@keyframes toastSlideDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   MOBİL VE DAR EKRAN UYUMLULUĞU (AÇILIR MENÜ VE TABLO DÜZENİ)
   ========================================================================== */
@media (max-width: 768px) {
    /* Navbar: Mobilde Başlık ve Sağda İkon */
    .navbar {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 12px 16px !important;
    }

    .nav-mobile-brand {
        display: inline-block !important;
    }

    .nav-mobile-toggle {
        display: inline-flex !important;
    }

    /* Mobilde linkler varsayılan olarak kapalıdır */
    .navbar a:not(.nav-mobile-brand) {
        display: none !important;
        width: 100% !important;
        padding: 12px 14px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        text-align: left;
        font-size: 0.95rem;
    }

    /* Menü açıldığında alt alta göster */
    .navbar.mobile-menu-open a:not(.nav-mobile-brand) {
        display: block !important;
        animation: fadeInMenu 0.2s ease forwards;
    }

    @keyframes fadeInMenu {
        from { opacity: 0; transform: translateY(-5px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .container {
        padding: 0 8px;
        margin: 10px auto;
        width: 100%;
    }

    .card {
        padding: 10px 12px;
        border-radius: 8px;
        margin-bottom: 12px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .market-selection-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .market-checkbox-group {
        width: 100%;
        gap: 6px;
    }

    .market-checkbox-label {
        font-size: 0.78rem;
        padding: 4px 8px;
    }

    .card:has(table) {
        overflow-x: hidden !important;
        padding: 8px 10px !important;
    }

    table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        font-size: 0.78rem !important;
    }

    th, td {
        padding: 6px 4px !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* 1. SEPETİM (cart.php) MOBİL */
    .cart-table th:nth-child(4),
    .cart-table td:nth-child(4),
    .cart-table th:nth-child(5),
    .cart-table td:nth-child(5) {
        display: none !important;
    }

    .cart-table th:nth-child(1) { width: 44% !important; }
    .cart-table th:nth-child(2) { width: 26% !important; text-align: center; }
    .cart-table th:nth-child(3) { width: 20% !important; }
    .cart-table th:nth-child(6) { width: 10% !important; }

    .qty-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 0.85rem !important;
    }

    .qty-input {
        width: 24px !important;
        font-size: 0.78rem !important;
    }

    /* 2. TÜM ÜRÜNLER (products.php) MOBİL */
    .cat-desktop-text { display: none !important; }
    .cat-mobile-link { display: inline-flex !important; }

    .data-table th:nth-child(3),
    .data-table td:nth-child(3),
    .data-table th:nth-child(6),
    .data-table td:nth-child(6),
    .th-desktop-link,
    .td-desktop-link,
    .data-table th:nth-child(8),
    .data-table td:nth-child(8) {
        display: none !important;
    }

    .data-table th:nth-child(1) { width: 48% !important; }
    .th-cat-link { width: 12% !important; text-align: center !important; }
    .td-cat-link { text-align: center !important; }
    .data-table th:nth-child(4) { width: 22% !important; }
    .data-table th:nth-child(5) { width: 18% !important; }

    .price-input-cell {
        width: 100% !important;
        padding: 4px 6px !important;
        font-size: 0.78rem !important;
    }

    /* 3. KAYITLI LİSTELER (saved_lists.php) MOBİL */
    .saved-table th:nth-child(3),
    .saved-table td:nth-child(3),
    .saved-table th:nth-child(5),
    .saved-table td:nth-child(5),
    .saved-table th:nth-child(7),
    .saved-table td:nth-child(7) {
        display: none !important;
    }

    .saved-table th:nth-child(1) { width: 30% !important; font-size: 0.72rem !important; }
    .saved-table th:nth-child(2) { width: 36% !important; }
    .saved-table th:nth-child(4) { width: 20% !important; }
    .saved-table th:nth-child(6) { width: 14% !important; }

    /* 4. MARKETS & CATEGORIES MOBİL */
    .markets-table th:nth-child(1),
    .markets-table td:nth-child(1),
    .simple-table th:nth-child(1),
    .simple-table td:nth-child(1) {
        width: 40px !important;
        font-size: 0.75rem !important;
    }

    /* EN UYGUNU BUL (compare.php) */
    .market-row {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px 0;
    }

    .market-row strong {
        grid-column: span 2;
        font-size: 0.88rem;
    }

    .market-row input {
        grid-column: span 1;
        width: 100%;
        font-size: 0.8rem;
    }

    .market-row .link-btn {
        grid-column: span 1;
        width: 100%;
        height: 32px;
        font-size: 0.8rem;
    }

    .market-row .badge {
        grid-column: span 2;
        width: 100%;
        padding: 4px 0;
        font-size: 0.75rem;
    }

    .market-row button {
        grid-column: span 2;
        width: 100%;
        padding: 6px;
        font-size: 0.82rem;
    }

    /* Butonlar & Filtreler */
    .cart-header-row, .filter-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px;
    }

    .cart-header-actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }

    .cart-header-actions button {
        width: 100% !important;
        padding: 8px 10px !important;
        font-size: 0.82rem !important;
    }

    .filter-container-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 10px 12px !important;
    }

    .filter-controls {
        flex-wrap: wrap !important;
        width: 100%;
        gap: 6px !important;
    }

    .filter-controls select.filter-select {
        flex: 1 1 45% !important;
        min-width: 0 !important;
        font-size: 0.82rem !important;
        padding: 6px 8px !important;
    }

    .filter-controls button.btn-filter-clear {
        width: 100% !important;
        font-size: 0.82rem !important;
        padding: 6px 10px !important;
    }

    #toast-container {
        top: auto;
        bottom: 12px;
        left: 12px;
        right: 12px;
    }

    .toast-box {
        width: 100%;
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}