/**
 * Mercado Disvisas - Estilos Personalizados
 * Complementa los estilos de Billetaxo
 */

/* ============================================================================
   Variables CSS
   ============================================================================ */
:root {
    --color-primary: #2c3e50;
    --color-secondary: #3498db;
    --color-success: #27ae60;
    --color-danger: #e74c3c;
    --color-warning: #f39c12;
    --color-info: #3498db;
    --color-light: #ecf0f1;
    --color-dark: #2c3e50;
    --color-text: #555;
    --color-text-light: #7f8c8d;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --border-radius: 12px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* ============================================================================
   Reset y Base
   ============================================================================ */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: #f8f9fa;
}

/* ============================================================================
   Utilidades
   ============================================================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-primary {
    background: var(--color-secondary);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* ============================================================================
   Dashboard de Estadísticas
   ============================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--spacing-md);
}

.currency-card {
    background: white;
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    border: 1px solid #e3e9f2;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    transition: var(--transition);
}

.currency-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(44, 62, 80, 0.12);
}

.currency-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.currency-card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--color-primary);
}

.currency-card-header span {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: #f1f5ff;
    color: #3b5bcc;
    font-size: 0.85rem;
    font-weight: 600;
}

.currency-main-rate {
    font-size: 2.15rem;
    font-weight: 700;
    color: var(--color-secondary);
    line-height: 1.2;
}

.currency-subtitle {
    margin: 0;
    color: var(--color-text-light);
    font-size: 0.95rem;
}

.currency-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: var(--spacing-sm);
}

.btn-detalles {
    padding: 0.6rem 1rem;
    border: 1px solid #d5dff0;
    background: #f8fbff;
    color: var(--color-secondary);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-detalles:hover {
    background: #edf3ff;
}

.currency-updated {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.currency-details {
    display: none;
    margin-top: var(--spacing-sm);
    border-top: 1px solid #e6ecf5;
    padding-top: var(--spacing-sm);
}

.currency-details dl {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 0.5rem;
}

.currency-details dt {
    font-weight: 600;
    color: var(--color-primary);
}

.currency-details dd {
    margin: 0;
    text-align: right;
    color: var(--color-text-light);
    font-weight: 600;
}

/* ============================================================================
   Cards de Oferta
   ============================================================================ */
.oferta-card {
    background: white;
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    position: relative;
}

.oferta-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.oferta-card .badge-verificado {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--color-success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ============================================================================
   Formularios
   ============================================================================ */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-primary);
}

.form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-help {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
    display: block;
}

.form-error {
    color: var(--color-danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* ============================================================================
   Alertas y Mensajes
   ============================================================================ */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: #d4edda;
    border-left: 4px solid var(--color-success);
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-left: 4px solid var(--color-danger);
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border-left: 4px solid var(--color-warning);
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border-left: 4px solid var(--color-info);
    color: #0c5460;
}

/* ============================================================================
   Loading y Spinners
   ============================================================================ */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(52, 152, 219, 0.2);
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ============================================================================
   Badges y Tags
   ============================================================================ */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-success {
    background: var(--color-success);
    color: white;
}

.badge-danger {
    background: var(--color-danger);
    color: white;
}

.badge-warning {
    background: var(--color-warning);
    color: white;
}

.badge-info {
    background: var(--color-info);
    color: white;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 768px) {
    .hero-mercado {
        padding: 3rem 0 !important;
    }

    .hero-mercado h1 {
        font-size: clamp(1.5rem, 4vw, 2rem) !important;
    }

    .hero-mercado h2 {
        font-size: clamp(1rem, 3vw, 1.3rem) !important;
    }

    .hero-mercado p {
        font-size: clamp(0.9rem, 2.5vw, 1.1rem) !important;
    }

    .section-ofertas .container > div {
        grid-template-columns: 1fr !important;
    }

    /* Filtros más compactos en móvil */
    .filtros-sidebar {
        position: static !important;
        margin-bottom: 1.5rem !important;
        padding: 1.25rem !important;
    }

    .filtros-sidebar h2 {
        font-size: 1.2rem !important;
        margin-bottom: 1rem !important;
    }

    .filtros-sidebar .form-group {
        margin-bottom: 1rem !important;
    }

    .filtros-sidebar label {
        font-size: 0.9rem !important;
        margin-bottom: 0.4rem !important;
    }

    .filtros-sidebar select,
    .filtros-sidebar input,
    .filtros-sidebar button {
        padding: 0.6rem !important;
        font-size: 0.95rem !important;
    }

    .filtros-sidebar #stats-sidebar {
        margin-top: 1.5rem !important;
        padding-top: 1.5rem !important;
    }

    .filtros-sidebar #stats-sidebar h3 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .filtros-sidebar #stats-sidebar p {
        font-size: 0.85rem !important;
    }

    /* Ofertas más compactas */
    .ofertas-grid-container {
        padding: 0 !important;
    }

    .ofertas-grid-container > div:first-child {
        margin-bottom: 1.25rem !important;
    }

    .ofertas-grid-container h2 {
        font-size: 1.4rem !important;
    }

    .ofertas-grid-container #ordenar {
        padding: 0.5rem !important;
        font-size: 0.9rem !important;
    }

    #ofertas-container {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .oferta-card {
        padding: 1.25rem !important;
    }

    .oferta-card h3 {
        font-size: 1.1rem !important;
    }

    .oferta-card p,
    .oferta-card span {
        font-size: 0.9rem !important;
    }

    .btn {
        width: 100%;
        text-align: center;
        padding: 0.65rem 1.25rem !important;
        font-size: 0.95rem !important;
    }

    /* Dashboard de estadísticas */
    #stats-dashboard {
        display: block !important;
    }

    .stats-dashboard {
        display: block !important;
        padding: 2rem 1rem !important;
    }

    .stats-header {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .currency-card {
        padding: 1rem !important;
    }

    .currency-card-header h3 {
        font-size: 1.05rem !important;
    }

    .currency-card-header span {
        font-size: 0.8rem !important;
        padding: 0.2rem 0.6rem !important;
    }
}

@media (max-width: 480px) {
    :root {
        --spacing-sm: 0.5rem;
        --spacing-md: 0.85rem;
        --spacing-lg: 1.25rem;
    }

    .hero-mercado {
        padding: 2.5rem 0 !important;
    }

    /* Dashboard visible y compacto en móviles pequeños */
    #stats-dashboard {
        display: block !important;
    }

    .stats-dashboard {
        display: block !important;
        padding: 1.5rem 0.5rem !important;
    }

    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    /* Filtros extra compactos */
    .filtros-sidebar {
        padding: 1rem !important;
    }

    .filtros-sidebar h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.85rem !important;
    }

    .filtros-sidebar .form-group {
        margin-bottom: 0.85rem !important;
    }

    .filtros-sidebar label {
        font-size: 0.85rem !important;
    }

    .filtros-sidebar select,
    .filtros-sidebar input {
        padding: 0.5rem !important;
        font-size: 0.9rem !important;
    }

    .filtros-sidebar button {
        padding: 0.6rem !important;
        font-size: 0.9rem !important;
    }

    /* Ofertas extra compactas */
    .oferta-card {
        padding: 1rem !important;
    }

    .oferta-card h3 {
        font-size: 1rem !important;
    }

    .oferta-card p,
    .oferta-card span {
        font-size: 0.85rem !important;
    }

    .ofertas-grid-container h2 {
        font-size: 1.25rem !important;
    }

    .ofertas-grid-container #ordenar {
        padding: 0.45rem !important;
        font-size: 0.85rem !important;
    }

    /* Dashboard compacto */
    .currency-card {
        padding: 0.85rem !important;
    }

    .currency-card-header h3 {
        font-size: 0.95rem !important;
    }

    .currency-card-header span {
        font-size: 0.75rem !important;
        padding: 0.15rem 0.5rem !important;
    }

    .form-control,
    input,
    select,
    textarea {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

/* ============================================================================
   Estilos para Nuevas Métricas de Mercado
   ============================================================================ */

/* Grid para detalles */
.detalles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 0;
}

.detalle-section {
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 3px solid var(--color-primary);
}

.detalle-section dt {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.detalle-section dd {
    font-size: 1rem;
    color: #1f2937;
    font-weight: 600;
    margin: 0;
}

.detalle-section small {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 400;
}

/* Secciones de ancho completo */
.detalle-full {
    grid-column: 1 / -1;
}

/* Barra de presión de mercado */
.presion-bar {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    margin: 0.5rem 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.presion-compra {
    background: linear-gradient(90deg, #22c55e, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.3s ease;
}

.presion-venta {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.3s ease;
}

/* Responsive para métricas */
@media (max-width: 768px) {
    .detalles-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .detalle-section {
        padding: 0.5rem;
    }
    
    .presion-bar {
        height: 28px;
    }
    
    .presion-compra,
    .presion-venta {
        font-size: 0.7rem;
    }
}

/* ============================================================================
   Accesibilidad
   ============================================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible para navegación por teclado */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* ============================================================================
   Animaciones
   ============================================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

/* ============================================================================
   Print Styles
   ============================================================================ */
@media print {
    .filtros-sidebar,
    .section-cta,
    .btn,
    button {
        display: none !important;
    }

    .oferta-card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* ============================================================================
   Dark Mode Support (opcional)
   ============================================================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text: #e0e0e0;
        --color-text-light: #b0b0b0;
    }

    body {
        background: #1a1a1a;
        color: var(--color-text);
    }

    .oferta-card,
    .filtros-sidebar,
    .alert {
        background: #2a2a2a;
        color: var(--color-text);
    }

    input,
    select,
    textarea {
        background: #333;
        color: var(--color-text);
        border-color: #444;
    }
}
