/**
 * CompraVenta BMW - Estilos principales
 * Mobile-first con colores BMW y BMW M
 */

/* ============================================
   VARIABLES Y COLORES
   ============================================ */
:root {
    /* Colores BMW */
    --bmw-blue: #1c69d4;
    --bmw-blue-dark: #0f4c9e;
    --bmw-blue-light: #009CDE;
    --bmw-grey: #262626;
    --bmw-grey-light: #666666;
    
    /* Colores BMW M */
    --m-blue: #1C6FD7;
    --m-red: #E31E24;
    --m-dark-blue: #1C1C1E;
    
    /* Colores base */
    --white: #ffffff;
    --black: #000000;
    --text-dark: #1a1a1a;
    --text-light: #666666;
    --border-color: #e0e0e0;
    --background: #f8f9fa;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    
    /* Espaciado */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* Bordes */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
    
    /* Transiciones */
    --transition: all 0.3s ease;
}

/* ============================================
   RESET Y BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--bmw-blue);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--bmw-blue-dark);
}

/* ============================================
   UTILIDADES
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-md);
}

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

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

/* ============================================
   HEADER
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--bmw-blue) 0%, var(--bmw-blue-light) 100%);
    color: var(--white);
    padding: var(--spacing-md) 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--white);
}

.logo:hover {
    color: var(--white);
    opacity: 0.9;
}

.nav {
    display: flex;
    gap: var(--spacing-lg);
    align-items: center;
}

.nav a {
    color: var(--white);
    font-weight: 500;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

/* Menú móvil */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bmw-blue-dark);
        flex-direction: column;
        padding: var(--spacing-md);
        box-shadow: var(--shadow-lg);
    }
    
    .nav.active {
        display: flex;
    }
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background: var(--bmw-blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--bmw-blue-dark);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-m {
    background: linear-gradient(135deg, var(--m-blue) 0%, var(--m-red) 100%);
    color: var(--white);
}

.btn-m:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: var(--white);
}

.btn-secondary {
    background: var(--bmw-grey);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--bmw-grey-light);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--bmw-blue);
    color: var(--bmw-blue);
}

.btn-outline:hover {
    background: var(--bmw-blue);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.card-body {
    padding: var(--spacing-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-dark);
}

.card-text {
    color: var(--text-light);
    margin-bottom: var(--spacing-md);
}

.card-footer {
    padding: var(--spacing-md);
    background: var(--background);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   GRID DE ANUNCIOS
   ============================================ */
.anuncios-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

@media (min-width: 640px) {
    .anuncios-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .anuncios-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Card de anuncio */
.anuncio-card {
    position: relative;
}

.anuncio-badge {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: var(--bmw-blue);
    color: var(--white);
    padding: 4px 12px;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
}

.anuncio-badge.urge {
    background: var(--m-red);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.anuncio-precio {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--bmw-blue);
}

.anuncio-info {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.anuncio-info-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--text-light);
    padding: 4px 8px;
    background: var(--background);
    border-radius: var(--radius-sm);
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--bmw-blue);
    box-shadow: 0 0 0 3px rgba(28, 105, 212, 0.1);
}

.form-control::placeholder {
    color: #999;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    appearance: none;
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: var(--spacing-xs);
}

/* ============================================
   BADGES Y ETIQUETAS
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    text-transform: uppercase;
}

.badge-blue { background: var(--bmw-blue); color: var(--white); }
.badge-m { background: var(--m-red); color: var(--white); }
.badge-success { background: var(--success); color: var(--white); }
.badge-warning { background: var(--warning); color: var(--black); }
.badge-danger { background: var(--danger); color: var(--white); }
.badge-grey { background: var(--bmw-grey-light); color: var(--white); }

/* ============================================
   ALERTAS
   ============================================ */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--bmw-grey);
    color: var(--white);
    padding: var(--spacing-xxl) 0 var(--spacing-lg);
    margin-top: var(--spacing-xxl);
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-xl);
}

@media (min-width: 768px) {
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
    }
}

.footer h3 {
    margin-bottom: var(--spacing-md);
    font-size: 1.125rem;
}

.footer a {
    color: rgba(255, 255, 255, 0.8);
    display: block;
    margin-bottom: var(--spacing-sm);
}

.footer a:hover {
    color: var(--white);
}

.footer-bottom {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   LOADER
   ============================================ */
.loader {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--bmw-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: var(--spacing-xl) auto;
}

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

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

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

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-spinner .spinner {
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid var(--white);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 0.8s linear infinite;
}

.loading-spinner .loading-text {
    color: var(--white);
    font-size: 1.125rem;
    font-weight: 500;
    text-align: center;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
}

/* ============================================
   PÁGINAS LEGALES Y ESTÁTICAS
   ============================================ */

.legal-page {
    padding: 60px 0;
    background: #f8f9fa;
}

.legal-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.legal-page h1 {
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 40px;
    text-align: center;
    font-weight: 700;
}

.legal-content {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    line-height: 1.8;
}

.legal-content h2 {
    font-size: 1.75rem;
    color: var(--bmw-blue);
    margin-top: 40px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
}

.legal-content h3 {
    font-size: 1.35rem;
    color: var(--text-dark);
    margin-top: 25px;
    margin-bottom: 15px;
    font-weight: 600;
}

.legal-content p {
    color: var(--text-light);
    margin-bottom: 16px;
}

.legal-content ul,
.legal-content ol {
    color: var(--text-light);
    margin-left: 30px;
    margin-bottom: 20px;
}

.legal-content li {
    margin-bottom: 10px;
    line-height: 1.8;
}

.legal-content strong {
    color: var(--text-dark);
    font-weight: 600;
}

.legal-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--bmw-blue);
}

.legal-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 30px 0;
}

.legal-update-date {
    background: #f8f9fa;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--bmw-blue);
    margin-bottom: 30px;
    color: var(--text-light);
}

.legal-update-date strong {
    color: var(--text-dark);
}

.legal-highlight {
    background: #fff3cd;
    border-left: 4px solid var(--warning);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: var(--radius-sm);
}

.legal-highlight strong {
    color: #856404;
}

/* Formulario de contacto mejorado */
.contact-form-section {
    padding: 60px 0;
}

.contact-form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.contact-form-container h1 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 40px;
    color: var(--text-dark);
}

.contact-form-card {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.contact-form-card .form-group {
    margin-bottom: 24px;
}

.contact-form-card label {
    display: block;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 1rem;
}

.contact-form-card .form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.contact-form-card .form-control:focus {
    outline: none;
    border-color: var(--bmw-blue);
    box-shadow: 0 0 0 3px rgba(28, 105, 212, 0.1);
}

.contact-form-card textarea.form-control {
    resize: vertical;
    min-height: 150px;
}

.contact-other-methods {
    margin-top: 40px;
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
}

.contact-other-methods h3 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

.contact-other-methods p {
    font-size: 1.1rem;
    color: var(--text-light);
}

.contact-other-methods a {
    color: var(--bmw-blue);
    text-decoration: none;
    font-weight: 600;
}

.contact-other-methods a:hover {
    text-decoration: underline;
}

/* Responsivo para páginas legales */
@media (max-width: 768px) {
    .legal-page {
        padding: 40px 0;
    }

    .legal-container {
        padding: 0 15px;
    }

    .legal-page h1 {
        font-size: 2rem;
        margin-bottom: 30px;
    }

    .legal-content {
        padding: 25px 20px;
    }

    .legal-content h2 {
        font-size: 1.5rem;
        margin-top: 30px;
    }

    .legal-content h3 {
        font-size: 1.2rem;
    }

    .contact-form-card {
        padding: 25px 20px;
    }
}
