/* 🎨 DARK UI PROFESSIONAL - INSPIRED BY MODERN FINTECH */
:root {
    /* Dark Theme Colors */
    --bg-primary: #0B1120;
    --bg-secondary: #151B2D;
    --bg-card: #1A2236;
    --bg-hover: #202943;
    
    /* Accent Colors */
    --accent-red: #E31E3D;
    --accent-red-hover: #FF2D4D;
    --accent-red-dark: #C11828;
    
    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #8B93A7;
    --text-muted: #5A6274;
    
    /* Border & Dividers */
    --border-color: #2A3447;
    --border-light: #1E2738;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-red: 0 4px 20px rgba(227, 30, 61, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image: 
        radial-gradient(at 20% 20%, rgba(227, 30, 61, 0.1) 0px, transparent 50%),
        radial-gradient(at 80% 80%, rgba(227, 30, 61, 0.08) 0px, transparent 50%);
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 🎯 HEADER MODERN */
header {
    text-align: center;
    padding: 15px 0 10px 0;
    position: relative;
    flex-shrink: 0;
    overflow: visible; /* Permitir que el dropdown se muestre fuera del header */
    z-index: 1; /* Establecer contexto de apilamiento */
}

/* 🌐 LANGUAGE SELECTOR */
.language-selector {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 9999; /* Máximo z-index para estar por encima de todo */
}

.lang-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent; /* Eliminar highlight en móvil */
    touch-action: manipulation; /* Mejorar respuesta táctil */
    position: relative;
    z-index: 9999; /* Asegurar que el botón esté por encima */
}

.lang-button:hover {
    border-color: var(--accent-red);
    transform: translateY(-2px);
    box-shadow: var(--shadow-red);
}

.lang-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Mejorar feedback táctil en móvil */
@media (hover: none) and (pointer: coarse) {
    .lang-button:active {
        background: var(--bg-hover);
        transform: scale(0.98);
    }
}

.lang-icon {
    color: var(--text-secondary);
}

.arrow-icon {
    transition: transform 0.3s ease;
}

.lang-button.active .arrow-icon {
    transform: rotate(180deg);
}

#current-lang {
    font-family: monospace;
    letter-spacing: 0.5px;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible; /* Cambiar a visible para mostrar todas las opciones */
    z-index: 10000; /* Aún más alto que el selector para estar por encima */
    max-height: none; /* Asegurar que no haya límite de altura */
    display: flex; /* Usar flex para mejor control */
    flex-direction: column; /* Apilar opciones verticalmente */
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.lang-option:hover {
    background: var(--bg-hover);
}

.lang-option:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
}

.lang-option .flag {
    font-size: 20px;
}

.lang-option .check {
    margin-left: auto;
    color: var(--accent-red);
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.lang-option.active .check {
    opacity: 1;
}

.banner {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
    padding: 20px 25px 15px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(227, 30, 61, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 8s ease-in-out infinite;
}

.banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(227, 30, 61, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-20px, -20px) scale(1.1); }
}

.banner:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-red), var(--shadow-lg);
}

.banner-badge {
    display: inline-block;
    background: var(--accent-red);
    color: var(--text-primary);
    font-size: 9px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.banner-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 5px 0;
    letter-spacing: -1px;
    position: relative;
    z-index: 1;
}

.banner-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    font-weight: 400;
    position: relative;
    z-index: 1;
    letter-spacing: 0.3px;
}

.banner-metrics {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 0;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.metric-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-red);
    line-height: 1;
}

.metric-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 📊 MAIN LAYOUT */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
    padding-bottom: 10px;
    min-height: 0; /* Permite que flex items se compriman */
}

section {
    flex-shrink: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: center;
}

.subtitle {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 8px;
}

/* 💱 RATES DISPLAY */
.rates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.rate-card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.rate-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-red) 0%, transparent 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}

.rate-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-red), var(--shadow-lg);
    border-color: var(--accent-red);
}

.rate-card:hover::before {
    transform: scaleX(1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.currency-code {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.status-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-badge.live {
    background: rgba(227, 30, 61, 0.2);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    animation: pulse 2s ease infinite;
}

.currency-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 15px;
    letter-spacing: 0.3px;
}

.card-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
}

.update-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.exchange-rate {
    font-size: 36px;
    font-weight: 800;
    color: var(--accent-red);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

/* 🔄 LATAM TOGGLE BUTTON */

/* 🌎 LATAM PANEL */
.latam-rates-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    flex: 1;
    min-height: 0; /* Permite compresión en móvil */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 700;
    margin: 0;
}

.panel-badge {
    background: rgba(227, 30, 61, 0.15);
    color: var(--accent-red);
    font-size: 9px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid rgba(227, 30, 61, 0.3);
}

.latam-rates-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.latam-rates-grid::-webkit-scrollbar {
    height: 6px;
}

.latam-rates-grid::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 3px;
}

.latam-rates-grid::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 3px;
}

.latam-rates-grid::-webkit-scrollbar-thumb:hover {
    background: var(--accent-red-hover);
}

.latam-rate-card {
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 140px;
    flex-shrink: 0;
    scroll-snap-align: start;
}

.latam-rate-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(227, 30, 61, 0.15) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.4s ease;
    border-radius: 50%;
}

.latam-rate-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--accent-red);
    box-shadow: var(--shadow-red);
}

.latam-rate-card:hover::after {
    transform: translate(-50%, -50%) scale(2);
}

.latam-rate-card:active {
    transform: translateY(-2px) scale(1);
}

.latam-rate-card .currency-code {
    font-size: 11px;
    margin-bottom: 4px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.latam-rate-card .rate-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent-red);
    margin-bottom: 4px;
}

.latam-rate-card .click-hint {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.latam-rate-card:hover .click-hint {
    opacity: 1;
    color: var(--accent-red);
}

/* 📈 MARKET OVERVIEW */
.market-overview {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.market-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.market-header h3 {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 700;
    margin: 0;
}

.market-badge {
    background: rgba(227, 30, 61, 0.15);
    color: var(--accent-red);
    font-size: 9px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid rgba(227, 30, 61, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.market-card {
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease;
}

.market-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-red);
    box-shadow: var(--shadow-red);
}

.market-icon {
    font-size: 24px;
    text-align: center;
    margin-bottom: 4px;
}

.market-info {
    flex: 1;
}

.market-name {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
    text-align: center;
}

.market-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.market-change {
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.market-change.positive {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.market-change.negative {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.market-label {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 🔄 CONVERTER */
.converter {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.converter h2 {
    margin-bottom: 8px;
}

.converter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.converter-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--border-color);
}

.converter-actions {
    text-align: center;
}

#clear-btn {
    background: var(--accent-red);
    color: var(--text-primary);
    border: none;
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#clear-btn:hover {
    background: var(--accent-red-hover);
    transform: translateY(-2px);
}

.input-group {
    margin-bottom: 25px;
    position: relative;
}

.card-label {
    margin-bottom: 6px;
}

.card-label span:first-child {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.hint {
    font-size: 8px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 8px 50px 8px 10px;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-variant-numeric: tabular-nums;
}

.currency-tag {
    position: absolute;
    right: 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-red);
    background: rgba(227, 30, 61, 0.1);
    padding: 3px 7px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 4px rgba(227, 30, 61, 0.15);
    background: var(--bg-card);
    transform: translateY(-2px);
}

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

.divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    background: var(--bg-card);
    padding: 0 15px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.converter-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    flex: 1;
    padding: 16px 30px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-clear {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-red);
    transform: translateY(-2px);
}

.btn-clear:active {
    transform: translateY(0);
}

/* 📱 AD SPACES */
.ad-space {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    margin: 40px 0;
    transition: all 0.3s ease;
    position: relative;
}

.ad-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 4px;
}

.ad-space:hover {
    border-color: var(--accent-red);
    background: var(--bg-card);
}

/* 🦶 FOOTER */
footer {
    text-align: center;
    padding: 10px 20px;
    color: var(--text-muted);
    font-size: 10px;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

footer p {
    margin: 0;
}

.footer-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-badge {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

footer a {
    color: var(--accent-red);
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--accent-red-hover);
    text-decoration: underline;
}

/* 📱 RESPONSIVE */
@media (max-width: 768px) {
    .container {
        padding: 0 8px;
    }

    .language-selector {
        position: absolute;
        top: 3px;
        right: 3px;
        z-index: 9999; /* Máximo z-index para estar por encima de todo */
    }
    
    .lang-button {
        padding: 6px 10px;
        font-size: 11px;
        border-width: 1px;
        min-height: 32px;
        min-width: 48px;
        gap: 4px;
        border-radius: 8px;
    }
    
    /* Ocultar icono de idioma en móvil para ahorrar espacio */
    .lang-icon {
        display: none;
    }
    
    .arrow-icon {
        width: 8px;
        height: 8px;
        flex-shrink: 0;
    }
    
    #current-lang {
        font-size: 11px;
        font-weight: 700;
        min-width: 20px;
        letter-spacing: 0.3px;
    }
    
    .lang-dropdown {
        min-width: 150px;
        max-width: calc(100vw - 16px);
        right: 0 !important;
        top: auto !important; /* Se calculará dinámicamente con JS */
        box-shadow: var(--shadow-lg);
        z-index: 10000; /* Aún más alto que el selector */
        border-radius: 8px;
        overflow: visible !important; /* Asegurar que todas las opciones sean visibles */
        display: flex !important;
        flex-direction: column;
        position: fixed !important; /* Usar fixed en móvil para evitar problemas de overflow */
    }
    
    .lang-option {
        padding: 12px 14px;
        min-height: 44px;
        font-size: 13px;
        gap: 8px;
    }
    
    .lang-option .flag {
        font-size: 18px;
        flex-shrink: 0;
    }
    
    .lang-option span:not(.flag):not(.check) {
        font-size: 13px;
        font-weight: 500;
    }
    
    header {
        padding: 5px 0 3px 0;
    }
    
    .banner {
        padding: 8px 12px 6px 12px;
    }
    
    .banner-badge {
        font-size: 7px;
        padding: 2px 6px;
        margin-bottom: 4px;
    }
    
    .banner-title {
        font-size: 18px;
        margin: 0 0 2px 0;
    }
    
    .banner-subtitle {
        font-size: 8px;
        margin: 0 0 6px 0;
        line-height: 1.2;
    }
    
    /* Ocultar métricas en móvil para ahorrar espacio */
    .banner-metrics {
        display: none;
    }
    
    main {
        gap: 6px;
        padding-bottom: 5px;
    }
    
    /* LATAM Panel más compacto */
    .latam-rates-panel {
        padding: 8px;
        border-radius: 8px;
    }
    
    .panel-header {
        margin-bottom: 6px;
    }
    
    .panel-header h3 {
        font-size: 11px;
    }
    
    .panel-badge {
        font-size: 7px;
        padding: 2px 6px;
    }
    
    .latam-rates-grid {
        gap: 6px;
        padding-bottom: 5px;
    }
    
    .latam-rate-card {
        min-width: 100px;
        padding: 8px 10px;
    }
    
    .latam-rate-card .currency-code {
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .latam-rate-card .rate-value {
        font-size: 13px;
        margin-bottom: 2px;
    }
    
    .latam-rate-card .click-hint {
        font-size: 7px;
    }
    
    /* Market Overview más compacto */
    .market-overview {
        padding: 8px;
        border-radius: 8px;
    }
    
    .market-header {
        margin-bottom: 6px;
    }
    
    .market-header h3 {
        font-size: 11px;
    }
    
    .market-badge {
        font-size: 7px;
        padding: 2px 6px;
    }
    
    .market-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .market-card {
        padding: 6px;
        gap: 4px;
    }
    
    .market-icon {
        font-size: 18px;
        margin-bottom: 2px;
    }
    
    .market-name {
        font-size: 8px;
        margin-bottom: 2px;
    }
    
    .market-price {
        font-size: 12px;
    }
    
    .market-change {
        font-size: 9px;
        padding: 2px 4px;
    }
    
    .market-label {
        font-size: 7px;
    }
    
    /* Converter más compacto */
    .converter {
        padding: 8px;
        border-radius: 8px;
    }
    
    .converter h2 {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .subtitle {
        font-size: 8px;
        margin-bottom: 4px;
    }
    
    .converter-grid {
        grid-template-columns: 1fr;
        gap: 4px;
        margin-bottom: 6px;
    }
    
    .converter-card {
        padding: 6px;
        border-radius: 6px;
    }
    
    .card-label span:first-child {
        font-size: 9px;
    }
    
    .hint {
        font-size: 7px;
        margin-top: 1px;
    }
    
    .input-wrapper input {
        font-size: 16px; /* Evita zoom automático en iOS */
        padding: 6px 40px 6px 8px;
    }
    
    .currency-tag {
        font-size: 9px;
        padding: 2px 5px;
        right: 6px;
    }
    
    .converter-actions {
        margin-top: 0;
    }
    
    #clear-btn {
        padding: 6px 16px;
        font-size: 10px;
    }
    
    /* Footer más compacto */
    footer {
        padding: 6px 8px;
        font-size: 8px;
    }
    
    .footer-content {
        gap: 4px;
    }
    
    .footer-badges {
        gap: 4px;
    }
    
    .footer-badge {
        font-size: 7px;
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 6px;
    }
    
    .language-selector {
        top: 2px;
        right: 2px;
    }
    
    .lang-button {
        padding: 5px 8px;
        font-size: 10px;
        min-height: 28px;
        min-width: 42px;
        gap: 3px;
        border-radius: 6px;
    }
    
    .lang-icon {
        display: none;
    }
    
    .arrow-icon {
        width: 7px;
        height: 7px;
    }
    
    #current-lang {
        font-size: 10px;
        min-width: 18px;
    }
    
    .lang-dropdown {
        min-width: 140px;
        max-width: calc(100vw - 12px);
        border-radius: 6px;
        z-index: 10000; /* Asegurar que esté por encima de todo */
        overflow: visible !important; /* Asegurar que todas las opciones sean visibles */
        display: flex !important;
        flex-direction: column;
        position: fixed !important; /* Usar fixed en móvil pequeño */
        right: 0 !important;
        top: auto !important; /* Se calculará con JS */
    }
    
    .lang-option {
        padding: 10px 12px;
        min-height: 40px;
        font-size: 12px;
    }
    
    .lang-option .flag {
        font-size: 16px;
    }
    
    header {
        padding: 4px 0 2px 0;
    }
    
    .banner {
        padding: 6px 10px 4px 10px;
    }
    
    .banner-title {
        font-size: 16px;
    }
    
    .banner-subtitle {
        font-size: 7px;
    }
    
    main {
        gap: 5px;
    }
    
    .latam-rates-panel {
        padding: 6px;
    }
    
    .latam-rate-card {
        min-width: 90px;
        padding: 6px 8px;
    }
    
    .market-overview {
        padding: 6px;
    }
    
    .market-card {
        padding: 5px;
    }
    
    .market-icon {
        font-size: 16px;
    }
    
    .market-price {
        font-size: 11px;
    }
    
    .converter {
        padding: 6px;
    }
    
    .input-wrapper input {
        font-size: 16px; /* Evita zoom automático en iOS */
        padding: 5px 35px 5px 6px;
    }
    
    .currency-tag {
        font-size: 8px;
        right: 5px;
    }
}

/* ⚡ PERFORMANCE OPTIMIZATIONS */
* {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

button, .rate-card, .latam-rate-card, .banner {
    will-change: transform;
}

/* 🎭 LOADING STATE */
.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* 🌟 SCROLL ANIMATIONS */
@media (prefers-reduced-motion: no-preference) {
    section {
        animation: fadeInUp 0.6s ease-out;
        animation-fill-mode: both;
    }

    section:nth-child(1) { animation-delay: 0.1s; }
    section:nth-child(2) { animation-delay: 0.2s; }
    section:nth-child(3) { animation-delay: 0.3s; }
}

/* 🎨 CUSTOM SCROLLBAR */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-red-hover);
}
