/* ===== Variables ===== */
:root {
    --primary: #9b1b30;
    --primary-dark: #7a1526;
    --primary-light: #d4536a;
    --accent: #b91c3c;
    --sidebar-bg: linear-gradient(180deg, #4a0e1b 0%, #6b1529 50%, #5c1224 100%);
    --sidebar-width: 400px;
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.12);
    --text-primary: #fdf2f4;
    --text-secondary: #f9a8b8;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow: hidden;
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--primary-light);
    filter: drop-shadow(0 0 8px rgba(212, 83, 106, 0.4));
}

.logo-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    opacity: 0.8;
    margin: 0;
}

/* ===== Sidebar Body ===== */
.sidebar-body {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ===== Step Cards ===== */
.step-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.step-card:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.step-card.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.step-card.active {
    border-color: var(--primary-light);
    box-shadow: 0 0 20px rgba(212, 83, 106, 0.15);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.85rem;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-label {
    font-size: 0.88rem;
    font-weight: 600;
}

/* ===== Custom Form Controls ===== */
.custom-select {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    padding: 0.65rem 1rem !important;
    font-size: 0.9rem !important;
    transition: all var(--transition);
}

.custom-select:focus {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: var(--primary-light) !important;
    box-shadow: 0 0 0 3px rgba(212, 83, 106, 0.25) !important;
}

.custom-select option {
    background: #5c1224;
    color: white;
}

.custom-input-group {
    border-radius: 10px;
    overflow: hidden;
}

.custom-input-group .form-control {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0.65rem 1rem;
    border-right: none;
}

.custom-input-group .form-control:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-light);
    box-shadow: none;
    color: white;
}

.custom-input-group .form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.custom-input-group .form-control:disabled {
    background-color: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.3);
}

.btn-search {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    padding: 0 1rem;
    transition: all var(--transition);
}

.btn-search:hover:not(:disabled) {
    background: var(--primary-dark);
    color: white;
}

.btn-search:disabled {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
}

/* ===== Search Status / Error ===== */
.search-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.7rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.search-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.7rem;
    font-size: 0.82rem;
    color: #fca5a5;
}

/* ===== Result Card ===== */
.result-card {
    background: linear-gradient(135deg, rgba(155, 27, 48, 0.2), rgba(212, 83, 106, 0.1));
    border: 1px solid rgba(212, 83, 106, 0.25);
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--primary-light);
    margin-bottom: 0.7rem;
}

.result-address {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.65rem;
    color: var(--text-primary);
}

/* ===== Manzana y Lote ===== */
.result-catastro {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.65rem;
}

.catastro-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
}

.catastro-item i {
    color: var(--primary-light);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.catastro-label {
    color: var(--text-secondary);
    opacity: 0.7;
    font-size: 0.75rem;
    white-space: nowrap;
}

.catastro-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Popup manzana/lote */
.popup-catastro {
    display: flex;
    gap: 0.75rem;
    margin-top: 6px;
    font-size: 0.78rem;
}

.popup-catastro span {
    color: #64748b;
}

.popup-catastro strong {
    color: #334155;
}

.catastro-found {
    color: var(--primary-light) !important;
}

.result-coords {
    font-size: 0.78rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-bottom: 0.8rem;
}

.btn-clear {
    width: 100%;
    border-radius: 8px;
    font-size: 0.82rem;
    padding: 0.45rem;
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.btn-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    padding: 0.8rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.sidebar-footer p {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.35);
    margin: 0;
}

/* ===== Map ===== */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* ===== Sidebar Toggle (mobile) ===== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: #4a0e1b;
    color: white;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .map-container {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        min-width: 100%;
    }
}

/* ===== Leaflet popup custom ===== */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    font-family: 'Inter', sans-serif !important;
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    font-size: 0.88rem !important;
    line-height: 1.5 !important;
}

.popup-title {
    font-weight: 600;
    color: #9b1b30;
    margin-bottom: 4px;
}

.popup-address {
    color: #475569;
    font-size: 0.82rem;
}

.popup-coords {
    color: #94a3b8;
    font-size: 0.75rem;
    margin-top: 4px;
    font-family: 'Courier New', monospace;
}

/* ===== Search Hint ===== */
.search-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.6rem;
    margin-bottom: 0;
    line-height: 1.5;
}

.search-hint strong {
    color: var(--primary-light);
}

.search-hint i {
    margin-right: 2px;
}

/* ===== Map Hint Tooltip ===== */
.map-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    background: rgba(74, 14, 27, 0.92);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    transition: opacity 0.5s ease;
    white-space: nowrap;
}

.map-hint.hidden {
    opacity: 0;
}

.map-hint i {
    margin-right: 4px;
}

/* ===== Map crosshair cursor ===== */
#map {
    cursor: crosshair;
}

/* ===== Reverse geocode loading on map ===== */
.map-loading-popup {
    text-align: center;
    color: #64748b;
    font-size: 0.82rem;
}