/* ============================================================================
   CATEGORIES LIST
   ============================================================================ */

.categories-list {
    padding: 0 24px;
    margin-bottom: 40px;
}

.category-list-item {
    background: white;
    border-radius: 18px;
    padding: 16px 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 2px solid transparent;
    box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
    position: relative;
    overflow: hidden;
}

.category-list-item.category-active {
    border-color: rgba(212, 165, 116, 0.75) !important;
    background: rgba(212, 165, 116, 0.1) !important;
    box-shadow: rgba(212, 165, 116, 0.35) 0px 0px 0px 3px, rgba(0, 0, 0, 0.1) 0px 2px 8px !important;
    transform: none !important;
}

.category-list-item.category-active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(212, 165, 116, 0.07);
    border-radius: 16px;
    pointer-events: none;
}

    .category-list-item:hover {
        transform: translateX(4px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        border-color: rgba(212, 165, 116, 0.2);
    }

.category-list-icon {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.category-list-item:hover .category-list-icon {
    transform: scale(1.1) rotate(5deg);
}

.category-list-info {
    flex: 1;
    min-width: 0;
}

.category-list-name {
    font-size: 16px;
    font-weight: 800;
    color: #212529;
    margin-bottom: 3px;
    letter-spacing: -0.3px;
}

.category-list-count {
    font-size: 13px;
    color: #6c757d;
    font-weight: 600;
}

.category-list-arrow {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff5e6, #fef3c7);
    border: 1.5px solid rgba(212, 165, 116, 0.25);
    color: #d4a574;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    transition: all 0.3s ease;
}

.category-list-item:hover .category-list-arrow {
    background: #d4a574;
    color: white;
    border-color: #d4a574;
    transform: translateX(3px);
}

/* ── TOP FOR DETAILS item ────────────────────────────────────────────────── */
.category-list-item.category-top-item {
    background: linear-gradient(135deg, #fff9f0, #fff5e6);
    border-color: rgba(212, 165, 116, 0.3);
}

.category-list-item.category-top-item .category-list-name {
    color: #c4956f;
}

.category-list-item.category-top-item .category-list-icon {
    background: linear-gradient(135deg, #fff0d6, #fce8c0);
    flex-direction: column;
    gap: 1px;
}

.top-item-star {
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(206, 159, 114, 0.5));
}

/* ── Tap-hint hand animation (mirrors redesign.css for Dashboard) ─────── */
.category-tap-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    pointer-events: none;
}

.category-hand-icon {
    width: 24px;
    height: 24px;
    color: #CE9F72;
    filter: drop-shadow(0 1px 4px rgba(206, 159, 114, 0.4));
    animation: catHandTap 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.category-tap-text {
    font-size: 7px;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: #CE9F72;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    animation: catTextPulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    white-space: nowrap;
}

@keyframes catHandTap {
    0%   { transform: translateY(0)  scale(1);    opacity: 0.7; }
    40%  { transform: translateY(3px) scale(0.94); opacity: 1;   }
    70%  { transform: translateY(0)  scale(1.05); opacity: 1;   }
    100% { transform: translateY(0)  scale(1);    opacity: 0.7; }
}

@keyframes catTextPulse {
    0%   { opacity: 0.55; }
    50%  { opacity: 1;    }
    100% { opacity: 0.55; }
}

.category-list-item.category-top-item:hover {
    border-color: rgba(212, 165, 116, 0.5);
    box-shadow: 0 4px 20px rgba(212, 165, 116, 0.18);
}

/* ── Tap-hint inside first category-list-item (inline, before arrow) ─── */
.category-list-item .tap-hint {
    position: static;
    transform: none;
    top: auto;
    left: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.category-list-item .hand-icon {
    width: 22px;
    height: 22px;
    color: #1a1a1a;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
    animation: catHandTap 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.category-list-item .tap-hint-text {
    font-size: 7px;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: #1a1a1a;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
    animation: catTextPulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    white-space: nowrap;
}

/* ============================================================================
   MENU CATEGORIES - CARD VIEW (FIXED TEXT OVERFLOW)
   ============================================================================ */

.menu-categories {
    padding: 16px 24px;
    margin-bottom: 32px;
    transition: all 0.3s ease;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.category-card {
    background: white;
    border-radius: 18px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    border: 2px solid transparent;
    width: 100%;
    box-sizing: border-box;
    /* box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;*/
    box-shadow: rgba(0, 0, 0, 0.2) 0px 3px 1px -1px, rgba(0, 0, 0, 0.14) 0px 1px 1px 0px, rgba(0, 0, 0, 0.12) 0px 1px 3px 0px !important;
}

    .category-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
        border-color: rgba(212, 165, 116, 0.15);
    }

.category-image-wrapper {
    width: 100%;
    height: 110px;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 12px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

    .category-image-wrapper:hover {
        box-shadow: 0 6px 28px rgba(0, 0, 0, 0.12);
    }

.category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.category-card:hover .category-image {
    transform: scale(1.12);
}

/* Card Bottom Section - FIXED */
.category-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0; /* Critical for text overflow */
}

/* FIXED: Category Info Container */
.category-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0; /* Critical for text overflow */
    overflow: hidden; /* Prevent overflow */
}

/* FIXED: Category Name - Proper Text Overflow */
.category-name {
    font-size: 15px;
    font-weight: 800;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 5px;
    letter-spacing: -0.3px;
    min-width: 0; /* Critical for text overflow */
    max-width: 100%; /* Prevent overflow */
}

/* FIXED: Emoji stays visible */
.category-emoji {
    font-size: 17px;
    flex-shrink: 0; /* Emoji never shrinks */
}

/* FIXED: Text wrapper for long names */
.category-name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Critical for text overflow */
}

.category-count {
    font-size: 11px;
    color: #6c757d;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quick Add Button */
.quick-add-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #d4a574 0%, #c4956f 100%);
    color: white;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.40);
    transition: all 0.3s ease;
    z-index: 10;
    flex-shrink: 0; /* Button never shrinks */
}

.category-card:hover .quick-add-btn {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.5);
}

.quick-add-btn:active {
    transform: scale(0.95);
}

/* Popular Badge */
.popular-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #ff6b6b, #ff5252);
    color: white;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.35);
    z-index: 5;
    letter-spacing: 0.3px;
}

.badge-icon {
    font-size: 12px;
}

/* ============================================================================
   LIST VIEW (FIXED TEXT OVERFLOW)
   ============================================================================ */

.menu-categories.list-view {
    display: block;
}

    .menu-categories.list-view .category-card {
        padding: 14px;
        margin-bottom: 10px;
        border-radius: 16px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .menu-categories.list-view .category-image-wrapper {
        width: 65px;
        height: 65px;
        border-radius: 12px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .menu-categories.list-view .category-bottom {
        flex: 1;
        justify-content: space-between;
        min-width: 0; /* Critical for text overflow */
    }

    .menu-categories.list-view .category-info {
        flex: 1;
        gap: 2px;
        min-width: 0; /* Critical for text overflow */
        overflow: hidden; /* Prevent overflow */
    }

    .menu-categories.list-view .category-name {
        font-size: 15px;
    }

    .menu-categories.list-view .category-emoji {
        font-size: 17px;
    }

    .menu-categories.list-view .category-count {
        font-size: 11px;
    }

    .menu-categories.list-view .quick-add-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
        flex-shrink: 0; /* Button never shrinks */
    }

    .menu-categories.list-view .popular-badge {
        padding: 4px 9px;
        font-size: 10px;
        top: 8px;
        right: 8px;
    }

/* ============================================================================
   PROFESSIONAL LOADING — card entrance + chip loading ring
   ============================================================================ */

/* Cards slide up and fade in when content arrives */
@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#menuCategories .category-card {
    animation: cardReveal 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Stagger each card — grid is 2 columns, so pairs enter together */
#menuCategories .category-card:nth-child(1)  { animation-delay:   0ms; }
#menuCategories .category-card:nth-child(2)  { animation-delay:   0ms; }
#menuCategories .category-card:nth-child(3)  { animation-delay:  55ms; }
#menuCategories .category-card:nth-child(4)  { animation-delay:  55ms; }
#menuCategories .category-card:nth-child(5)  { animation-delay: 110ms; }
#menuCategories .category-card:nth-child(6)  { animation-delay: 110ms; }
#menuCategories .category-card:nth-child(7)  { animation-delay: 165ms; }
#menuCategories .category-card:nth-child(8)  { animation-delay: 165ms; }
#menuCategories .category-card:nth-child(9)  { animation-delay: 220ms; }
#menuCategories .category-card:nth-child(10) { animation-delay: 220ms; }
#menuCategories .category-card:nth-child(11) { animation-delay: 275ms; }
#menuCategories .category-card:nth-child(12) { animation-delay: 275ms; }

/* In list-view each row is independent — keep the same cascade */
#menuCategories.list-view .category-card:nth-child(odd),
#menuCategories.list-view .category-card:nth-child(even) {
    animation-delay: calc((var(--card-i, 0)) * 45ms);
}

/* ── Filter chip — loading ring while fetch is in-flight ──────────────── */
@keyframes chipLoadingPulse {
    0%   { box-shadow: 0 0 0 0   rgba(255,255,255,0.70),
                       0 8px 28px rgba(212,165,116,0.35); }
    60%  { box-shadow: 0 0 0 5px rgba(255,255,255,0.00),
                       0 8px 28px rgba(212,165,116,0.35); }
    100% { box-shadow: 0 0 0 0   rgba(255,255,255,0.70),
                       0 8px 28px rgba(212,165,116,0.35); }
}

.filter-chip.chip-loading {
    pointer-events: none;
    animation: chipLoadingPulse 1.1s ease-out infinite;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (min-width: 768px) {
    .menu-categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .category-card {
        padding: 16px;
    }

    .category-image-wrapper {
        height: 140px;
    }

    .category-name {
        font-size: 17px;
    }

    .category-emoji {
        font-size: 20px;
    }

    .category-count {
        font-size: 12px;
    }

    .quick-add-btn {
        width: 46px;
        height: 46px;
        font-size: 22px;
    }

    .category-bottom {
        gap: 12px;
    }
}

@media (max-width: 380px) {
    .menu-categories {
        gap: 10px;
        padding: 0 16px;
    }

    .category-card {
        padding: 12px;
        border-radius: 16px;
    }

    .category-image-wrapper {
        height: 100px;
        border-radius: 12px;
    }

    .category-bottom {
        gap: 8px;
    }

    .category-name {
        font-size: 14px;
    }

    .category-emoji {
        font-size: 16px;
    }

    .category-count {
        font-size: 10px;
    }

    .quick-add-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .popular-badge {
        padding: 4px 9px;
        font-size: 10px;
    }

    .menu-categories.list-view .category-card {
        padding: 12px;
    }

    .menu-categories.list-view .category-image-wrapper {
        width: 60px;
        height: 60px;
    }

    .menu-categories.list-view .quick-add-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}
