/* ═══════════════════════════════════════
   B2B Platform - Base Styles
   ═══════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --light: #f8fafc;
    --dark: #1e293b;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #2563eb;
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f1f5f9;
    color: #334155;
    margin-bottom: 60px;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* ═══════════════════════════════════════
   RTL Support
   ═══════════════════════════════════════ */

[dir="rtl"] {
    font-family: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
}

[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-auto { margin-right: auto !important; margin-left: 0 !important; }
[dir="rtl"] .me-auto { margin-left: auto !important; margin-right: 0 !important; }

[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }

[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }
[dir="rtl"] .float-start { float: right !important; }
[dir="rtl"] .float-end { float: left !important; }

[dir="rtl"] .dropdown-menu-end {
    right: auto !important;
    left: 0 !important;
}

[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.5em;
}

[dir="rtl"] .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.5em;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    content: "\2039";
    float: right;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* ═══════════════════════════════════════
   Common Components
   ═══════════════════════════════════════ */

.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-radius: 0.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.table th {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Status Badges */
.badge-status {
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 500;
    border-radius: 0.375rem;
}

.badge-pending { background-color: #fef3c7; color: #92400e; }
.badge-approved { background-color: #d1fae5; color: #065f46; }
.badge-processing { background-color: #dbeafe; color: #1e40af; }
.badge-shipped { background-color: #e0e7ff; color: #3730a3; }
.badge-delivered { background-color: #d1fae5; color: #065f46; }
.badge-cancelled { background-color: #fee2e2; color: #991b1b; }
.badge-suspended { background-color: #fee2e2; color: #991b1b; }
.badge-rejected { background-color: #fecaca; color: #991b1b; }

/* Stat Cards (Dashboard) */
.stat-card {
    border-radius: 0.75rem;
    padding: 1.5rem;
    color: #fff;
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.875rem; opacity: 0.9; }
.stat-card .stat-icon { font-size: 2.5rem; opacity: 0.3; }

/* Tiered Price Table */
.tiered-price-table { border-radius: 0.5rem; overflow: hidden; }
.tiered-price-table th { background-color: var(--primary); color: #fff; text-transform: none; font-size: 0.9rem; }
.tiered-price-table .best-price { background-color: #ecfdf5; font-weight: 600; }
.tiered-price-table .savings-badge { font-size: 0.75rem; color: var(--success); font-weight: 600; }

/* Toast Container */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: 1rem;
}

/* Language Switcher */
.lang-switcher img { border-radius: 2px; }

/* ═══════════════════════════════════════
   Admin Sidebar
   ═══════════════════════════════════════ */

.admin-sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease, width 0.25s ease;
    overflow-x: hidden;
}

/* Sidebar nav-group accordion */
.admin-sidebar .nav-group {
    display: flex;
    flex-direction: column;
}
.admin-sidebar .nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    color: var(--sidebar-text);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 1.5rem 0.5rem;
    font-weight: 600;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    transition: color 0.15s;
}
[dir="rtl"] .admin-sidebar .nav-section-toggle {
    text-align: right;
}
.admin-sidebar .nav-section-toggle:hover {
    color: #fff;
}
.admin-sidebar .nav-section-toggle .chevron {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    opacity: 0.7;
}
.admin-sidebar .nav-group.collapsed .chevron {
    transform: rotate(-90deg);
}
[dir="rtl"] .admin-sidebar .nav-group.collapsed .chevron {
    transform: rotate(90deg);
}
.admin-sidebar .nav-group-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 1000px;
    transition: max-height 0.25s ease;
}
.admin-sidebar .nav-group.collapsed .nav-group-body {
    max-height: 0;
}

[dir="rtl"] .admin-sidebar {
    left: auto;
    right: 0;
}

.admin-sidebar .sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.admin-sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

[dir="rtl"] .admin-sidebar .nav-link {
    border-left: none;
    border-right: 3px solid transparent;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--sidebar-active);
}

[dir="rtl"] .admin-sidebar .nav-link:hover,
[dir="rtl"] .admin-sidebar .nav-link.active {
    border-left-color: transparent;
    border-right-color: var(--sidebar-active);
}

.admin-sidebar .nav-section {
    color: var(--sidebar-text);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 1.5rem 0.5rem;
    font-weight: 600;
}

.admin-content {
    margin-left: 260px;
    min-height: 100vh;
    padding: 0;
}

[dir="rtl"] .admin-content {
    margin-left: 0;
    margin-right: 260px;
}

.admin-topbar {
    background: #fff;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-main {
    padding: 1.5rem;
}

/* ═══════════════════════════════════════
   Dealer Layout
   ═══════════════════════════════════════ */

.dealer-topbar {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.dealer-topbar .navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--primary);
}

.dealer-mega-menu .dropdown-menu {
    min-width: 600px;
    padding: 1rem;
}

.dealer-footer {
    background: var(--dark);
    color: var(--sidebar-text);
    padding: 2rem 0;
    margin-top: 3rem;
}

/* Mini Cart */
.mini-cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

[dir="rtl"] .mini-cart-badge {
    right: auto;
    left: -5px;
}

/* Product Card */
.product-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #e2e8f0;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.product-card .product-image {
    height: 200px;
    object-fit: contain;
    padding: 1rem;
}

.product-card .price-range {
    color: var(--primary);
    font-weight: 700;
}

/* ═══════════════════════════════════════
   Responsive
   ═══════════════════════════════════════ */

/* Tables scroll on mobile */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

    [dir="rtl"] .admin-sidebar {
        transform: translateX(100%);
    }

    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: 5px 0 30px rgba(0,0,0,0.3);
    }

    .admin-content {
        margin-left: 0 !important;
    }

    [dir="rtl"] .admin-content {
        margin-right: 0 !important;
    }

    .admin-main {
        padding: 1rem;
    }

    .admin-topbar {
        padding: 0.5rem 1rem;
    }

    /* Stat cards stack vertically */
    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    /* Tables become scrollable */
    .card-body > .table,
    .card-body > table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    /* Product cards 2 columns on tablet, 1 on phone */
    .product-card .product-image {
        height: 140px;
    }

    .product-card .card-title {
        font-size: 0.85rem;
    }

    /* Hero banners shorter on mobile */
    .carousel-item > div,
    [style*="height:350px"],
    [style*="height:300px"],
    [style*="height: 350px"],
    [style*="height: 300px"] {
        min-height: 200px !important;
        height: auto !important;
        padding: 2rem 1rem !important;
    }

    .carousel-item h1,
    .carousel-item h2 {
        font-size: 1.4rem !important;
    }

    /* Dealer navbar */
    .dealer-topbar .navbar-brand {
        font-size: 1.1rem;
    }

    .dealer-topbar .input-group {
        margin: 0.5rem 0;
    }

    /* Store layout */
    .dealer-footer .row > div {
        margin-bottom: 1rem;
    }

    /* Forms side by side → stack */
    .row.align-items-end > div {
        margin-bottom: 0.5rem;
    }

    /* Tiered price table */
    .tiered-price-table {
        font-size: 0.85rem;
    }

    /* Sidebar filter on mobile → collapsible */
    .col-md-3 > .card {
        margin-bottom: 1rem;
    }

    /* Card padding reduce */
    .card-body {
        padding: 0.75rem;
    }

    /* Display-6 smaller */
    .display-6 {
        font-size: 1.5rem !important;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.8rem;
    }

    /* Auth card */
    .auth-card {
        padding: 1.5rem !important;
        margin: 1rem;
    }
}

@media (max-width: 576px) {
    .product-card .product-image {
        height: 120px;
    }

    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .stat-card .stat-value {
        font-size: 1.1rem;
    }

    .stat-card .stat-icon {
        font-size: 1.5rem;
    }

    /* Navbar buttons stack */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    h3, h4 {
        font-size: 1.1rem;
    }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.admin-sidebar.show ~ .sidebar-overlay,
.admin-sidebar.show + .admin-content .sidebar-overlay {
    display: block;
}

/* DataTables Responsive — mobil collapsible row görünümü */
table.dataTable > tbody > tr.dtr-expanded > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before {
    background-color: var(--primary, #0d6efd);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.25);
    border-radius: 50%;
}
table.dataTable > tbody > tr.dtr-expanded > td.dtr-control::before {
    background-color: #dc3545;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.25);
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control {
    cursor: pointer;
}
/* Child row (açılan detay) görünümü */
table.dataTable > tbody > tr.child ul.dtr-details {
    display: block;
    width: 100%;
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding: 0.5rem 0;
}
table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
    border-bottom: none;
}
table.dataTable > tbody > tr.child ul.dtr-details .dtr-title {
    font-weight: 600;
    color: #555;
    min-width: 100px;
    display: inline-block;
}
/* Mobilde satır tıklama feedback */
@media (max-width: 991.98px) {
    table.dataTable tbody tr:hover {
        background-color: rgba(13, 110, 253, 0.04);
        cursor: pointer;
    }
    table.dataTable tbody tr.dtr-expanded {
        background-color: rgba(13, 110, 253, 0.06);
    }
    /* Aksiyon butonları dikey stack */
    table.dataTable td .btn + .btn,
    table.dataTable td .btn + form,
    table.dataTable td form + form,
    table.dataTable td form + .btn {
        margin-top: 0.25rem;
    }
}
