/* 
 * Menu Grid (Apple-Style) 
 * Modern Navigation with Icon Circles and Popups
 */

.dut-menu-grid-wrapper {
    width: 100%;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
}

.dut-menu-grid {
    display: grid;
    gap: var(--dut-mg-gap, 20px);
    width: auto;
    max-width: 100%;
    justify-content: center;
}

/* Item Wrapper */
.dut-mg-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--dut-mg-label-color, #1d1d1f);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
}

.dut-mg-item:hover {
    transform: scale(1.05);
}

/* Icon Wrapper for Badge Overlay v4 */
.dut-mg-icon-wrapper {
    position: relative;
    width: fit-content;
    margin: 0 auto;
}

/* Icon Box */
.dut-mg-icon-box {
    width: var(--dut-mg-icon-size-pc, 60px);
    height: var(--dut-mg-icon-size-pc, 60px);
    background: var(--dut-mg-icon-bg, #f5f5f7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

@media (max-width: 767px) {
    .dut-mg-icon-box {
        width: var(--dut-mg-icon-size-mb, 50px);
        height: var(--dut-mg-icon-size-mb, 50px);
    }
}

.dut-mg-item:hover .dut-mg-icon-box {
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.dut-mg-icon-box img {
    width: var(--dut-mg-inner-size-pc, 24px);
    height: var(--dut-mg-inner-size-pc, 24px);
    object-fit: contain;
    padding: 0;
}

@media (max-width: 767px) {
    .dut-mg-icon-box img {
        width: var(--dut-mg-inner-size-mb, 20px);
        height: var(--dut-mg-inner-size-mb, 20px);
    }
}

.dut-mg-icon-box i, 
.dut-mg-icon-box .dashicons {
    font-size: var(--dut-mg-inner-size-pc, 24px);
    width: var(--dut-mg-inner-size-pc, 24px);
    height: var(--dut-mg-inner-size-pc, 24px);
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 767px) {
    .dut-mg-icon-box i, 
    .dut-mg-icon-box .dashicons {
        font-size: var(--dut-mg-inner-size-mb, 20px);
        width: var(--dut-mg-inner-size-mb, 20px);
        height: var(--dut-mg-inner-size-mb, 20px);
    }
}

/* Label */
.dut-mg-label {
    font-size: var(--dut-mg-label-size-pc, 13px);
    font-weight: var(--dut-mg-label-weight, 500);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    word-break: break-word;
}

@media (max-width: 767px) {
    .dut-mg-label {
        font-size: var(--dut-mg-label-size-mb, 11px);
    }
}

/* Badge (Mới, HOT...) - Pill Shape Overlay v4 */
.dut-mg-badge {
    position: absolute;
    top: -2px;
    right: -8px; /* Adjusted to overlay better on the circle */
    background: var(--dut-mg-badge-bg, #4c6ef5);
    color: var(--dut-mg-badge-color, #fff);
    /* Support gradient text if provided as background */
    background-image: var(--dut-mg-badge-color, none);
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: none;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    line-height: 1;
    white-space: nowrap;
    pointer-events: none; /* Let clicks pass through to the link */
}

/* Swipe Handle - Hidden by default, shown on mobile v68 */
.dut-mg-swipe-handle {
    display: none;
}

/* Popup / Modal */
.dut-mg-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999999;
}

.dut-mg-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 767px) {
    .dut-mg-modal.active {
        align-items: flex-end; /* Drawer style */
    }
}

.dut-mg-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dut-mg-modal-content {
    position: relative;
    width: 90%;
    max-width: 850px; /* Widened for better PC view */
    max-height: 70vh; /* Reduced for a "tidy" look as requested */
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    animation: dutPopupAnim 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dutPopupAnim {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (max-width: 767px) {
    .dut-mg-modal-content {
        width: 100%;
        max-width: 100%;
        height: 85vh;
        border-radius: 30px 30px 0 0;
        animation: dutDrawerAnim 0.4s cubic-bezier(0.32, 0.72, 0, 1);
        /* Swipe Support v68 */
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        will-change: transform;
    }

    /* Swipe Settings v68 */
    .dut-mg-modal.active.is-swiping .dut-mg-modal-overlay {
        backdrop-filter: blur(4px); /* Reduce blur when swiping away */
    }

    .dut-mg-modal.active.is-swiping .dut-mg-modal-content {
        transition: none !important; /* Direct control during touchmove */
    }

    /* Swipe Handle Styles v68 */
    .dut-mg-swipe-handle {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px 0 4px; /* Reduced v68.1 */
        background: #fff;
        cursor: grab;
        z-index: 100;
        border-radius: 30px 30px 0 0;
    }

    .dut-mg-modal-header {
        padding: 10px 20px 15px !important; /* Reduced top padding v68.1 */
    }

    .dut-mg-modal-header h3 {
        font-size: 16px;
    }

    .dut-mg-handle-bar {
        width: 36px;
        height: 4px;
        background: #e0e0e0;
        border-radius: 10px;
        margin-bottom: 6px;
        transition: transform 0.15s ease-out;
    }

    .dut-mg-swipe-indicator {
        font-size: 11px;
        color: #94a3b8;
        font-weight: 600;
        opacity: 0;
        transition: opacity 0.2s;
    }

    .is-swiping .dut-mg-swipe-indicator {
        opacity: 1;
    }

    .threshold-met .dut-mg-swipe-indicator {
        color: #ff3b30;
    }
}

@keyframes dutDrawerAnim {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.dut-mg-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dut-mg-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1d1d1f;
}

.dut-mg-modal-close {
    background: #f5f5f7;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.dut-mg-modal-close:hover {
    background: #eef2f3;
}

.dut-mg-modal-grid {
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 columns on large screens */
    gap: 25px;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .dut-mg-modal-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 20px;
    }
}

@media (max-width: 900px) {
    .dut-mg-modal-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .dut-mg-modal-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        padding: 20px;
    }
}
