:root {
    --primary-color: #314d64; /* GCFE Blue-ish Gray */
    --accent-color: #0078d4;
    --bg-dark: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Prevent text size adjustment on iOS */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

html * {
    box-sizing: border-box;
}

/* Fix for iOS Safari date input rendering issues */
@supports (-webkit-touch-callout: none) {
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"] {
        min-height: 44px !important;
        height: 44px !important;
        line-height: 20px !important;
        padding: 12px 16px !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    /* Prevent horizontal scroll on mobile */
    width: 100%;
    max-width: 100vw;
    position: relative;
    /* Prevent any element from causing horizontal scroll */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.95)), url('/static/img/hero_bg.png');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

.container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    /* Prevent horizontal overflow */
    min-width: 0;
    overflow-x: hidden;
}

/* Glassmorphism Card */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: fadeIn 0.8s ease-out;
    width: 100%;
    box-sizing: border-box;
    /* Prevent horizontal overflow */
    min-width: 0;
    overflow-x: hidden;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
}

.form-title {
    margin-bottom: 20px;
}

.description {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.btn {
    display: inline-block;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: #005a9e;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 120, 212, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Form Styles */
.form-group {
    margin-bottom: 30px;
}

.label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    font-size: 1.125rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.input, .textarea, .select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    transition: border-color 0.3s;
    min-height: 44px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

/* Specific rules for date inputs - fix iOS Safari issues */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    min-height: 44px;
    height: 44px;
    padding: 12px 16px;
    line-height: 1.5;
    display: block;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

/* Fix for iOS Safari date picker */
input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    height: 20px;
    width: 20px;
    margin-left: 8px;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    font-size: 1.05rem;
    transition: background 0.2s;
}

.radio-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.hidden {
    display: none;
}

/* Status icons */
.status-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.status-icon.success {
    color: #10b981;
}

.status-icon.error {
    color: #ef4444;
}

/* Center aligned cards */
.card-center {
    text-align: center;
}

/* Required asterisk */
.required-asterisk {
    color: #ef4444;
}

/* Full width button */
.btn-full-width {
    width: 100%;
}

/* User info badge */
.user-info {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
}

.user-icon {
    font-size: 1.5rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-details strong {
    color: var(--text-main);
    font-size: 1rem;
}

.user-details span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Location input with current position button */
.location-input-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.location-input-container .input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.btn-map-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(0, 120, 212, 0.2);
    border: 1px solid rgba(0, 120, 212, 0.4);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-sizing: border-box;
    /* Allow text to wrap on very small screens */
    min-width: 0;
    flex-shrink: 1;
}

.btn-map-selector:hover {
    background: rgba(0, 120, 212, 0.3);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.btn-map-selector span {
    font-size: 1.1rem;
}

/* Messaggio errore geolocalizzazione (sotto la label del campo luogo) */
.location-error {
    margin-top: 8px;
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 0.95rem;
    font-weight: 500;
}

.location-error[hidden] {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    /* Container and Card spacing */
    .container {
        margin: 20px auto;
        padding: 15px;
        max-width: 100vw;
        width: 100%;
    }

    .card {
        padding: 24px;
        border-radius: 16px;
        max-width: 100%;
        width: 100%;
    }

    /* Typography */
    h1 {
        font-size: 2rem;
        margin-bottom: 16px;
    }
    
    h2, .form-title {
        font-size: 1.75rem;
        margin-bottom: 16px;
    }

    .description {
        font-size: 0.95rem;
        margin-bottom: 24px;
    }

    /* Buttons - Touch targets */
    .btn {
        padding: 16px 24px;
        min-height: 44px;
        font-size: 1.05rem;
    }

    .btn-group {
        gap: 12px;
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Form elements */
    .form-group {
        margin-bottom: 24px;
    }

    .input, .textarea, .select {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 14px 16px;
        min-height: 44px;
        height: auto;
    }
    
    /* Force date inputs to have proper height on mobile */
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"] {
        min-height: 44px;
        height: 44px;
        padding: 14px 16px;
        font-size: 16px;
        line-height: 1.5;
        -webkit-appearance: none;
        appearance: none;
        display: block;
        box-sizing: border-box;
    }

    .textarea {
        min-height: 100px;
    }

    .label {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    /* Radio buttons - Touch targets */
    .radio-option {
        padding: 14px;
        min-height: 44px;
    }

    .radio-option input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
    }

    /* User badge */
    .user-badge {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .user-icon {
        font-size: 1.3rem;
    }

    .user-details strong {
        font-size: 0.95rem;
    }

    .user-details span {
        font-size: 0.8rem;
    }

    /* Location input */
    .location-input-container {
        flex-direction: column;
        gap: 12px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Prevent horizontal overflow */
    body {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    html {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .card, .container {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .btn-map-selector {
        width: 100%;
        justify-content: center;
        min-height: 44px;
        padding: 14px 16px;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Ensure all inputs and form elements respect container width */
    .input, .textarea, .select {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Prevent any element from overflowing */
    * {
        max-width: 100%;
    }
    
    img, video, iframe {
        max-width: 100%;
        height: auto;
    }

}

@media (max-width: 480px) {
    /* Further spacing reductions */
    .container {
        margin: 15px auto;
        padding: 12px;
        max-width: 100vw;
        width: 100%;
    }

    .card {
        padding: 20px;
        border-radius: 12px;
        max-width: 100%;
        width: 100%;
    }

    /* Typography */
    h1 {
        font-size: 1.75rem;
        margin-bottom: 14px;
    }
    
    h2, .form-title {
        font-size: 1.5rem;
        margin-bottom: 14px;
    }

    .description {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    /* Buttons */
    .btn {
        padding: 14px 20px;
        font-size: 1rem;
    }

    .btn-group {
        gap: 10px;
    }

    /* Form */
    .form-group {
        margin-bottom: 20px;
    }

    .input, .textarea, .select {
        padding: 12px 14px;
        min-height: 44px;
    }
    
    /* Ensure date inputs maintain height on very small screens */
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"] {
        min-height: 44px;
        height: 44px;
        padding: 12px 14px;
        font-size: 16px;
    }

    .label {
        font-size: 1rem;
    }

    .help-text {
        font-size: 0.8rem;
    }

    /* User badge */
    .user-info {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .user-badge {
        padding: 12px 14px;
    }

}

@media (max-width: 360px) {
    /* Minimal spacing for very small devices */
    .container {
        margin: 10px auto;
        padding: 10px;
        max-width: 100vw;
        width: 100%;
    }

    .card {
        padding: 16px;
        border-radius: 12px;
        max-width: 100%;
        width: 100%;
    }

    /* Typography */
    h1 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }
    
    h2, .form-title {
        font-size: 1.25rem;
        margin-bottom: 12px;
    }

    .description {
        font-size: 0.85rem;
        margin-bottom: 18px;
    }

    /* Buttons */
    .btn {
        padding: 12px 18px;
        font-size: 0.95rem;
    }

    /* Form */
    .form-group {
        margin-bottom: 18px;
    }

    .input, .textarea, .select {
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
    }
    
    /* Critical: Force date inputs to proper height on smallest screens */
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"] {
        min-height: 44px;
        height: 44px;
        padding: 12px;
        font-size: 16px;
        line-height: 1.5;
        -webkit-appearance: none;
        appearance: none;
        display: block;
        box-sizing: border-box;
    }

    .label {
        font-size: 0.95rem;
    }

    /* Radio */
    .radio-option {
        padding: 12px;
    }

    /* User badge */
    .user-badge {
        padding: 10px 12px;
    }

    .user-icon {
        font-size: 1.2rem;
    }

    .user-details strong {
        font-size: 0.9rem;
    }

    .user-details span {
        font-size: 0.75rem;
    }

    /* Status icons */
    .status-icon {
        font-size: 2.5rem;
        margin-bottom: 14px;
    }
    
    /* Ensure no horizontal scroll */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    img, video, iframe {
        max-width: 100%;
        height: auto;
    }
    
    /* Additional overflow prevention */
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
        width: 100%;
    }
    
    .container, .card {
        overflow-x: hidden;
    }
    
    /* Ensure text doesn't overflow */
    h1, h2, h3, .label, .form-title {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
}
