/**
 * Digital Menu - Frontend Styles
 * Inspired by elegant restaurant menus
 */

/* Menu Container */
.dm-menu {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    color: #1a1a1a;
    line-height: 1.5;
}

/* Category */
.dm-menu-category {
    margin-bottom: 40px;
}

.dm-category-name {
    background: #1a1a1a;
    color: #ffffff;
    padding: 12px 20px;
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

/* Collapsible Category */
.dm-category-name.dm-collapsible {
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.dm-category-name.dm-collapsible:hover {
    background: #333;
}

/* Toggle Icon */
.dm-toggle-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    position: relative;
    flex-shrink: 0;
}

.dm-toggle-icon::before,
.dm-toggle-icon::after {
    content: '';
    position: absolute;
    background: currentColor;
    transition: transform 0.3s ease;
}

/* Linea orizzontale */
.dm-toggle-icon::before {
    width: 12px;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

/* Linea verticale (diventa + quando collapsed) */
.dm-toggle-icon::after {
    width: 2px;
    height: 12px;
    left: 50%;
    top: 0;
    transform: translateX(-50%) scaleY(0);
}

/* Quando collapsed, mostra il + */
.dm-collapsed .dm-toggle-icon::after {
    transform: translateX(-50%) scaleY(1);
}

/* Stato expanded - mostra - */
.dm-expanded .dm-toggle-icon::after {
    transform: translateX(-50%) scaleY(0);
}

/* Items Container */
.dm-items {
    padding: 0 10px;
}

/* Single Item */
.dm-item {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px dotted #e0e0e0;
}

.dm-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.dm-item-image-wrap {
    margin-bottom: 10px;
}

.dm-item-image {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
}

/* Item Header (Name + Price) */
.dm-item-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.dm-item-name {
    font-weight: 600;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Allergens inline */
.dm-item-allergens {
    font-weight: 400;
    font-size: 12px;
    color: #666;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: middle;
}

.dm-allergen-inline {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.dm-allergen-has-icon {
    cursor: help;
}

.dm-allergen-icon-inline {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: middle;
}

.dm-allergen-text {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* Tooltip nativo migliorato con CSS */
.dm-allergen-has-icon[title] {
    position: relative;
}

.dm-allergen-has-icon::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 100;
    margin-bottom: 5px;
}

.dm-allergen-has-icon::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 100;
}

.dm-allergen-has-icon:hover::after,
.dm-allergen-has-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Dotted line between name and price */
.dm-item-dots {
    flex: 1;
    border-bottom: 1px dotted #ccc;
    margin: 0 8px;
    min-width: 20px;
    position: relative;
    top: -4px;
}

/* Prices */
.dm-item-prices {
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
    flex-shrink: 0;
}

.dm-price-label {
    font-size: 12px;
    font-weight: 400;
    color: #666;
}

.dm-price-value {
    font-weight: 600;
}

.dm-price-separator {
    color: #999;
    margin: 0 2px;
}

/* Item Description */
.dm-item-description {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #666;
    font-style: italic;
    line-height: 1.4;
}

/* Allergens Legend */
.dm-allergens-legend {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 2px solid #1a1a1a;
}

.dm-legend-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 15px 0;
}

.dm-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px 25px;
}

.dm-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #444;
}

.dm-allergen-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Empty & Error states */
.dm-empty,
.dm-error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.dm-error {
    color: #c0392b;
}

/* Responsive */
@media (max-width: 600px) {
    .dm-menu {
        padding: 15px;
    }

    .dm-category-name {
        font-size: 14px;
        padding: 10px 15px;
        letter-spacing: 1px;
    }

    .dm-item-header {
        flex-wrap: wrap;
    }

    .dm-item-name {
        font-size: 14px;
        width: 100%;
        flex: 1 1 100%;
        line-height: 1.4;
        margin-bottom: 4px;
    }

    .dm-item-dots {
        display: none;
    }

    .dm-item-prices {
        width: 100%;
        margin-top: 2px;
        text-align: right;
    }

    .dm-item-description {
        font-size: 12px;
    }

    .dm-item-image {
        max-width: 100%;
    }

    .dm-legend-items {
        gap: 10px 15px;
    }

    .dm-legend-item {
        font-size: 12px;
    }

    .dm-allergen-icon-inline {
        width: 16px;
        height: 16px;
    }

    .dm-allergen-text {
        font-size: 10px;
    }

    /* Su mobile il tooltip appare sopra */
    .dm-allergen-has-icon::after {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* ==========================================
   INDICE CATEGORIE - Pulsante e Popup
   ========================================== */

/* Pulsante Floating */
.dm-index-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dm-index-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.dm-index-btn:active {
    transform: translateY(0);
}

.dm-index-icon {
    width: 18px;
    height: 18px;
}

.dm-index-label {
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Popup Overlay */
.dm-index-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
}

.dm-index-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.dm-index-open .dm-index-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* Panel laterale */
.dm-index-panel {
    position: absolute;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: #fff;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.dm-index-open .dm-index-panel {
    right: 0;
}

/* Header del popup */
.dm-index-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #1a1a1a;
    color: #fff;
}

.dm-index-title {
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.dm-index-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.dm-index-close:hover {
    opacity: 1;
}

/* Navigazione */
.dm-index-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.dm-index-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dm-index-list li {
    margin: 0;
}

.dm-index-link {
    display: block;
    padding: 15px 20px;
    color: #1a1a1a;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.2s ease, padding-left 0.2s ease;
}

.dm-index-link:hover {
    background: #f9f9f9;
    padding-left: 25px;
    color: #1a1a1a;
}

.dm-index-list li:last-child .dm-index-link {
    border-bottom: none;
}

/* Responsive per mobile */
@media (max-width: 600px) {
    .dm-index-btn {
        bottom: 15px;
        right: 15px;
        padding: 10px 16px;
        font-size: 13px;
    }

    .dm-index-icon {
        width: 16px;
        height: 16px;
    }

    .dm-index-panel {
        width: 280px;
    }

    .dm-index-link {
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* Print styles */
@media print {
    .dm-menu {
        max-width: 100%;
        padding: 0;
    }

    .dm-category-name {
        background: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .dm-allergens-legend {
        page-break-inside: avoid;
    }

    /* Nascondi elementi interattivi in stampa */
    .dm-index-btn,
    .dm-index-popup,
    .dm-toggle-icon {
        display: none !important;
    }

    .dm-category-name.dm-collapsible {
        cursor: default;
    }

    /* Espandi tutte le categorie in stampa */
    .dm-items {
        display: block !important;
    }
}
