/* ========================================= */
/* CSS CUSTOM PROPERTIES - DARK MODE */
/* ========================================= */

:root {
    /* Light Mode Colors */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --bg-neutral: #f5f5f5;
    --text-primary: #111111;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --accent: #000000;
    --accent-hover: #374151;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --shadow: rgba(0, 0, 0, 0.05);
    /* Brand Orange */
    --orange-primary: #f97316;
    --orange-hover: #ea580c;
    --orange-light: #fff7ed;
    --orange-dark: #c2410c;
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #262626;
    --bg-neutral: #171717;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-tertiary: #718096;
    --border-light: #404040;
    --border-medium: #525252;
    --accent: #ffffff;
    --accent-hover: #d1d5db;
    --card-bg: #1f1f1f;
    --input-bg: #262626;
    --shadow: rgba(255, 255, 255, 0.03);
    /* Brand Orange (slightly brighter for dark mode) */
    --orange-primary: #fb923c;
    --orange-hover: #f97316;
    --orange-light: #431407;
    --orange-dark: #fdba74;
}

/* ========================================= */
/* BASE STYLES */
/* ========================================= */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: default;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, .mono-font {
    font-family: 'Space Grotesk', sans-serif;
}

/* ========================================= */
/* ANIMATIONS */
/* ========================================= */

/* Cursor blinking */
.cursor {
    display: inline-block;
    width: 3px;
    background-color: #000;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Fade Up Animation */
.fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}


/* ========================================= */
/* UTILITY CLASSES */
/* ========================================= */

/* Delay utilities for staggered animations */
.fade-delay-100 {
    transition-delay: 100ms;
}

.fade-delay-200 {
    transition-delay: 200ms;
}

.fade-delay-1000 {
    transition-delay: 1s;
    animation-fill-mode: forwards;
}

.ping-delay-200 {
    animation-delay: 0.2s;
}

.ping-delay-400 {
    animation-delay: 0.4s;
}

.ping-delay-600 {
    animation-delay: 0.6s;
}

/* ========================================= */
/* COMPONENTS */
/* ========================================= */

/* Custom selection color */
::selection {
    background: #000;
    color: #fff;
}

/* Menu overlay */
.menu-overlay {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Service Card Hover */
.service-arrow {
    transition: transform 0.3s ease;
}

.service-card:hover .service-arrow {
    transform: translateX(10px);
}

/* FAQ Accordion */
.faq-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.faq-item.active .faq-content {
    max-height: 500px;
    transition: max-height 0.5s ease-in;
}

.faq-item.active .faq-icon {
    transform: rotate(45deg);
}

.faq-icon {
    transition: transform 0.3s ease;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid #000;
    outline-offset: 4px;
}

/* ✓ OTTIMIZZATO: Transizioni specifiche invece di "all" */
button, a {
    transition: background-color 0.3s ease, color 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

input, textarea {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}


/* Loading state */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ========================================= */
/* X-RAY MODE */
/* ========================================= */

body.xray-mode * {
    outline: 1px solid rgba(255, 0, 0, 0.3) !important;
    background: rgba(0, 0, 0, 0.02) !important;
    position: relative !important;
}

body.xray-mode *::before {
    content: '<' attr(data-tag) '>';
    position: absolute;
    top: -1px;
    left: 0;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    background: #ff0000;
    color: white;
    padding: 1px 4px;
    line-height: 1.2;
    z-index: 10000;
    pointer-events: none;
    white-space: nowrap;
}

body.xray-mode img::after {
    content: 'ALT: ' attr(alt);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 255, 0.8);
    color: white;
    padding: 4px;
    line-height: 1.2;
    z-index: 10000;
    pointer-events: none;
}

/* Element-specific tag colors in X-Ray mode */
body.xray-mode h1::before { background: #9333ea; }
body.xray-mode h2::before { background: #7c3aed; }
body.xray-mode h3::before { background: #8b5cf6; }
body.xray-mode section::before { background: #10b981; }
body.xray-mode article::before { background: #059669; }
body.xray-mode header::before { background: #3b82f6; }
body.xray-mode footer::before { background: #1d4ed8; }
body.xray-mode nav::before { background: #06b6d4; }
body.xray-mode button::before { background: #f59e0b; }
body.xray-mode a::before { background: #ef4444; }
body.xray-mode form::before { background: #ec4899; }
body.xray-mode input::before,
body.xray-mode textarea::before { background: #d946ef; }

/* X-Ray Toggle Button */
#xray-toggle {
    transition: background-color 0.3s ease, transform 0.3s ease;
}

#xray-toggle:hover {
    transform: scale(1.05);
}

body.xray-mode #xray-toggle {
    background: #ff0000 !important;
}

/* Link attributes display in X-Ray mode */
body.xray-mode a[target="_blank"]::after {
    content: ' [target="_blank"]';
    font-size: 9px;
    color: #fbbf24;
    font-family: 'Courier New', monospace;
}

body.xray-mode a[rel]::after {
    content: ' [rel="' attr(rel) '"]';
    font-size: 9px;
    color: #34d399;
    font-family: 'Courier New', monospace;
}

/* Highlight broken links in X-Ray mode */
body.xray-mode a[href="#"] {
    outline: 2px solid #ef4444 !important;
    animation: pulse-xray 2s infinite;
}

@keyframes pulse-xray {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================= */
/* DARK MODE - TAILWIND OVERRIDES */
/* ========================================= */

/* Override Tailwind classes for dark mode */
[data-theme="dark"] .bg-white {
    background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .bg-neutral-50,
[data-theme="dark"] .bg-gray-50 {
    background-color: var(--bg-neutral) !important;
}

[data-theme="dark"] .bg-neutral-800 {
    background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .text-gray-600 {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-gray-400,
[data-theme="dark"] .text-gray-500 {
    color: var(--text-tertiary) !important;
}

[data-theme="dark"] .text-black,
[data-theme="dark"] .text-gray-900 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-100 {
    border-color: var(--border-light) !important;
}

[data-theme="dark"] .border-black {
    border-color: var(--border-medium) !important;
}

/* Dark mode for inputs and forms */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-tertiary);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--accent);
    outline-color: var(--accent);
}

/* Keep menu overlay pure black in dark mode */
[data-theme="dark"] .menu-overlay {
    background-color: #000000 !important;
}

/* Hamburger menu lines visibility in dark mode */
[data-theme="dark"] #menu-btn > div {
    background-color: #ffffff !important;
    opacity: 0.9;
}

[data-theme="dark"] #menu-btn:hover > div {
    opacity: 1;
}

/* Card backgrounds in dark mode */
[data-theme="dark"] .bg-gray-200 {
    background-color: var(--card-bg) !important;
}

/* Hover states in dark mode */
[data-theme="dark"] .hover\:bg-gray-800:hover {
    background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .hover\:text-gray-600:hover {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .hover\:border-black:hover {
    border-color: var(--accent) !important;
}

/* ========================================= */
/* DARK MODE - TOGGLE BUTTONS */
/* ========================================= */

/* Theme Toggle Button */
.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Language Toggle Button */
.lang-toggle {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lang-toggle:hover {
    background: var(--accent);
    color: var(--bg-primary);
}

.lang-toggle:active {
    transform: scale(0.95);
}

/* ========================================= */
/* DARK MODE - X-RAY COMPATIBILITY */
/* ========================================= */

/* Ensure X-Ray mode remains visible in dark mode */
body.xray-mode[data-theme="dark"] * {
    /* Keep X-Ray outlines visible */
    outline-color: rgba(255, 100, 100, 0.6) !important;
}

body.xray-mode[data-theme="dark"] *::before {
    /* Brighter tag labels for dark background */
    filter: brightness(1.2);
}

/* ========================================= */
/* BRAND ORANGE ACCENTS */
/* ========================================= */

/* Orange text utilities */
.text-orange {
    color: var(--orange-primary) !important;
}

.text-orange-dark {
    color: var(--orange-dark) !important;
}

/* Orange background utilities */
.bg-orange {
    background-color: var(--orange-primary) !important;
}

.bg-orange-light {
    background-color: var(--orange-light) !important;
}

/* Orange border utilities */
.border-orange {
    border-color: var(--orange-primary) !important;
}

/* Orange hover effects */
.hover\:text-orange:hover {
    color: var(--orange-primary) !important;
}

.hover\:bg-orange:hover {
    background-color: var(--orange-primary) !important;
    color: white !important;
}

.hover\:border-orange:hover {
    border-color: var(--orange-primary) !important;
}

/* Orange CTA button */
.btn-orange {
    background-color: var(--orange-primary);
    color: white;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.btn-orange:hover {
    background-color: var(--orange-hover);
    transform: translateY(-1px);
}

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

/* Orange selection */
::selection {
    background: var(--orange-primary);
    color: #fff;
}

/* ========================================= */
/* MOBILE OPTIMIZATIONS */
/* ========================================= */

/* Hide X-Ray button on mobile */
@media (max-width: 640px) {
    #xray-toggle {
        display: none !important;
    }

    /* Reduce header padding on mobile */
    header {
        padding: 1rem 1rem !important;
    }

    /* Reduce gap between header items */
    header .flex.items-center.gap-3 {
        gap: 0.5rem !important;
    }

    /* Smaller theme toggle on mobile */
    .theme-toggle {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    /* Smaller language toggle on mobile */
    .lang-toggle {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Logo text smaller on very small screens */
    header a[aria-label="Torna alla home"],
    header a[aria-label="Go to homepage"] {
        font-size: 0.875rem !important;
    }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    header a[aria-label="Torna alla home"],
    header a[aria-label="Go to homepage"] {
        font-size: 0.75rem !important;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }

    .lang-toggle {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* Mobile Footer Navigation */
@media (max-width: 640px) {
    /* Vertical layout for footer nav */
    footer nav[aria-label="Footer navigation"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
        text-align: center;
    }

    footer nav[aria-label="Footer navigation"] span[aria-hidden="true"] {
        display: none !important;
    }

    footer nav[aria-label="Footer navigation"] a {
        display: block;
        padding: 0.5rem 0;
    }

    /* Reduce footer padding */
    footer .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Lighthouse scores - smaller on mobile */
    footer .w-20 {
        width: 3.5rem !important;
        height: 3.5rem !important;
    }

    footer .w-20 .text-2xl {
        font-size: 1.25rem !important;
    }

    /* Hide ping animations on mobile (battery saver) */
    footer .animate-ping {
        animation: none !important;
        display: none !important;
    }
}

/* Mobile Timeline Improvements */
@media (max-width: 768px) {
    /* Timeline content padding */
    #algoritmo .relative.flex > div:first-child {
        padding-left: 2rem !important;
    }

    /* Timeline step content */
    #algoritmo .w-full.md\:w-1\/2.pr-0 {
        padding-left: 2.5rem !important;
    }
}

/* Mobile Trust Signals (Audit Page) */
@media (max-width: 640px) {
    /* Stack trust signals vertically */
    .mt-8.flex.items-center.justify-center.gap-6 {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* Audit form padding */
    #audit-form {
        padding: 0 !important;
    }

    /* Loading overlay padding */
    #loading-overlay > div {
        padding: 1.5rem !important;
        margin: 1rem !important;
        max-width: calc(100vw - 2rem) !important;
    }

    /* Results grid on mobile */
    #results-section .grid {
        gap: 1rem !important;
    }
}

/* Mobile Consulting Section */
@media (max-width: 768px) {
    /* Remove border-right on mobile */
    .border-r.border-gray-200 {
        border-right: none !important;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 1rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Better Touch Targets */
@media (max-width: 768px) {
    /* Minimum 44px touch targets */
    button,
    a[class*="btn"],
    input[type="submit"],
    input[type="checkbox"],
    .faq-item {
        min-height: 44px;
    }

    /* Checkbox wrapper */
    input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
    }

    /* FAQ items touch-friendly */
    .faq-item {
        padding: 1.25rem !important;
    }

    /* Menu items larger touch area */
    #menu-overlay nav a {
        padding: 0.75rem 1rem;
        font-size: 1.75rem !important;
    }
}

/* Mobile Service Cards */
@media (max-width: 768px) {
    /* Remove transform on best seller card */
    .service-card.transform.md\:-translate-y-4 {
        transform: none !important;
    }

    /* Service card padding */
    .service-card {
        padding: 1.5rem !important;
    }
}

/* Mobile Hero Improvements */
@media (max-width: 640px) {
    /* Hero text sizes */
    .text-5xl {
        font-size: 2.25rem !important;
    }

    .text-4xl {
        font-size: 1.875rem !important;
    }

    /* Hero buttons stack vertically */
    .mt-16.flex.justify-center.space-x-4 {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .mt-16.flex.justify-center.space-x-4 > * {
        margin-left: 0 !important;
        width: 100% !important;
        text-align: center !important;
    }

    /* Reduce section padding */
    .py-24 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* Mobile Testimonials */
@media (max-width: 640px) {
    .bg-neutral-800.p-8 {
        padding: 1.25rem !important;
    }
}

/* Ensure text is readable on mobile */
@media (max-width: 640px) {
    body {
        font-size: 16px; /* Prevent iOS zoom on input focus */
    }

    input, textarea, select {
        font-size: 16px !important; /* Prevent iOS zoom */
    }

    /* Minimum readable font size */
    .text-\[10px\] {
        font-size: 11px !important;
    }

    .text-\[11px\] {
        font-size: 12px !important;
    }
}

/* Landscape mobile improvements */
@media (max-height: 500px) and (orientation: landscape) {
    .h-screen, .min-h-screen {
        min-height: auto !important;
        height: auto !important;
        padding-top: 4rem !important;
        padding-bottom: 2rem !important;
    }

    #menu-overlay nav a {
        font-size: 1.25rem !important;
        padding: 0.5rem;
    }

    #menu-overlay nav {
        gap: 0.5rem !important;
    }
}
