/**
 * Main CSS file for PHP-based Albaruska Localizador
 * Imports all component styles in proper order
 */

/* Base styles - variables, reset, and typography */
@import url('./base/variables.css');
@import url('./base/reset.css');
@import url('./base/typography.css');

/* Layout styles */
@import url('./layout/main.css');
@import url('./layout/header.css');
@import url('./layout/footer.css');

/* Component styles */
@import url('./components/search-form.css');
@import url('./components/results-grid.css');
@import url('./components/loading.css');
@import url('./components/error-handling.css');
@import url('./components/breadcrumbs.css');
@import url('./components/front-page-layout.css');

/* Utility styles */
@import url('./utilities/accessibility.css');
@import url('./utilities/responsive.css');

/* Global base styles for the application */
body {
    font-family: var(--font-family);
    line-height: var(--line-height-normal);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    background-color: var(--bg-white);
}

/* Ensure proper box-sizing for all elements */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Remove default margins and paddings from common elements */
h1, h2, h3, h4, h5, h6,
p, ul, ol, li,
form, fieldset, legend,
input, textarea, select, button {
    margin: 0;
    padding: 0;
}

/* Improve button and input styling */
button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Remove default button styles */
button {
    background: none;
    border: none;
    cursor: pointer;
}

/* Improve focus visibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: var(--z-tooltip);
}

.skip-link:focus {
    top: 6px;
}

.logo-container{
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
.section-title{
    padding: 140px 0px 30px 0px!important;
}
.section-title h1{
    font-size: 32px!important;
    font-weight: 700!important;
    color: #67574E!important;
    text-align: center!important;
}

/* Container utility class */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

/* Utility classes for common patterns */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

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

.loading * {
    cursor: wait !important;
}

/* Error state utilities */
.error {
    color: var(--error);
}

.success {
    color: var(--success);
}

.warning {
    color: var(--warning);
}

.info {
    color: var(--info);
}

/* Responsive utilities */
.mobile-only {
    display: block;
}

.tablet-up {
    display: none;
}

.desktop-up {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
    
    .tablet-up {
        display: block;
    }
}

@media (min-width: 1024px) {
    .desktop-up {
        display: block;
    }
}


/*
 JavaScript Enhancement Styles */

/* Form validation states */
.search-input.valid {
    border-color: var(--success, #28a745);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.94-.94 1.38 1.38 3.68-3.68.94.94-4.62 4.62z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.search-input.invalid {
    border-color: var(--error, #dc3545);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 2.4 2.4m0-2.4L5.8 7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Input error messages */
.input-error {
    display: none;
    color: var(--error, #dc3545);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    padding: 0.25rem 0;
}

.input-error:not(:empty) {
    display: block;
}

/* Geolocation button states */
.geolocation-btn.success {
    background-color: var(--success, #28a745);
    color: white;
    border-color: var(--success, #28a745);
}

.geolocation-btn.success .geolocation-icon {
    color: white;
}

/* Loading button states */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Geolocation loading indicator */
.geo-loading {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary, #67574E);
}

.geo-loading.active {
    display: inline-flex;
}

.geo-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary, #67574E);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Search loading states */
.search-loading {
    display: none;
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.search-loading.active {
    display: block;
}

.loading-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.loading-progress {
    height: 100%;
    background: var(--primary, #67574E);
    border-radius: 2px;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; transform: translateX(-100%); }
    50% { width: 100%; transform: translateX(0%); }
    100% { width: 100%; transform: translateX(100%); }
}

.loading-message {
    margin: 0;
    font-size: 0.9rem;
    color: #6c757d;
}

/* Main loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary, #67574E);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loading-text {
    margin: 0;
    color: var(--primary, #67574E);
    font-weight: 500;
}

/* Error message styling */
.error-message {
    display: none;
    padding: 0.75rem 1rem;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.error-message.active {
    display: block;
}

.error-icon {
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* Success message styling */
.success-message {
    display: none;
    padding: 0.75rem 1rem;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.success-message.active {
    display: block;
}

/* Accessibility improvements for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .spinner,
    .loading-progress,
    .geo-spinner,
    .btn-loading::after {
        animation: none;
    }
    
    .loading-progress {
        width: 100%;
        transform: none;
    }
    
    /* Provide alternative loading indication */
    .loading-progress::after {
        content: 'Carregando...';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 0.75rem;
        color: white;
        font-weight: bold;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-input.valid {
        border-color: #000;
        background-color: #e6ffe6;
    }
    
    .search-input.invalid {
        border-color: #000;
        background-color: #ffe6e6;
    }
    
    .loading-overlay {
        background: rgba(255, 255, 255, 0.95);
        border: 2px solid #000;
    }
    
    .error-message {
        border-color: #000;
        background-color: #fff;
        color: #000;
    }
    
    .success-message {
        border-color: #000;
        background-color: #fff;
        color: #000;
    }
}

/* Focus management for loading states */
.btn-loading:focus {
    outline: none;
}

.btn-loading:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Ensure proper stacking context */
.search-form {
    position: relative;
    z-index: 1;
    background: #fefefe;
}

.loading-overlay {
    z-index: 9999;
}

/* Mobile-specific enhancements */
@media (max-width: 767px) {
    .geo-loading {
        font-size: 0.8rem;
    }
    
    .loading-overlay .loading-spinner {
        padding: 1rem;
    }
    
    .error-message,
    .success-message {
        font-size: 0.9rem;
    }
}

/* ============================================================================
   SCROLL ANIMATIONS - Fade in on scroll
   ============================================================================ */

.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms var(--ease-smooth), transform 600ms var(--ease-smooth);
}

.animate-on-scroll.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Respects reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .animate-on-scroll {
        opacity: 1;
        transform: none;
        transition: none;
    }
}