:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --topbar-height: 70px;
    --primary-color: #3b82f6;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --text-muted: #94a3b8;
}

body {
    font-family: "Outfit", sans-serif;
    background-color: var(--bg-dark);
    color: #fff;
    margin: 0;
    overflow-x: hidden;
}

/* Layout Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg) !important;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
}

.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1040;
}

/* Sidebar States */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}
.sidebar-collapsed .sidebar .fs-4,
.sidebar-collapsed .sidebar .nav-link span {
    display: none;
}
.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 12px 0;
}
.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        width: var(--sidebar-width) !important;
    }
    .sidebar.sidebar-open .fs-4,
    .sidebar.sidebar-open .nav-link span {
        display: inline !important;
    }
    .main-content {
        margin-left: 0 !important;
    }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
    display: none;
    backdrop-filter: blur(4px);
}
.sidebar-overlay.active {
    display: block;
}

/* Nav Styles */
.nav-link {
    color: var(--text-muted);
    transition: all 0.2s;
}
.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1) !important;
}

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}
.sidebar-collapse-btn:hover,
.sidebar-collapse-btn.active {
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1) !important;
}
.sidebar-chevron {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}
.sidebar-collapse-btn[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(180deg);
}

/* Sidebar Sub Items */
.sidebar-sub-item {
    font-size: 0.88rem;
}


/* Custom Cards */
.custom-card,
.settings-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
}

/* Menu Management Specific */
.category-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.3s;
}
.category-header {
    padding: 18px 24px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.product-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: grab;
}
.cat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-right: 18px;
}
.prod-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-right: 14px;
}

/* Settings Specific */
.group-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Common Components */
.category-item:hover {
    transform: translateX(8px);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.product-item:hover {
    transform: translateX(8px);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.badge-count {
    background: rgba(var(--bs-primary-rgb), 0.15);
    color: var(--bs-primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ─── Sortable.js Stilleri (forceFallback: true modu) ─── */
/*
  forceFallback modunda:
  • .sortable-ghost    = listede bırakma pozisyonunu gösteren yarı şeffaf placeholder
  • .sortable-fallback = fareyle birlikte giden görsel klon (body'e eklenir)
  • .sortable-chosen   = fare basılmış ama sürükleme başlamamış
*/

/* Placeholder: bırakılacağı yeri gösterir */
.sortable-ghost {
    opacity: 0.4 !important;
    background: rgba(59, 130, 246, 0.06) !important;
    border: 2px dashed rgba(59, 130, 246, 0.5) !important;
}

/* Fareyle giden görsel klon */
.sortable-fallback {
    background: var(--card-bg) !important;
    border: 1px solid rgba(59, 130, 246, 0.6) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6) !important;
    border-radius: 12px !important;
    opacity: 0.95 !important;
    cursor: grabbing !important;
}

/* Fare basılmış, henüz sürükleme başlamamış */
.sortable-chosen {
    border-color: rgba(59, 130, 246, 0.4) !important;
}

/* Drag handle */
.drag-handle {
    cursor: grab;
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    margin-right: 12px;
    transition: color 0.2s;
    user-select: none;
}
.drag-handle:hover {
    color: rgba(255, 255, 255, 0.6);
}
.drag-handle:active {
    cursor: grabbing;
}
.sorting-active .drag-handle {
    cursor: grabbing !important;
}

/* Bırakma sonrası yeşil flash */
.sort-success-highlight {
    animation: sortFlash 0.8s ease forwards;
}
@keyframes sortFlash {
    0% {
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.55);
        border-color: rgba(34, 197, 94, 0.8) !important;
    }
    100% {
        box-shadow: none;
        border-color: var(--border-color) !important;
    }
}

/* Specific Page Styles consolidated from EJS files */
.allergen-search-wrapper {
    position: relative;
}
.search-results-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    max-height: 250px;
    overflow-y: auto;
    display: none;
    margin-top: 6px;
    padding: 6px;
}
.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}
.search-result-item:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    transform: translateX(4px);
}
.search-result-item i {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.75rem;
}

.printer-chip {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.printer-chip .remove-chip {
    cursor: pointer;
    opacity: 0.7;
}
.printer-chip .remove-chip:hover {
    opacity: 1;
}

.chevron {
    transition: transform 0.4s;
    color: var(--primary-color);
    font-size: 0.9rem;
}
.collapsed .chevron {
    transform: rotate(-90deg);
}

.actions {
    opacity: 0.4;
    transition: opacity 0.2s;
}
.category-item:hover .actions,
.product-item:hover .actions {
    opacity: 1;
}

.search-group .input-group-text {
    border-radius: 12px 0 0 12px !important;
}
.search-group .form-control {
    border-radius: 0 12px 12px 0 !important;
    padding: 12px 18px;
}

/* Settings Page - Fixed Height Lists & Custom Scrollbars */
#invoiceGroupsList,
#warehouseGroupsList,
#printersList,
#noteGroupsList,
#allergensList,
#unitsList {
    height: 250px;
    overflow-y: auto;
    padding-right: 8px;
}

#invoiceGroupsList::-webkit-scrollbar,
#warehouseGroupsList::-webkit-scrollbar,
#printersList::-webkit-scrollbar,
#noteGroupsList::-webkit-scrollbar,
#allergensList::-webkit-scrollbar,
#unitsList::-webkit-scrollbar {
    width: 4px;
}

#invoiceGroupsList::-webkit-scrollbar-thumb,
#warehouseGroupsList::-webkit-scrollbar-thumb,
#printersList::-webkit-scrollbar-thumb,
#noteGroupsList::-webkit-scrollbar-thumb,
#allergensList::-webkit-scrollbar-thumb,
#unitsList::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#invoiceGroupsList::-webkit-scrollbar-thumb:hover,
#warehouseGroupsList::-webkit-scrollbar-thumb:hover,
#printersList::-webkit-scrollbar-thumb:hover,
#noteGroupsList::-webkit-scrollbar-thumb:hover,
#allergensList::-webkit-scrollbar-thumb:hover,
#unitsList::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Menu Management - Product Indentation */
.product-list {
    padding: 0 16px 20px 24px;
    margin-left: 30px;
}

.subcategories-container {
    margin-left: 30px;
    margin-bottom: 12px;
}

/* ── Bulk checkbox ── */
.menu-tree-container {
    /* Soldaki floating checkbox için yer aç */
    padding-left: 32px;
}

/* Her seçilebilir kart relative konumda olmalı */
.bulk-selectable {
    position: relative;
}

/* Checkbox kartın solunda, tam ortalanmış şekilde yüzer */
.bulk-chk-float {
    position: absolute;
    left: -26px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    accent-color: var(--bs-warning);
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.15s;
    z-index: 2;
}

/* Seçildiğinde veya üzerine gelindiğinde belirginleş */
.bulk-selectable:hover .bulk-chk-float,
.bulk-chk-float:checked {
    opacity: 1;
}

/* ── Yuvarlama adım butonları ── */
.bulk-round-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.bulk-round-btn:hover {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    border-color: rgba(255, 193, 7, 0.3);
}
/* ── Yuvarla ana buton (toggle) ── */
.bulk-round-toggle-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    color: #adb5bd;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.bulk-round-toggle-btn:hover {
    border-color: rgba(255, 193, 7, 0.5);
    color: #ffc107;
    background: rgba(255, 193, 7, 0.08);
}
.bulk-round-toggle-btn.active {
    background: rgba(255, 193, 7, 0.18);
    border-color: #ffc107;
    color: #ffc107;
    font-weight: 600;
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.25);
}

.bulk-round-btn.active {
    background: rgba(255, 193, 7, 0.25);
    color: #ffc107;
    border-color: rgba(255, 193, 7, 0.5);
}

/* ── Sticky bar ── */
.bulk-price-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-top: 1px solid rgba(255, 193, 7, 0.35);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    padding: 14px 24px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bulk-price-bar.visible {
    transform: translateY(0);
}
.bulk-price-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.bulk-info {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    white-space: nowrap;
}
.bulk-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.bulk-type-toggle,
.bulk-direction-toggle {
    display: flex;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
}
.bulk-toggle-btn {
    background: transparent;
    color: #aaa;
    border: none;
    padding: 6px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}
.bulk-toggle-btn.active {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    font-weight: 600;
}
.bulk-toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

/* ═══════════════════════════════════════════════ */
/* BARKOD İŞLEMLERİ STİLLERİ                     */
/* ═══════════════════════════════════════════════ */

/* Barkod Input Grubu */
.barcode-input-group {
    position: relative;
}
.barcode-input-group .form-control {
    padding-right: 70px;
}
.barcode-actions {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
}
.barcode-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}
.barcode-generate-btn {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.barcode-generate-btn:hover {
    background: rgba(34, 197, 94, 0.3);
    color: #4ade80;
    transform: scale(1.1);
}
.barcode-scan-btn {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}
.barcode-scan-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    transform: scale(1.1);
}

/* Tab Toggle */
.barcode-tab-toggle {
    display: flex;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    overflow: hidden;
}
.barcode-tab-btn {
    flex: 1;
    background: transparent;
    color: #aaa;
    border: none;
    padding: 10px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.barcode-tab-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    font-weight: 600;
}
.barcode-tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}


/* Dosya Yükleme Alanı */
.barcode-file-upload {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.02);
}
.barcode-file-upload:hover,
.barcode-file-upload.drag-over {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.05);
}
.barcode-preview-img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sonuç Alanı */
.barcode-result {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 12px;
    padding: 16px 20px;
    margin-top: 16px;
}
.barcode-result-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Fade-in animasyonu */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* USB Barkod Okuyucu Paneli */
.barcode-usb-area {
    text-align: center;
    padding: 30px 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}
.barcode-usb-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
    font-size: 1.8rem;
}
.barcode-usb-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.4);
    animation: usbPulse 2s ease-in-out infinite;
}
@keyframes usbPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0; }
}
.barcode-usb-area input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

/* ==========================================
   HAMMADDE YÖNETİMİ
   ========================================== */

#rawMaterialsTable {
    background: transparent;
}

#rawMaterialsTable th {
    background: rgba(255, 255, 255, 0.02);
}

#rawMaterialsTable tbody tr {
    transition: background 0.15s;
}

#rawMaterialsTable tbody tr:hover {
    background: rgba(59, 130, 246, 0.05) !important;
}

.rm-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.rm-unit-badge {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.25);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

.rm-billing-badge {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

