/* CSS Forbedringer for Lighthouse Score og Autocomplete */
/* Fil: css/lighthouse-improvements.css */

/* ================================
   AUTOCOMPLETE STYLING IMPROVEMENTS
   ================================ */

/* Bedre styling for autocomplete dropdown */
input[autocomplete]::-webkit-credentials-auto-fill-button {
    visibility: hidden;
    pointer-events: none;
    position: absolute;
    right: 0;
}

/* Forbedre autofill styling for bedre brukeropplevelse */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0f1419 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    caret-color: #ffffff !important;
    border-color: #00E676 !important;
}

/* Firefox autofill */
input:-moz-autofill {
    background-color: #0f1419 !important;
    color: #ffffff !important;
    border-color: #00E676 !important;
}

/* Spesifikk styling for kontakt modal */
#kontaktModal input:-webkit-autofill,
#kontaktModal input:-webkit-autofill:hover,
#kontaktModal input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px #1a2332 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: #00E676 !important;
}

/* Newsletter form autofill */
#newsletterForm input:-webkit-autofill,
#newsletterForm input:-webkit-autofill:hover,
#newsletterForm input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px #0f1419 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: #00E676 !important;
}

/* Login modal autofill */
#loginModal input:-webkit-autofill,
#loginModal input:-webkit-autofill:hover,
#loginModal input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px #1a2332 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: #00E676 !important;
}

/* ================================
   FORM VALIDATION IMPROVEMENTS
   ================================ */

/* Visual feedback for required fields */
input:required:invalid {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.1);
}

input:required:valid {
    border-color: #00E676;
    box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.1);
}

/* Focus states for better accessibility */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #00E676;
    box-shadow: 0 0 0 3px rgba(0, 230, 118, 0.1);
}

/* ================================
   PERFORMANCE OPTIMIZATIONS
   ================================ */

/* Reduser layout shifts */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 230, 118, 0.1);
    border-left-color: #00E676;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Forbedre font loading */
@font-face {
    font-family: 'System';
    src: local('system-ui'), local('-apple-system'), local('BlinkMacSystemFont');
    font-display: swap;
}

/* Optimalisere bilder */
img {
    max-width: 100%;
    height: auto;
}

.header-logo {
    width: auto;
    height: 80px; /* Matches global header sizing to keep navigation alignment consistent */
}

/* ================================
   ACCESSIBILITY IMPROVEMENTS
   ================================ */

/* Bedre focus indicators */
button:focus,
a:focus {
    outline: 2px solid #00E676;
    outline-offset: 2px;
}

/* Bedre kontrast for tekst */
.disclaimer,
.form-assurance p {
    color: #b0bec5;
    font-size: 14px;
    line-height: 1.5;
}

/* Hover effects for bedre interaktivitet */
.btn:hover {
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* ================================
   GA4 LOADING OPTIMIZATIONS
   ================================ */

/* Skjul consent banner til den er klar */
.cookie-banner {
    opacity: 0;
    transform: translateY(-100%);
    transition: all 0.3s ease;
}

.cookie-banner.show {
    opacity: 1;
    transform: translateY(0);
}

/* Loading states for form submissions */
.form-loading {
    position: relative;
    pointer-events: none;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================
   MOBILE OPTIMIZATIONS
   ================================ */

@media (max-width: 768px) {
    /* Bedre mobile form styling */
    input,
    select,
    textarea {
        font-size: 16px; /* Forhindrer zoom på iOS */
        padding: 14px 16px;
    }
    
    /* Mobile autocomplete improvements */
    input:-webkit-autofill {
        font-size: 16px !important;
    }
    
    /* Bedre mobile button sizing */
    .btn {
        min-height: 44px; /* iOS anbefalt touch target */
        padding: 12px 24px;
    }
    
    /* Mobile form spacing */
    .form-group {
        margin-bottom: 20px;
    }
    
    /* Mobile modal improvements */
    .modal-container {
        margin: 10px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
}

/* ================================
   REDUCED MOTION SUPPORT
   ================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
    }
    
    .cookie-banner.show {
        transition: none;
    }
}

/* ================================
   DARK MODE SUPPORT
   ================================ */

@media (prefers-color-scheme: dark) {
    /* Sørg for at autofill fungerer i dark mode */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 30px #0f1419 inset !important;
        -webkit-text-fill-color: #ffffff !important;
    }
}

/* ================================
   HIGH CONTRAST SUPPORT
   ================================ */

@media (prefers-contrast: high) {
    /* Økt kontrast for bedre tilgjengelighet */
    input,
    select,
    textarea {
        border-width: 2px;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .btn-primary {
        background: #ffffff;
        color: #000000;
    }
    
    .btn-secondary {
        background: #000000;
        color: #ffffff;
    }
}

/* ================================
   COOKIE CONSENT IMPROVEMENTS
   ================================ */

/* Bedre styling for cookie consent */
.cookie-banner {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.cookie-banner-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.cookie-banner-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .cookie-banner-actions {
        flex-direction: column;
    }
    
    .cookie-banner-actions button {
        width: 100%;
    }
}

/* ================================
   NEWSLETTER FORM IMPROVEMENTS
   ================================ */

.newsletter-form {
    position: relative;
}

.newsletter-form.success {
    background: rgba(0, 230, 118, 0.05);
    border-radius: 8px;
    padding: 20px;
}

.newsletter-submit-btn {
    transition: all 0.3s ease;
    min-width: 160px; /* Forhindrer layout shift */
}

.newsletter-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ================================
   ROI CALCULATOR IMPROVEMENTS
   ================================ */

.roi-tooltip {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.4;
    z-index: 10000;
}

.roi-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid rgba(4, 28, 44, 0.95);
}

/* Slider improvements */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #00E676;
    cursor: pointer;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #00E676;
    cursor: pointer;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}