/* ========================================
   Real Estate Calculator V2 - Main Styles
   ======================================== */

/* Base Styles & Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #333 0%, #444 50%, #333 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* Container & Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 32px 64px rgba(0,0,0,0.12), 0 0 0 1px rgba(255,255,255,0.1);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
}
/* Header Section */
.header {
    background: linear-gradient(135deg, #333 0%, #444 50%, #333 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Form Container & Sections */
.form-container {
    padding: 40px;
}

.form-section {
    background: rgba(248,249,250,0.6);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 28px;
    border: 1px solid rgba(255,255,255,0.2);    transition: all 0.3s ease;
    animation: slideInUp 0.6s ease-out;
    isolation: isolate;
}

.form-section:hover {
    background: rgba(248,249,250,0.8);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

/* Form Elements */
.form-group {
    margin-bottom: 25px;
    transition: all 0.3s ease;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.required {
    color: #e74c3c;
}

input, select, textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15), 0 4px 12px rgba(102, 126, 234, 0.1);
    background: rgba(255,255,255,0.95);
    transform: translateY(-1px);
}
/* Utility Classes */
.hidden {
    display: none;
}

/* Animated Sections */
#year-group, #energy-section {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#year-group:not(.hidden), #energy-section:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* Searchable Dropdown Component */
.searchable-dropdown {
    position: relative;
    width: 100%;
    z-index: 1;
}

.searchable-dropdown.open {
    z-index: 9999;
}

.form-section {
    position: relative;
    overflow: visible;
}
.form-container {
    overflow: visible;
}

.form-section:has(.searchable-dropdown.open) {
    z-index: 10000;
    position: relative;
}

.searchable-dropdown .dropdown-input {
    width: 100%;
    padding: 14px 28px 14px 28px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.searchable-dropdown .dropdown-input:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15), 0 4px 12px rgba(102, 126, 234, 0.1);
    background: rgba(255,255,255,0.95);
    transform: translateY(-1px);
    cursor: text;
}
.searchable-dropdown .dropdown-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.searchable-dropdown.open .dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.searchable-dropdown .dropdown-arrow svg {
    width: 100%;
    height: 100%;
    fill: #6c757d;
}

.searchable-dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    border: 2px solid #e1e8ed;
    border-top: none;    border-radius: 0 0 12px 12px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1);
}

.searchable-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.searchable-dropdown .dropdown-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    font-weight: 500;
}

.searchable-dropdown .dropdown-option:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateX(4px);
}
.searchable-dropdown .dropdown-option.selected {
    background: rgba(102, 126, 234, 0.15);
    color: #333;
    font-weight: 600;
}

.searchable-dropdown .dropdown-option.hidden {
    display: none;
}

.searchable-dropdown .no-results {
    padding: 16px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Scrollbar Styling */
.searchable-dropdown .dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.searchable-dropdown .dropdown-menu::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
}

.searchable-dropdown .dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}
.searchable-dropdown .dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Hide original select when using searchable dropdown */
.searchable-dropdown + select {
    display: none;
}

/* Enhanced focus states */
.searchable-dropdown .dropdown-input:focus + .dropdown-arrow svg {
    fill: #333;
}

/* Required field styling for dropdowns */
.form-group:has(.searchable-dropdown) label .required {
    color: #e74c3c;
}

/* Button Styles */
.btn {
    background: linear-gradient(135deg, #333 0%, #444 50%, #333 100%);
    color: white;
    border: none;
    padding: 18px 32px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);    width: 100%;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(102, 126, 234, 0.3), 0 8px 16px rgba(0,0,0,0.1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s;
}

.btn:hover::before {
    left: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
/* Loading State */
.loading {
    display: none;
    text-align: center;
    margin: 24px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading.show {
    display: block;
    opacity: 1;
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: conic-gradient(#333, #444, #333);
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
    position: relative;
}

.spinner::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;    background: white;
    border-radius: 50%;
}

/* Results Section */
.result {
    margin-top: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 5px solid #28a745;
    display: none;
}

.result.show {
    display: block;
}

.result h3 {
    color: #28a745;
    margin-bottom: 15px;
}

/* Price Display */
.price-range {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid #dee2e6;
}
.price-range h4 {
    color: #333;
    margin-bottom: 10px;
}

.price-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #333;
}

.price-per-sqm {
    font-size: 1rem;
    color: #666;
    margin-top: 5px;
}

.price-average {
    background: linear-gradient(135deg, #333 0%, #444 50%, #333 100%);
    color: white;
    padding: 32px;
    border-radius: 20px;
    margin: 24px 0;
    text-align: center;
    box-shadow: 0 16px 40px rgba(51, 51, 51, 0.4), 0 8px 16px rgba(0,0,0,0.1);
    border: 3px solid rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
}
.price-average::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
}

.price-average h4 {
    color: white;
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.price-average .average-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.price-average .average-per-sqm {
    font-size: 1.2rem;
    opacity: 0.9;
}
.price-range-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.price-range.min {
    border-left: 4px solid #28a745;
}

.price-range.max {
    border-left: 4px solid #dc3545;
}

.price-range.min h4 {
    color: #28a745;
}

.price-range.max h4 {
    color: #dc3545;
}

.surface-info {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}
/* Error State */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 5px solid #dc3545;
    display: none;
}

.error.show {
    display: block;
}

/* Info Box */
.info-box {
    background: #d1ecf1;
    color: #0c5460;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #17a2b8;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes shimmer {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

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

/* Media Queries */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .price-range-container {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .form-container {
        padding: 25px;
    }
}
/* Pulsante Editor */
.editor-button-container {
    text-align: center;
    margin-bottom: 25px;
    animation: fadeIn 0.6s ease-out 0.3s both;
}

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

.btn-editor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #333 0%, #444 50%, #333 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-editor:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.btn-editor:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.btn-editor svg {
    width: 20px;
    height: 20px;
}

/* Responsive per pulsante editor */
@media (max-width: 768px) {
    .editor-button-container {
        margin-bottom: 20px;
    }
    
    .btn-editor {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .btn-editor svg {
        width: 18px;
        height: 18px;
    }
}