/* Variables Modo Claro (Por defecto) */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --input-bg: #ffffff;
    --distance-bg: #e2e8f0;
}

/* Variables Modo Oscuro */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary: #10b981;
    --secondary-hover: #34d399;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --input-bg: #0f172a;
    --distance-bg: #334155;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.header h1 {
    margin: 0;
    font-size: 1.8em;
}

.theme-toggle {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-size: 20px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--distance-bg);
}

.panel {
    background: var(--card);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
}

/* Diseño de búsqueda */
.location-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-box {
    display: flex;
    flex: 1;
    position: relative;
}

.search-box input[type="text"] {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--border);
    border-right: none;
    border-radius: 12px 0 0 12px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    width: 100%;
}

.search-box input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.search-box button {
    border-radius: 0 12px 12px 0;
    padding: 14px 24px;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
    transition: background-color 0.2s;
}

button:hover { background: var(--primary-hover); }
button:disabled { background: var(--text-muted); cursor: not-allowed; }

#btn-locate { background: var(--secondary); }
#btn-locate:hover { background: var(--secondary-hover); }

#filters {
    display: flex;
    gap: 20px;
    margin-top: 24px;
    flex-wrap: wrap;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background-color: var(--input-bg);
    color: var(--text);
    outline: none;
}

select:focus {
    border-color: var(--primary);
}

#status {
    text-align: center;
    margin: 20px 0;
    font-weight: 500;
    color: var(--text-muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    background: var(--card);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.05);
    border: 1px solid var(--border);
    transition: transform 0.2s, background-color 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

.brand {
    font-weight: bold;
    font-size: 1.3em;
    color: var(--primary);
}

.price {
    font-size: 2em;
    font-weight: bold;
    margin: 15px 0;
    color: var(--text);
}

.address {
    font-size: 0.95em;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.4;
}

.distance {
    display: inline-block;
    background: var(--distance-bg);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    margin-top: 15px;
    color: var(--text);
}

/* =========================================
   REGLAS PARA MÓVILES (Pantallas pequeñas) 
   ========================================= */
@media (max-width: 650px) {
    .header h1 {
        font-size: 1.5em; /* Título un poco más pequeño */
    }

    /* Apilar el botón de GPS y la barra de búsqueda verticalmente */
    .location-controls {
        flex-direction: column;
        align-items: stretch;
    }

    #btn-locate {
        width: 100%; /* Botón GPS ocupa todo el ancho */
    }

    .search-box {
        width: 100%;
    }

    .search-box input[type="text"] {
        width: 100%;
    }

    /* Reducir el texto del botón buscar para ganar espacio en la caja de texto */
    .search-box button {
        padding: 14px 16px; 
    }

    /* Apilar los filtros verticalmente */
    #filters {
        flex-direction: column;
        gap: 15px;
    }
    
    .filter-group {
        width: 100%;
    }
}