/* ===== Unified Menu System Styles (Dark Mode Supported) ===== */

/* Section Specifics */
#section-menu .card-body {
    padding: 0;
}

#section-menu .controls-row {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0 !important;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.menu-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: auto;
    /* Push to left in RTL */
}

@media (max-width: 640px) {
    #section-menu .controls-row .search-input {
        order: 1;
        flex: 1 1 100% !important;
        margin-bottom: 12px;
    }

    /* Toolbar Alignment Fix (RTL) */
    .menu-toolbar-actions {
        order: 2;
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        /* Toggle Right, Buttons Left */
        align-items: center;
        flex: 1 1 100%;
        margin: 0 !important;
        padding: 0 2px;
    }

    /* Reset margins to prevent center-bias */
    .menu-toolbar-actions>* {
        margin: 0 !important;
    }
}

#menu-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px 80px 20px;
}

/* Empty State */
.state-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--border);
}

/* Category Card */
.menu-category-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
}

.menu-category-card:hover {
    border-color: var(--text-muted);
}

.menu-category-card.open {
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

/* Category Header */
.cat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
    min-height: 70px;
}

.menu-category-card.open .cat-header {
    background: var(--bg-soft);
}

.cat-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    padding: 10px;
    margin-left: 8px;
    font-size: 18px;
    display: flex;
    align-items: center;
}

.cat-drag-handle:active {
    cursor: grabbing;
    color: var(--primary);
}

.cat-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cat-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.cat-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cat-badge {
    background: var(--bg-soft);
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    border: 1px solid var(--border);
    min-width: 20px;
    text-align: center;
}

/* Compact Switch for Product List */
.switch.compact {
    width: 32px;
    height: 18px;
    margin: 0;
}

.switch.compact .slider:before {
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
}

.switch.compact input:checked+.slider:before {
    transform: translateX(14px);
}

.cat-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Action Buttons */
.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg-soft);
    color: var(--text-main);
}

.action-btn.edit:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.chevron-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-category-card.open .chevron-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

/* Category Body */
.cat-body {
    display: none;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
    padding: 16px;
}

.menu-category-card.open .cat-body {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Product List */
.cat-products-list {
    min-height: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Product Item */
.menu-product-item {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 10px;
    transition: all 0.2s;
}

.menu-product-item:hover {
    border-color: var(--text-muted);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.prod-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    padding: 10px;
    font-size: 14px;
}

.prod-drag-handle:active {
    cursor: grabbing;
    color: var(--primary);
}

.prod-img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-soft);
    flex-shrink: 0;
}

.prod-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prod-info {
    flex: 1;
    padding: 0 12px;
    overflow: hidden;
}

.prod-name {
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.prod-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prod-pricing {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.9rem;
    background: var(--bg-soft);
    padding: 4px 8px;
    border-radius: 6px;
}

.prod-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 12px;
    border-right: 1px solid var(--border);
    padding-right: 12px;
}

/* Product Placeholder Button */
.add-prod-placeholder {
    margin-top: 12px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    background: var(--card-bg);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.add-prod-placeholder:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-soft);
}

/* Sortable Classes */
.sortable-ghost {
    opacity: 0.4;
    background: var(--bg-soft);
}

.sortable-drag {
    background: var(--card-bg);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
    transform: scale(1.02);
    border: 1px solid var(--primary);
}

@media (max-width: 640px) {
    #menu-container {
        padding: 15px 10px;
    }

    .prod-desc,
    .prod-pricing {
        display: none !important;
    }

    /* Truncate Long Category Names */
    .cat-info {
        flex-wrap: nowrap !important;
        /* Prevent wrapping */
        min-width: 0;
        /* Enable flex shrinkage */
    }

    .cat-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 1rem;
        max-width: 120px;
    }

    /* Product Item Mobile Optimizations */
    .prod-img {
        width: 36px !important;
        height: 36px !important;
    }

    .prod-info {
        padding: 0 8px !important;
        flex: 1 !important;
        min-width: 0;
    }

    .prod-name {
        display: block !important;
        font-size: 13px !important;
        width: 100%;
        color: var(--text-main);
    }

    .prod-controls {
        gap: 4px !important;
        margin-right: 4px !important;
        padding-right: 4px !important;
        border-right: 1px solid var(--border) !important;
    }

    .prod-drag-handle {
        padding: 6px !important;
        font-size: 12px !important;
    }

    .action-btn {
        width: 32px !important;
        height: 32px !important;
    }

    .switch.compact {
        width: 30px !important;
        height: 16px !important;
    }

    .switch.compact .slider:before {
        height: 10px !important;
        width: 10px !important;
        left: 3px !important;
        bottom: 3px !important;
    }

    .switch.compact input:checked+.slider:before {
        transform: translateX(14px) !important;
    }
}