/* ============================================
   MOBILE APP FIRST - NATIVE APP STYLE
   Design ottimizzato per mobile app
   ============================================ */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    height: 100%;
    overflow-x: hidden;
    /* Prevent bounce scroll on iOS */
    overscroll-behavior: none;
    /* Smooth scrolling */
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #000000 url("/static/sfondo.png") center/cover no-repeat fixed;
    background-attachment: fixed;
    color: #ffffff;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Mobile app feel */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height */
    overflow-x: hidden;
    position: fixed;
    width: 100%;
    /* Safe area per dispositivi con notch */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    /* Prevent pull-to-refresh */
    overscroll-behavior-y: contain;
}

/* Overlay mobile app style - Elegant Black & Gold */
.overlay {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(20, 15, 5, 0.9) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Safe area padding */
    padding-top: max(env(safe-area-inset-top), 0);
    padding-bottom: max(env(safe-area-inset-bottom), 0);
    /* Mobile app container */
    position: relative;
    /* Elegant gold accent border */
    box-shadow: inset 0 0 100px rgba(255, 215, 0, 0.03);
    /* Estende il velo fino in fondo */
    display: flex;
    flex-direction: column;
}

/* Mobile app content container */
.app-content {
    padding: 15px;
    max-width: 100%;
    margin: 0 auto;
    padding-bottom: max(100px, env(safe-area-inset-bottom) + 80px);
}

/* Titoli - Elegant Black & Gold Style */
h2 {
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0 0 25px 0;
    font-size: 28px;
    line-height: 1.2;
    padding: 0 15px;
    /* Mobile app header style */
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.85) 100%);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    padding-top: max(15px, env(safe-area-inset-top) + 10px);
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 2px solid;
    border-image: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.4), transparent) 1;
    /* Elegant gold text gradient */
    background-clip: text;
    -webkit-background-clip: text;
    color: #ffffff;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.2), 0 2px 10px rgba(0, 0, 0, 0.5);
}

h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 15px 0;
    line-height: 1.3;
    letter-spacing: -0.3px;
}

/* ============================================
   FORM - Mobile App Style
   ============================================ */
form {
    width: 100%;
    margin: 0 auto 20px auto;
    padding: 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-radius: 20px;
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    /* Elegant gold shadow */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                0 0 0 1px rgba(255, 215, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

form::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.05), transparent);
    transition: left 0.6s ease;
}

form:hover::before {
    left: 100%;
}

label {
    font-size: 14px;
    opacity: 0.9;
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 16px 18px; /* Touch target minimo 48px */
    margin-top: 6px;
    margin-bottom: 20px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
    color: #ffffff;
    font-size: 16px; /* Previene zoom automatico su iOS */
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Elegant gold border */
    border: 1.5px solid rgba(255, 215, 0, 0.15);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3),
                0 1px 0 rgba(255, 255, 255, 0.05);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.08) 100%);
    border: 2px solid rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.2),
                0 0 20px rgba(255, 215, 0, 0.15),
                inset 0 2px 8px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 215, 0, 0.1);
    transform: translateY(-1px);
}

input::placeholder,
textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}


/* Select styling */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Textarea */
textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================
   BUTTONS - Mobile App Style
   ============================================ */
button {
    width: 100%;
    min-height: 56px; /* Touch target ottimale per mobile */
    padding: 18px 28px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FFD700 100%);
    background-size: 200% 100%;
    border: none;
    color: #000000;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Elegant gold button style */
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4),
                0 0 0 1px rgba(255, 215, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.3),
                inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    /* Centra il contenuto */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: scale(0.97) translateY(1px);
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

button:hover {
    background-position: 100% 0;
    box-shadow: 0 8px 28px rgba(255, 215, 0, 0.5),
                0 0 0 1px rgba(255, 215, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.4),
                inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

button:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.4),
                0 8px 28px rgba(255, 215, 0, 0.5),
                0 0 0 1px rgba(255, 215, 0, 0.3);
}

/* ============================================
   LOGO
   ============================================ */
.logo-box {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding-left: 10px;
    padding-right: 10px;
    width: 100%;
}

.logo-box img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* ============================================
   MESSAGES
   ============================================ */
.error-message {
    color: #FFD700;
    font-size: 14px;
    margin: -10px 0 15px 0;
    text-align: center;
    line-height: 1.4;
}

.error-message-box {
    width: 100%;
    margin: 0 auto 20px auto;
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.08) 100%);
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 12px;
    color: #FFD700;
    text-align: center;
    font-size: 15px;
    line-height: 1.6;
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.error-message-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #FFD700, #FFA500);
}

.success-message-box {
    width: 100%;
    margin: 0 auto 20px auto;
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.12) 100%);
    border: 2px solid rgba(255, 215, 0, 0.6);
    border-radius: 12px;
    color: #FFD700;
    text-align: center;
    font-size: 15px;
    line-height: 1.6;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
}

.success-message-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #FFD700, #FFA500, #FFD700);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================
   STATS & CARDS
   ============================================ */
.stats-box {
    width: 100%;
    margin: 0 auto 20px auto;
    padding: 24px 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
    border-radius: 16px;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stats-box p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

.stats-box strong {
    font-size: 18px;
    color: #FFD700;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* ============================================
   LINKS
   ============================================ */
a {
    color: #fff;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.2s;
    min-height: 44px; /* Touch target */
    display: inline-flex;
    align-items: center;
}

a:active {
    opacity: 0.7;
}

a:focus {
    outline: 2px solid rgba(255, 215, 0, 0.5);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================
   LOGOUT LINK
   ============================================ */
.logout-link {
    text-align: center;
    margin-top: 30px;
    padding-bottom: env(safe-area-inset-bottom);
}

.logout-link a {
    color: #fff;
    text-decoration: none;
    opacity: 0.7;
    font-size: 14px;
    padding: 12px 20px;
    display: inline-block;
}

.logout-link a:active {
    opacity: 1;
}

/* ============================================
   TABLES (se necessario)
   ============================================ */
table {
    width: 100%;
    margin: 0 auto;
    border-collapse: collapse;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

th, td {
    padding: 12px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

th {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.08) 100%);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    color: #FFD700;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
}

td {
    font-size: 13px;
}

/* ============================================
   LOGIN FORM
   ============================================ */
.login-form {
    width: 100%;
    margin: 0 auto;
    padding: 20px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ============================================
   SUCCESS PAGE
   ============================================ */
.success-content {
    text-align: center;
    width: 100%;
    margin: 0 auto;
    padding: 20px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.success-content p {
    font-size: 16px;
    opacity: 0.9;
    margin-top: 15px;
    line-height: 1.6;
}

/* ============================================
   TABLET STYLES (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
    body {
        position: relative;
        height: auto;
        min-height: 100vh;
    }

    .overlay {
        padding: 0;
        position: relative;
        min-height: auto;
    }
    
    .app-content {
        padding: 30px;
        max-width: 600px;
    }
    
    h2 {
        position: relative;
        background: transparent;
        backdrop-filter: none;
        padding: 0 0 20px 0;
        margin-bottom: 30px;
    }

    h2 {
        font-size: 32px;
        margin-bottom: 30px;
        letter-spacing: 1px;
    }

    h3 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    form {
        max-width: 500px;
        padding: 30px;
    }

    .logo-box {
        margin-bottom: 25px;
        padding-left: 20px;
        padding-right: 20px;
    }

    .logo-box img {
        max-width: 100%;
    }

    .success-content {
        max-width: 600px;
        padding: 40px;
    }

    .success-content p {
        font-size: 18px;
        margin-top: 20px;
    }

    table {
        width: 90%;
        max-width: 1200px;
        font-size: 16px;
    }

    th, td {
        padding: 15px 12px;
    }

    th {
        font-size: 14px;
    }

    td {
        font-size: 15px;
    }

    .login-form {
        max-width: 450px;
        padding: 30px;
    }

    .error-message-box,
    .success-message-box {
        max-width: 500px;
    }

    .stats-box {
        max-width: 90%;
        max-width: 1200px;
        padding: 30px;
    }

    .stats-box p {
        font-size: 16px;
    }

    .stats-box strong {
        font-size: 18px;
    }

    .logout-link a:hover {
        opacity: 1;
        text-decoration: underline;
    }

    button:hover {
        background: #fff;
        color: #000;
    }
}

/* ============================================
   LARGE DESKTOP (min-width: 1024px)
   ============================================ */
@media (min-width: 1024px) {
    .overlay {
        padding: 50px 40px;
    }

    form {
        max-width: 600px;
        padding: 40px;
    }

    .login-form {
        max-width: 500px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   FOOTER
   ============================================ */
.app-footer {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(20, 15, 5, 0.9) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 2px solid;
    border-image: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.3), transparent) 1;
    padding: 18px 20px;
    margin-top: auto;
    text-align: center;
    position: relative;
    z-index: 5;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
    width: 100%;
}

.app-footer p {
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.8px;
}

.app-footer .footer-name {
    color: #FFD700;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
    opacity: 1;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.app-footer .footer-name:hover {
    color: #FFA500;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
