/* ==================== Global Reset ====================
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==================== Base Typography and Colors ====================
   ============================================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #333;
    background: #fff;
}

/* ==================== Application Layout ====================
   ============================================================ */
.app-container {
    display: flex;
    height: 100vh;
}

/* ==================== Side Panel ====================
   ============================================================ */
.side-panel {
    width: 320px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: #1e3a8a;
    color: white;
    padding: 20px;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

.panel-subtitle {
    font-size: 14px;
    color: #e2e8f0;
    font-weight: 400;
}

/* ==================== Panel Sections ====================
   ============================================================ */
.panel-section {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-content {
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
}

/* ==================== Layer Controls ====================
   ============================================================ */
.layer-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    flex-wrap: wrap;
    justify-content: space-between;
}

.layer-toggle input[type="radio"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.layer-toggle span {
    cursor: pointer;
    flex: 1;
    min-width: 120px;
    margin-right: auto;
}

/* ==================== Year Selector Styles ====================
   ============================================================ */
.year-selector {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8rem;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: 60px;
    flex-shrink: 0;
}

.year-selector:hover {
    border-color: #9ca3af;
}

.year-selector:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.year-selector:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.year-selector option {
    padding: 4px 8px;
    background: white;
    color: #374151;
}

/* ==================== Legend Styles ====================
   ============================================================ */
.legend-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}

.legend-color {
    width: 20px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #d1d5db;
}

.legend-label {
    color: #374151;
    font-weight: 500;
}

/* ==================== Details Grid ====================
   ============================================================ */
.details-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.detail-icon {
    font-size: 16px;
    margin-top: 2px;
}

.detail-content {
    flex: 1;
}

.detail-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

/* ==================== Map Container ====================
   ============================================================ */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

/* ==================== Affordability Legend Statistics ====================
   ============================================================ */
.legend-stats {
    display: none !important;
}

.stats-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.stats-item {
    color: #6c757d;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

/* ==================== HAI Calculator Styles ====================
   ============================================================ */
.hai-input-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.income-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s ease;
}

.income-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.income-input::placeholder {
    color: #9ca3af;
}

.property-type-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.property-type-controls {
    display: flex;
    gap: 16px;
}

.property-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
}

.property-toggle input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.property-toggle span {
    cursor: pointer;
}

.mortgage-parameters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parameter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.parameter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #374151;
}

.parameter-label {
    font-weight: 500;
    flex: 1;
}

.parameter-input {
    width: 70px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    text-align: right;
    background: white;
    transition: border-color 0.2s ease;
}

.parameter-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.calculate-button {
    padding: 10px 16px;
    background: #1e3a8a;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.calculate-button:hover:not(:disabled) {
    background: #1e40af;
}

.calculate-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.hai-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 12px;
}

.info-text {
    font-size: 12px;
    color: #0369a1;
    line-height: 1.4;
    margin: 0;
}

/* ==================== HAI Legend Styles ====================
   ============================================================ */
.hai-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hai-legend h4 {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.legend-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.legend-params {
    font-size: 11px;
    color: #6b7280;
    margin: 0;
    padding: 6px 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 4px;
    font-style: italic;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-placeholder {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
    text-align: center;
    padding: 20px;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    margin: 0;
}

/* ==================== Responsive Design ====================
   ============================================================ */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .side-panel {
        width: 100%;
        height: 40vh;
        max-height: 400px;
    }
    
    .map-container {
        height: 60vh;
    }
    
    .property-type-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .calculate-button {
        width: 100%;
    }
    
    /* Year selector responsive adjustments */
    .layer-toggle {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .layer-toggle span {
        min-width: auto;
        flex: none;
    }
    
    .year-selector {
        width: 100%;
        min-width: auto;
        margin-top: 4px;
    }
}

/* ==================== Side-Attached Summary Button ====================
   ============================================================ */
.side-attached-summary-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 90px;
    background: #1e3a8a;
    color: white;
    border: none;
    border-radius: 0;
    cursor: pointer;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    transition: right 0.3s ease;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.summary-panel.open + * .side-attached-summary-btn,
.summary-panel.open .side-attached-summary-btn {
    right: 400px;
}


.summary-text {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 2px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* ==================== Summary Panel (Right Side) ====================
   ============================================================ */
.summary-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    border-left: 1px solid #dee2e6;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.summary-panel.open {
    right: 0;
}

.summary-header {
    background: #1e3a8a;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1001;
}

.summary-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.summary-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.summary-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.summary-content {
    padding: 24px;
}

.summary-section {
    margin-bottom: 28px;
}

.summary-section.main-description {
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.section-heading {
    font-size: 16px;
    font-weight: 600;
    color: #1e3a8a;
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.section-subheading {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.description-text {
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
    margin: 0;
}

.feature-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.feature-list li {
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
    margin-bottom: 6px;
    padding-left: 14px;
    position: relative;
}

.feature-list li::before {
    content: "•";
    color: #1e3a8a;
    font-weight: 600;
    position: absolute;
    left: 0;
}

.feature-list li strong {
    color: #374151;
    font-weight: 600;
}

.color-legend {
    margin: 0;
    padding: 0;
    list-style: none;
}

.color-legend li {
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-legend li strong {
    color: #374151;
    font-weight: 600;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.color-dot.green {
    background-color: #1B5E20;
}

.color-dot.orange {
    background-color: #F57F17;
}

.color-dot.red {
    background-color: #B71C1C;
}

.color-dot.gray {
    background-color: #BDBDBD;
}

/* ==================== Suburb Popup Styles ====================
   ============================================================ */
.suburb-popup .mapboxgl-popup-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
    max-width: 280px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.suburb-popup .mapboxgl-popup-tip {
    border-top-color: white;
}

.popup-content {
    padding: 16px;
}

.popup-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e3a8a;
    margin: 0 0 12px 0;
    line-height: 1.3;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
}

.popup-data {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.data-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
}

.data-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-value {
    font-size: 14px;
    color: #374151;
    font-weight: 600;
}

/* ==================== Responsive Summary Panel ====================
   ============================================================ */
@media (max-width: 768px) {
    .summary-panel {
        width: 100%;
        right: -100%;
    }
    
    .side-attached-summary-btn {
        left: 0;
        top: 20px;
        transform: translateX(0);
        width: 80px;
        height: 35px;
        border-radius: 0 8px 8px 0;
    }
    
    .summary-text {
        font-size: 12px;
    }
    
    /* Mobile popup adjustments */
    .suburb-popup .mapboxgl-popup-content {
        max-width: 250px;
    }
    
    .popup-content {
        padding: 12px;
    }
    
    .popup-title {
        font-size: 14px;
    }
    
    .data-value {
        font-size: 13px;
    }
}
