/**
 * Frontend Styles for Maca Menu List
 */

/* Category Buttons */
.maca-category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
    justify-content: center;
}

/* Horizontal layout (default) */
.maca-category-buttons.layout-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
}

/* Vertical layout */
.maca-category-buttons.layout-vertical {
    flex-direction: column;
    flex-wrap: nowrap;
}

.maca-category-buttons.layout-vertical .maca-category-button {
    width: 100%;
}

/* Fit Width layout */
.maca-category-buttons.layout-fit-width {
    flex-direction: row;
    flex-wrap: wrap;
}

.maca-category-buttons.layout-fit-width .maca-category-button {
    flex: 1 1 calc(33.333% - 10px);
    min-width: 150px;
}

/* Fit Height layout */
.maca-category-buttons.layout-fit-height {
    flex-direction: column;
    flex-wrap: nowrap;
    height: 100%;
}

.maca-category-buttons.layout-fit-height .maca-category-button {
    flex: 1;
    min-height: 80px;
}

.maca-category-button {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    background: #fff;
    border: 2px solid #0073aa;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 200px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    text-align: left;
}

.maca-category-button:has(.maca-category-thumbnail) {
    padding: 0 25px 0 0;
    min-height: 50px;
    justify-content: flex-start;
}

.maca-category-button:not(:has(.maca-category-thumbnail)) {
    justify-content: center;
    text-align: center;
}

.maca-category-button:hover {
    background: #0073aa;
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.maca-category-button:active {
    transform: translateY(-1px);
}

.maca-category-button.active {
    background: #0073aa;
    border-color: #005177;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.3);
}

.maca-category-button:hover .maca-category-name,
.maca-category-button.active .maca-category-name {
    color: #fff;
}

.maca-category-button-content {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 50px;
}

.maca-category-thumbnail {
    width: 100px;
    height: 50px;
    object-fit: cover;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 6px 0 0 6px;
    flex-shrink: 0;
}

.maca-category-button:has(.maca-category-thumbnail) .maca-category-name {
    margin-left: 110px;
}

.maca-category-thumbnail-placeholder {
    width: 100px;
    height: 50px;
    background: #f0f0f0;
    border-radius: 6px 0 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: absolute;
    left: 0;
    top: 0;
}

.maca-category-thumbnail-placeholder .dashicons {
    font-size: 24px;
    color: #666;
}

.maca-category-name {
    color: #0073aa;
    font-weight: 600;
    transition: color 0.3s ease;
}

/* Menu Display */
.maca-menu-display {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 200px;
}

.maca-menu-placeholder {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
}

.maca-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* Menu Container */
.maca-menu-container {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.maca-menu-title {
    margin: 0 0 15px 0;
    font-size: 24px;
    color: #333;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 10px;
}

.maca-menu-schedule-note {
    margin: 0 0 12px;
    padding: 8px 12px;
    background: #fff8e5;
    border-left: 3px solid #dba617;
    color: #5c4a00;
    font-size: 14px;
    line-height: 1.4;
}

/* Menu Image */
.maca-menu-image {
    text-align: center;
    margin: 15px 0;
}

.maca-menu-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* PDF Display */
.maca-pdf-embed {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.maca-pdf-embed iframe {
    display: block;
    border: none;
    width: 100%;
    min-height: 500px;
}

.maca-pdf-fallback {
    margin: 10px 0 0;
    text-align: center;
    font-size: 13px;
}

.maca-pdf-fallback a {
    color: #0073aa;
}

.maca-pdf-js-view .maca-menu-title {
    margin: 0 0 12px;
}

.maca-pdf-js-pages {
    overflow-x: hidden;
}

.maca-pdf-js-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* Categories List */
.maca-categories-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.maca-category-item {
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.maca-category-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.maca-category-title {
    font-size: 20px;
    margin: 0 0 15px 0;
    color: #333;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 10px;
}

.maca-no-menu {
    color: #666;
    font-style: italic;
    padding: 20px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .maca-category-buttons {
        flex-direction: column;
    }
    
    .maca-category-button {
        width: 100%;
        min-width: auto;
    }
    
    .maca-categories-list {
        grid-template-columns: 1fr;
    }
    
    .maca-pdf-embed iframe {
        height: 70vh;
        min-height: 400px;
    }

    .maca-menu-popup {
        width: 95%;
        max-height: 95%;
    }

    .maca-popup-content {
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .maca-pdf-js-pages canvas {
        max-width: 100%;
        height: auto !important;
    }
}

@media (max-width: 480px) {
    .maca-category-button:not(:has(.maca-category-thumbnail)) {
        padding: 12px 20px;
    }

    .maca-category-button:has(.maca-category-thumbnail) {
        padding: 0 20px 0 0;
    }
    
    .maca-category-name {
        font-size: 14px;
    }
    
    .maca-menu-title {
        font-size: 20px;
    }
}

/* Only inline mode uses the area below buttons */
.maca-menulist-wrap[data-display-mode='popup'] .maca-menu-display,
.maca-menulist-wrap[data-display-mode='new_page'] .maca-menu-display {
    display: none !important;
}

.maca-menulist-wrap[data-display-mode='new_page'] .maca-menu-popup,
.maca-menulist-wrap[data-display-mode='new_page'] .maca-popup-overlay {
    display: none !important;
}

/* Close button (website inline / popup – same style as QR menu) */
.maca-menu-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.maca-menu-close:hover,
.maca-menu-close:focus {
    background: #005177;
    color: #fff;
    outline: none;
}

.maca-menu-close--popup {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
    font-size: 20px;
    z-index: 2;
}

/* New-tab / standalone menu viewer */
.maca-menu-close--viewer {
    display: flex !important;
}

.maca-menu-popup .maca-popup-content {
    padding-top: 48px;
}

/* Popup Modal Styles */
.maca-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.maca-popup-overlay.active {
    display: block;
    opacity: 1;
}

.maca-menu-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    max-width: 90%;
    max-height: 90%;
    width: 800px;
    display: none;
    opacity: 0;
    transition: all 0.3s ease;
}

.maca-menu-popup.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.maca-popup-content {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.maca-popup-content .maca-menu-container {
    box-shadow: none;
    border: none;
    border-radius: 0;
}

.maca-popup-content .maca-menu-title {
    margin-top: 0;
}

@media (max-width: 768px) {
    .maca-menu-popup {
        width: 95%;
        max-height: 95%;
    }
    
    .maca-popup-content {
        padding: 15px;
    }
}
