/*!
 * Looply UI Framework - Versione Completa 2026
 * Design coordinato per Safe Areas, Bottom Sheets e Match System.
 */

/* --- 1. VARIABILI E RESET --- */
:root {
    --primary: #4e73df; 
    --bg-color: #f4f7f9;
    --card-bg: #ffffff;
    --text-main: #1a1a1a;
    --text-muted: #666;
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-top: var(--safe-top);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; 
    overflow-y: auto;
    width: 100%;
}

/* --- 2. ANIMAZIONI --- */
@keyframes pulse-calendar {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.pulse-calendar { display: inline-block; animation: pulse-calendar 2s infinite ease-in-out; font-size: 1.4rem; }

@keyframes pulse-install {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(78, 115, 223, 0.4); }
    70% { transform: scale(1.03); box-shadow: 0 0 0 10px rgba(78, 115, 223, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(78, 115, 223, 0); }
}
.pulse-install { animation: pulse-install 2s infinite; background: var(--primary); border: 2px solid white; }

@keyframes sweep { 
    0% { transform: rotate(-10deg); } 
    50% { transform: rotate(20deg) translateX(5px); } 
    100% { transform: rotate(-10deg); } 
}

@keyframes pop-in { 
    0% { transform: scale(0.8); opacity: 0; } 
    100% { transform: scale(1); opacity: 1; } 
}

/* --- 3. INPUT E FORM --- */
input { 
    user-select: text !important; 
    -webkit-user-select: text !important; 
    border: 1.5px solid #eee; 
    padding: 16px; 
    border-radius: 14px; 
    width: 100%; 
    font-size: 16px !important; 
    margin-bottom: 12px; 
    transition: all 0.2s; 
    background: #fff; 
    outline: none; 
}
input:focus { border-color: var(--primary); }

#input-otp { 
    text-align: center; 
    font-size: 2.2rem; 
    font-weight: 900; 
    letter-spacing: 10px; 
    border: 2px solid var(--primary); 
    color: var(--primary); 
    padding-left: 26px; 
}

/* --- 4. SCHERMATE E LOGO --- */
.screen { display: none; max-width: 500px; margin: 0 auto; width: 100%; flex-direction: column; padding: 25px; min-height: 100dvh; justify-content: flex-start; }
.logo-text { font-size: 3.2rem; margin: 0; color: var(--primary); font-weight: 900; letter-spacing: -2px; transition: color 0.3s ease; }

/* --- 5. DASHBOARD E GIORNI --- */
#dashboard-screen { padding-bottom: 140px; }

.day-group {
    margin-bottom: 14px;
    border-radius: 20px;
    overflow: hidden;
    background-color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.day-group > div:first-child {
    position: relative;
    z-index: 2;
}

.day-accordion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 18px 22px;
    background-color: var(--primary); 
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 750;
    text-transform: capitalize;
    transition: background-color 0.3s ease, transform 0.1s;
}
.day-accordion:active { opacity: 0.95; transform: scale(0.99); }

.accordion-label { flex-grow: 1; text-align: left; pointer-events: none; }
.accordion-arrow { font-size: 0.8rem; margin-left: 10px; transition: transform 0.3s ease; pointer-events: none; }
.arrow-rotated { transform: rotate(180deg); }

.day-accordion .match-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    z-index: 999;
    pointer-events: auto !important;
}

.match-count-badge { 
    position: absolute; 
    top: -5px; 
    right: -7px; 
    background-color: #ff3b30; 
    color: white; 
    font-size: 0.7rem; 
    font-weight: 900; 
    padding: 2px 6px; 
    border-radius: 10px; 
    border: 2px solid white; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); 
    z-index: 2; 
}

.slots-grid {
    display: none; 
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px;
    background: white;
    border-top: 1px solid #f5f5f5;
    clear: both;
}

.slot-btn, .reg-day-btn, .set-day-btn { padding: 12px 5px; border-radius: 12px; border: 1.5px solid #eee; background: white; font-weight: 600; font-size: 0.85rem; cursor: pointer; transition: all 0.2s; }
.slot-btn.selected, .reg-day-btn.selected, .set-day-btn.selected { background: var(--primary) !important; color: white !important; border-color: var(--primary) !important; }

/* --- 6. TRIGGER IMPOSTAZIONI (INGRANAGGIO SVG) --- */
.settings-trigger {
    background: #ffffff;
    border: 1px solid #eee;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.settings-trigger:active {
    transform: scale(0.92);
    background-color: #f8f9fa;
    border-color: #ddd;
}

.icon-gear {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s;
}

.settings-trigger:hover .icon-gear {
    transform: rotate(45deg);
    color: var(--primary);
}

/* --- 7. POPUP MATCH E SUGGERIMENTI --- */
#match-modal {
    display: none; 
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}
#match-modal.active, #match-modal.open { display: flex !important; opacity: 1; }

.match-suggestions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 18px;
    border: 1px solid #eee;
}

.suggestion-icon {
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 8px;
    border-radius: 12px;
    line-height: 1;
}

.suggestion-icon.active {
    background: var(--primary) !important;
    transform: scale(1.25);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* --- 8. TINDER CARDS SYSTEM --- */
card-stack {
    position: relative;
    height: 420px; 
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    perspective: 1000px; 
}

.match-card {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    border-radius: 25px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease;
    cursor: pointer;
    transform-origin: bottom center;
    will-change: transform, opacity;
}

.match-card.swipe-out {
    transform: translateX(150%) rotate(25deg) !important;
    opacity: 0;
    pointer-events: none;
}

.card-badge { padding: 6px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 800; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.card-name { font-size: 1.6rem; margin: 5px 0; color: var(--text-main); font-weight: 850; }
.card-info { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 15px; }
.card-suggestions-row { display: flex; gap: 12px; margin: 10px 0 20px 0; padding: 10px; background: #f9f9f9; border-radius: 15px; }
.card-footer { width: 100%; margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.ora-display { font-size: 0.85rem; color: var(--text-muted); }
.ora-display strong { color: var(--primary); font-size: 1rem; }

.btn-wa-card {
    background: #25D366; 
    color: white;
    border: none;
    padding: 14px;
    border-radius: 18px;
    font-weight: 800;
    font-size: 0.95rem;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
}
.swipe-hint { margin-top: 10px; font-size: 0.7rem; color: #ccc; font-weight: 600; text-transform: uppercase; }

/* --- 9. CARDS AMICI NEL MATCH --- */
.match-friend-card { background: #f8f9fa; padding: 15px; border-radius: 20px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; border: 1px solid #eee; }
.vip-match { border: 2px solid #FFD700 !important; background: #fffdf0 !important; }
.match-friend-info { text-align: left; flex: 1; }
.match-friend-name { font-weight: 700; font-size: 1.05rem; color: var(--text-main); display: block; margin-bottom: 4px; }

/* --- 10. BOTTOM SHEET E OVERLAY --- */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 9400; }
.bottom-sheet { 
    position: fixed; bottom: 0; left: 0; width: 100%; background: white; 
    border-radius: 35px 35px 0 0; transform: translateY(100%); 
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); z-index: 9500; 
    padding: 20px 30px; padding-bottom: calc(30px + var(--safe-bottom)); 
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15); max-height: 85vh; overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.handle-bar { width: 50px; height: 6px; background: #e0e0e0; border-radius: 10px; margin: 0 auto 25px auto; cursor: pointer; }

/* --- 11. BOTTONI FISSI E FOOTER --- */
.btn-primary { background: var(--primary); color: white; border: none; padding: 18px; border-radius: 22px; font-size: 1rem; font-weight: 800; width: 100%; cursor: pointer; transition: background-color 0.3s ease; }
.save-area { width: 100%; margin-top: 10px; padding: 0 25px; }
#btn-match { background: var(--primary); width: 100%; border: none; padding: 18px; border-radius: 22px; color: white; font-weight: 800; font-size: 1rem; box-shadow: 0 4px 15px rgba(0,0,0,0.1); cursor: pointer; transition: background-color 0.3s ease; }

/* --- 12. PALLINI COLORI (FIX SELEZIONE TEMA) --- */
.color-dot { 
    width: 42px; 
    height: 42px; 
    border-radius: 50%; 
    cursor: pointer; 
    border: 3px solid white; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); 
    transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease; 
    opacity: 0.6; 
}
.color-dot.active { 
    opacity: 1; 
    transform: scale(1.2); 
    border-color: #1a1a1a !important; 
}

/* --- 13. SYSTEM TOAST & POPUP PULIZIA --- */
#limit-toast {
    position: fixed;
    bottom: 120px; 
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #ff3b30;
    color: white;
    padding: 12px 25px;
    border-radius: 30px;
    font-weight: 600;
    z-index: 10001;
    box-shadow: 0 10px 20px rgba(255, 59, 48, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}
#limit-toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

.clean-popup-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; z-index: 20000; padding: 20px; }
.clean-popup-content { background: white; padding: 35px 25px; border-radius: 35px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.1); max-width: 350px; border: 1px solid #f0f0f0; }
.clean-icon { font-size: 4rem; margin-bottom: 20px; display: inline-block; animation: sweep 1.5s ease-in-out infinite; }
.clean-popup-content h2 { margin: 0 0 10px 0; color: var(--text-main); font-weight: 850; }
.clean-popup-content p { color: #666; line-height: 1.5; margin-bottom: 25px; }
#btn-clean-close { background: linear-gradient(135deg, #4ed3df 0%, #a259ff 50%, #ff6b9a 100%); color: white; border: none; padding: 18px; border-radius: 20px; width: 100%; font-weight: 800; cursor: pointer; box-shadow: 0 10px 20px rgba(162, 89, 255, 0.2); }

#welcome-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center; z-index: 10000; backdrop-filter: blur(8px); }
#welcome-overlay.open { display: flex; }
.welcome-content { background: white; padding: 30px; border-radius: 30px; text-align: center; width: 85%; max-width: 350px; }

/* --- 14. LOGIN POLICIES --- */
.auth-policies { margin: 30px auto; display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 320px; align-items: center; }
.policy-check { display: flex !important; flex-direction: row !important; align-items: center !important; padding: 14px 20px; border-radius: 50px; background: white; border: 1.5px solid #eee; cursor: pointer; width: 100%; transition: all 0.3s ease; }
.policy-check input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 22px !important; height: 22px !important; border: 2px solid #ddd !important; border-radius: 50% !important; margin: 0 12px 0 0 !important; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: white !important; }
.policy-check input[type="checkbox"]:checked { background: linear-gradient(135deg, #4ed3df 0%, #a259ff 50%, #ff6b9a 100%) !important; border-color: transparent !important; }
.policy-check input[type="checkbox"]:checked::after { content: "✓"; color: white; font-size: 12px; font-weight: bold; }
.policy-check span { font-size: 0.9rem; color: #666; font-weight: 600; line-height: 1.2; }

/* --- 15. ORA CHIP ED EMOJI SELEZIONATI --- */
.sugg-icon.selected-emoji { transform: scale(1.4); filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); background: rgba(78, 115, 223, 0.1); border-radius: 10px; }
.ora-input-card { appearance: none; -webkit-appearance: none; color: var(--primary); font-family: inherit; font-weight: 800; cursor: pointer; padding: 5px 10px; border-radius: 10px; background: #f0f4ff; border: none; text-align: center; width: auto; min-width: 80px; transition: color 0.3s; }

/* --- 16. MINI CALENDARIO LOOPLY SETTIMANALE --- */
.match-summary-container { margin: 20px 0; padding: 0 5px; width: 100%; clear: both; display: block !important; }
.mini-calendar { display: flex; gap: 10px; overflow-x: auto; padding: 5px 2px 15px 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.mini-calendar::-webkit-scrollbar { display: none; }
.cal-day { flex: 0 0 60px; background: white; padding: 12px 8px; border-radius: 20px; text-align: center; border: 1.5px solid #eee; transition: all 0.3s ease; }
.cal-day-name { font-size: 0.7rem; font-weight: 800; color: #bbb; margin-bottom: 6px; text-transform: uppercase; }

.cal-day.is-confirmed {
    border: 2px solid #25D366 !important; 
    background: #f1fff5 !important;
    animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.cal-day.is-confirmed .cal-day-name { color: #128C7E !important; }
.cal-match-icons { display: flex; justify-content: center; align-items: center; min-height: 24px; font-size: 1.3rem; line-height: 1; }
.match-dot-small { width: 6px; height: 6px; border-radius: 50%; background: #e0e0e0; }
