/* ============================================
   SUNS FIDELITY CARD - MOBILE FIRST CSS
   Ottimizzato per smartphone e tablet
   ============================================ */

:root {
    /* Color Palette - SunsBoards Style */
    --primary-color: #f95919;
    --primary-hover: #ff7a45;
    --primary-dark: #e04810;
    --bg-light: #ffffff;
    --bg-dark: #000000;
    --bg-grey: #f8f9fa;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-white: #ffffff;
    --border-color: #f95919;
    --border-light: #e0e0e0;
    --success-color: #26b050;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    /* Mobile-optimized shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    /* Mobile spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    /* Touch targets (min 44x44px Apple, 48x48px Android) */
    --touch-target: 48px;
    /* Toast colors */
    --toast-success-bg: #d4edda;
    --toast-success-border: #26b050;
    --toast-success-text: #155724;
    --toast-error-bg: #f8d7da;
    --toast-error-border: #dc3545;
    --toast-error-text: #721c24;
    /* Overlay backgrounds */
    --overlay-dark: rgba(0, 0, 0, 0.5);
    --overlay-darker: rgba(0, 0, 0, 0.7);
}

/* ============================================
   RESET & BASE - Mobile First
   ============================================ */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    font-size: 16px;
    /* Base per rem */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

a,
.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    min-height: var(--touch-target);
    display: inline-flex;
    align-items: center;
}

a:hover,
a:active {
    color: var(--primary-hover);
}

/* Focus outlines only for interactive elements */
input:focus-visible,
button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove default focus outline from all elements */
*:focus {
    outline: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 var(--spacing-sm) 0;
    line-height: 1.2;
}

/* Mobile typography */
h1 {
    font-size: 1.75rem;
}

/* 28px */
h2 {
    font-size: 1.5rem;
}

/* 24px */
h3 {
    font-size: 1.25rem;
}

/* 20px */
h4 {
    font-size: 1.125rem;
}

/* 18px */
h5 {
    font-size: 1rem;
}

/* 16px */
h6 {
    font-size: 0.875rem;
}

/* 14px */

/* ============================================
   UTILITIES
   ============================================ */
.text-suns {
    color: var(--primary-color) !important;
}

.bg-suns {
    background-color: var(--primary-color) !important;
}

.bg-light-suns {
    background-color: rgba(249, 89, 25, 0.05) !important;
}

/* Spacing utilities mobile-first */
.p-mobile {
    padding: var(--spacing-sm);
}

.px-mobile {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
}

.py-mobile {
    padding-top: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
}

.m-mobile {
    margin: var(--spacing-sm);
}

.my-mobile {
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

/* ============================================
   BUTTONS - Touch Optimized
   ============================================ */
.btn,
.btn-custom,
.btn-registration-modern {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    /* Prevent double-tap zoom */
}

.btn-custom,
.btn-registration-modern {
    background: var(--bg-dark);
    border: 3px solid var(--text-primary);
    color: var(--text-white);
}

.btn-custom:hover,
.btn-registration-modern:hover {
    background: var(--bg-light);
    border: 3px solid var(--text-primary);
    color: var(--text-primary);
}

.btn-custom:active,
.btn-registration-modern:active {
    transform: scale(0.98);
}

/* Active state for touch feedback */
.btn:active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

/* ============================================
   FORMS - Mobile Optimized
   ============================================ */
input,
select,
textarea,
button {
    font-size: 16px;
    /* Prevent iOS zoom */
}

.form-control-modern,
.form-control-floating {
    min-height: var(--touch-target);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--text-primary);
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

.form-control-modern:focus,
.form-control-floating:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(249, 89, 25, 0.1);
}

/* Override browser autofill styles */
.form-control-modern:-webkit-autofill,
.form-control-floating:-webkit-autofill,
.form-control-modern:-webkit-autofill:hover,
.form-control-floating:-webkit-autofill:hover,
.form-control-modern:-webkit-autofill:focus,
.form-control-floating:-webkit-autofill:focus,
.form-control-modern:-webkit-autofill:active,
.form-control-floating:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    border: 2px solid var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Floating labels - mobile optimized */
.input-wrapper {
    position: relative;
}

.floating-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    /* Removed pointer-events: none to allow label clicks to trigger input via 'for' attribute */
    transition: all var(--transition-normal);
    background: white;
    padding: 0 6px;
    z-index: 1;
    user-select: none;
    cursor: text;
}

.floating-label.focused {
    top: -12px;
    left: 12px;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Input underline removed - using only border for focus indication */

/* ============================================
   CARDS - Mobile First
   ============================================ */
.home-card,
.welcome-card {
    border-radius: 16px;
    border: 2px solid var(--primary-color);
    background: white;
    box-shadow: var(--shadow-md);
    margin: var(--spacing-sm);
    width: calc(100% - var(--spacing-md));
    max-width: 100%;
}

.card-body {
    padding: var(--spacing-md);
}

/* Flip card - mobile optimized */
.flip-card-container {
    width: 100%;
    max-width: 350px;
    height: 220px;
    margin: 0 auto var(--spacing-md);
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card-container.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

/* ============================================
   DATEPICKER HEADER & NAVIGATION
   ============================================ */
.datepicker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    padding: 0.5rem 0;
}

.nav-btn {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:active {
    background: var(--bg-grey);
    transform: scale(0.95);
}

.header-title {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: relative;
    z-index: 10002;
}

.month-select,
.year-select {
    padding: 0.5rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    min-height: var(--touch-target);
    position: relative;
    z-index: 10003;
    touch-action: manipulation;
    -webkit-appearance: menulist;
    appearance: menulist;
}

.weekday-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
}

.weekday {
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    border: 3px solid var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.flip-card-front {
    background: var(--bg-dark);
    color: white;
    padding: var(--spacing-md);
}

.flip-card-back {
    background: white;
    transform: rotateY(180deg);
}

/* ============================================
   DATE PICKER - Mobile Friendly
   ============================================ */
.modern-datepicker {
    position: relative;
    width: 100%;
    z-index: 1;
}

.datepicker-dropdown {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100% - 2rem);
    max-width: 380px;
    background: white;
    border-radius: 16px;
    padding: var(--spacing-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10000 !important;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.datepicker-backdrop {
    position: fixed !important;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999 !important;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day-cell {
    min-height: var(--touch-target);
    border-radius: 8px;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.day-cell:active {
    transform: scale(0.95);
}

.day-cell.selected {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(249, 89, 25, 0.3);
}

/* ============================================
   TOAST NOTIFICATIONS - Mobile
   ============================================ */
.toast-container-custom {
    position: fixed;
    top: env(safe-area-inset-top, 1rem);
    left: 1rem;
    right: 1rem;
    z-index: 9999;
    pointer-events: none;
}

.toast-custom {
    background: white;
    border: 2px solid var(--text-primary);
    border-left: 6px solid var(--primary-color);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    width: 100%;
    transform: translateY(-120%);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.toast-custom.show {
    transform: translateY(0);
}

.toast-custom.success {
    border-left-color: var(--toast-success-border);
    background: var(--toast-success-bg);
}

.toast-custom.error {
    border-left-color: var(--toast-error-border);
    background: var(--toast-error-bg);
}

.toast-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

.toast-custom.success .toast-icon {
    color: var(--toast-success-border);
}

.toast-custom.error .toast-icon {
    color: var(--toast-error-border);
}

.toast-content h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.toast-content p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   MODAL - Mobile Optimized
   ============================================ */
.modal-dialog {
    margin: var(--spacing-sm);
    max-width: calc(100% - var(--spacing-md));
}

.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-body {
    padding: var(--spacing-md);
}

/* ============================================
   LOADING & SPINNERS
   ============================================ */
.loading-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
}

.loading-progress circle {
    fill: none;
    stroke: rgba(249, 89, 25, 0.2);
    stroke-width: 4;
}

.loading-progress circle:last-child {
    stroke: var(--primary-color);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.unselectable {
    -webkit-user-select: none;
    user-select: none;
}

.fade-in-up {
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   DECORATIVE ELEMENTS
   ============================================ */
.decoration {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), transparent);
    opacity: 0.08;
    pointer-events: none;
}

.decoration-top-left {
    top: -50px;
    left: -50px;
}

.decoration-bottom-right {
    bottom: -50px;
    right: -50px;
    background: linear-gradient(315deg, var(--primary-color), transparent);
}

/* ============================================
   RESPONSIVE - Tablet & Desktop
   ============================================ */
@media (min-width: 576px) {
    :root {
        --spacing-sm: 1.5rem;
        --spacing-md: 2rem;
        --spacing-lg: 3rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    .home-card,
    .welcome-card {
        max-width: 480px;
        margin: 0 auto;
    }

    .flip-card-container {
        max-width: 400px;
        height: 250px;
    }

    .toast-container-custom {
        top: 1.5rem;
        left: auto;
        right: 1.5rem;
        max-width: 400px;
    }
}

@media (min-width: 768px) {
    :root {
        --spacing-md: 2.5rem;
        --spacing-lg: 4rem;
    }

    .container {
        padding: var(--spacing-lg);
    }
}

@media (min-width: 992px) {
    h1 {
        font-size: 3rem;
    }

    .home-card,
    .welcome-card {
        max-width: 540px;
    }
}

/* ============================================
   DARK MODE SUPPORT (iOS/Android)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Implementare se necessario */
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --border-width: 3px;
    }

    .btn,
    input,
    select {
        border-width: 3px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .btn,
    .modal,
    .toast {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}

/* ============================================
   iOS SPECIFIC FIXES
   ============================================ */
@supports (-webkit-touch-callout: none) {

    /* iOS Safari specific */
    input[type="date"]::-webkit-calendar-picker-indicator {
        min-height: var(--touch-target);
        min-width: var(--touch-target);
    }

    /* Fix iOS input zoom */
    input,
    select,
    textarea {
        font-size: max(16px, 1rem);
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* GPU acceleration for animations */
.flip-card-inner,
.modal,
.toast-custom {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ============================================
   HOME PAGE SPECIFIC STYLES
   ============================================ */

/* Prevent text selection on labels for better mobile UX */
.floating-label,
.form-check-label {
    -webkit-user-select: none;
    user-select: none;
}

/* Optimize focus states for mobile */
.form-control-floating:focus {
    /* Prevent iOS blue highlight */
    -webkit-tap-highlight-color: transparent;
}

/* Better touch targets for checkbox */
.newsletter-check {
    min-height: 60px;
    padding: 1rem;
}

@media (max-width: 576px) {

    /* Reduce card padding on small screens */
    .home-card .card-body {
        padding: 1.25rem !important;
    }

    /* Optimize logo size */
    .logo-container {
        width: 100px;
        height: 100px;
    }

    .logo-container img {
        max-width: 80px;
        max-height: 80px;
    }

    /* Reduce spacing between form elements */
    .form-floating-group {
        margin-bottom: 1rem !important;
    }

    /* Newsletter checkbox more compact */
    .newsletter-check {
        padding: 0.75rem;
        min-height: auto;
    }

    /* Button slightly smaller on mobile */
    .btn-registration-modern {
        font-size: 0.95rem;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .home-bg {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .welcome-section {
        margin-bottom: 1rem !important;
    }

    .logo-container {
        width: 80px;
        height: 80px;
        padding: 0.5rem !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {

    .floating-label.focused,
    .text-suns {
        font-weight: 800;
    }

    .input-underline {
        height: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .logo-shimmer,
    .btn-shimmer,
    .decoration {
        display: none;
    }

    .fade-in-up {
        animation: none;
        opacity: 1;
        transform: none;
    }
}