/* Variables de color para modo claro (por defecto) */
:root {
    --bg-gradient-start: #f6f9fc;
    --bg-gradient-end: #edf2f7;
    --card-bg: rgba(255,255,255,0.9);
    --card-border: rgba(255,255,255,0.6);
    --text-primary: #0d2b44;
    --text-secondary: #2c455d;
    --rate-item-bg: white;
    --rate-item-border: rgba(74, 124, 176, 0.15);
    --converter-bg: #eaf1fa;
    --input-bg: white;
    --input-border: #b3c9df;
    --input-focus: #a5c5e5;
    --badge-bg: #e2eaf3;
    --badge-text: #4a6a8a;
    --refresh-bg: #e3ecf5;
    --refresh-btn-hover: #c8d9ec;
    --error-bg: #ffdede;
    --error-text: #9e2b2b;
    --footer-text: #53718f;
    --shadow-color: rgba(0,20,40,0.25);
    --toast-bg: #2c3e50;
    --toast-text: white;
}

/* Variables para modo oscuro */
body.dark-mode {
    --bg-gradient-start: #1a2634;
    --bg-gradient-end: #0f1a24;
    --card-bg: rgba(30, 41, 59, 0.95);
    --card-border: rgba(255,255,255,0.1);
    --text-primary: #e2e8f0;
    --text-secondary: #a0b3cc;
    --rate-item-bg: #2d3748;
    --rate-item-border: #4a5568;
    --converter-bg: #253241;
    --input-bg: #1e2a3a;
    --input-border: #4a5a72;
    --input-focus: #2b6c9e;
    --badge-bg: #2d3f54;
    --badge-text: #bdd1e6;
    --refresh-bg: #253241;
    --refresh-btn-hover: #3a4a62;
    --error-bg: #4f2b2b;
    --error-text: #f8b4b4;
    --footer-text: #8fa3bf;
    --shadow-color: rgba(0,0,0,0.5);
    --toast-bg: #1e293b;
    --toast-text: #f1f5f9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: linear-gradient(145deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    transition: background 0.3s ease;
}

.card {
    max-width: 950px;
    width: 100%;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 48px;
    padding: 2.5rem 2rem;
    box-shadow: 0 25px 50px -12px var(--shadow-color);
    border: 1px solid var(--card-border);
    transition: background 0.3s ease, border-color 0.3s ease;
    position: relative;
}

/* Botón de cambio de modo */
.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--rate-item-bg);
    border: 1px solid var(--rate-item-border);
    border-radius: 40px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--shadow-color);
    z-index: 10;
}

.theme-toggle:hover {
    background: var(--refresh-btn-hover);
}

.theme-toggle span {
    font-size: 1.2rem;
    line-height: 1;
}

h1 {
    font-size: 3.2rem;
    font-weight: 700;
    background: linear-gradient(130deg, #1A2F4F, #2B5F8A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.subhead {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    border-left: 3px solid #2b6c9e;
    padding-left: 1rem;
    transition: color 0.3s ease;
}

.rates-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin: 2.5rem 0 2.2rem;
}

.rate-item {
    flex: 1 1 160px;
    background: var(--rate-item-bg);
    padding: 1.5rem 1rem;
    border-radius: 36px;
    text-align: center;
    box-shadow: 0 8px 18px -8px var(--shadow-color);
    border: 1px solid var(--rate-item-border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.currency {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    white-space: nowrap;
}

.value {
    font-size: 2.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    transition: color 0.3s ease;
}

.value small {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 0.2rem;
}

.update-badge {
    font-size: 0.75rem;
    color: var(--badge-text);
    background: var(--badge-bg);
    display: inline-block;
    padding: 0.2rem 1rem;
    border-radius: 40px;
    margin-top: 0.6rem;
    transition: background 0.3s ease, color 0.3s ease;
}

.converter-area {
    background: var(--converter-bg);
    border-radius: 40px;
    padding: 2rem 1.8rem;
    margin: 2rem 0 1.5rem;
    transition: background 0.3s ease;
}

.converter-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Botón compartir */
.share-button {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 60px;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.share-button:hover {
    background: var(--refresh-btn-hover);
    transform: scale(1.02);
}

/* Tabs */
.converter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-button {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 40px;
    padding: 0.6rem 1.4rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tab-button.active {
    background: var(--input-focus);
    color: white;
    border-color: var(--input-focus);
}

body.dark-mode .tab-button.active {
    background: #2b6c9e;
    border-color: #2b6c9e;
}

.converter-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.input-row label {
    font-weight: 600;
    color: var(--text-primary);
    width: 140px;
    font-size: 1.1rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.input-row input {
    flex: 1;
    padding: 0.9rem 1.2rem;
    border: none;
    border-radius: 60px;
    font-size: 1.2rem;
    background: var(--input-bg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05), 0 0 0 1px var(--input-border);
    outline: none;
    text-align: right;
    font-weight: 500;
    min-width: 200px;
    color: var(--text-primary);
    transition: background 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

.input-row input:focus {
    box-shadow: 0 0 0 3px var(--input-focus);
}

/* Estilos para la sección de descarga de la APK */
.app-download {
    background: var(--converter-bg);
    border-radius: 40px;
    padding: 1.2rem 1.8rem;
    margin: 2rem 0 1.5rem;
    transition: background 0.3s ease;
}

.app-download-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
}

.app-icon {
    font-size: 2.5rem;
}

.app-text {
    flex: 1;
    min-width: 200px;
    color: var(--text-primary);
}

.app-text strong {
    display: block;
    font-size: 1.2rem;
}

.app-text span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.app-button {
    background: linear-gradient(130deg, #1A2F4F, #2B5F8A);
    color: white;
    padding: 0.8rem 1.8rem;
    border-radius: 60px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    border: none;
    cursor: pointer;
}

.app-button:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 15px rgba(0,0,0,0.25);
}

body.dark-mode .app-button {
    background: linear-gradient(130deg, #2b4a6e, #3a6e9e);
}

/* Sección de donaciones */
.donation-section {
    margin-top: 1rem;
    border: 2px solid #FFDD00;
    background: linear-gradient(145deg, #FFDD0010, #FFAA0010);
    border-radius: 40px;
    padding: 1.5rem 1.8rem;
    transition: all 0.3s ease;
}

.donation-badge {
    background: #FFDD00;
    color: #000000;
    padding: 0.3rem 2rem;
    border-radius: 60px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 1rem;
}

.donation-button {
    background: #FFDD00;
    color: #000000;
    padding: 1.2rem 3rem;
    border-radius: 60px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    display: inline-block;
    border: none;
    cursor: pointer;
}

.donation-button:hover {
    transform: scale(1.05);
}

.flag-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 1.5rem;
    margin: 1rem 0;
}

.flag-container span {
    cursor: default;
    transition: transform 0.2s;
}

.flag-container span:hover {
    transform: scale(1.2);
}

.refresh-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 1.4rem;
    padding: 0.3rem 1rem;
    background: var(--refresh-bg);
    border-radius: 60px;
    transition: background 0.3s ease, color 0.3s ease;
}

.refresh-btn {
    background: none;
    border: none;
    color: #2b5f8a;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.8rem;
    border-radius: 60px;
    transition: background 0.2s;
}

body.dark-mode .refresh-btn {
    color: #7aa9d9;
}

.refresh-btn:hover {
    background: var(--refresh-btn-hover);
}

.error-msg {
    background: var(--error-bg);
    color: var(--error-text);
    border-radius: 60px;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    margin: 0.8rem 0;
    display: none;
}

.error-msg.show {
    display: block;
}

footer {
    text-align: center;
    color: var(--footer-text);
    font-size: 0.8rem;
    margin-top: 2rem;
    transition: color 0.3s ease;
}

.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast-message.show {
    opacity: 1;
}

/* Media queries */
@media (max-width: 700px) {
    .card { padding: 1.5rem 1.2rem; border-radius: 36px; }
    h1 { font-size: 2.5rem; }
    h1 img { width: 160px !important; }
    .subhead { font-size: 0.9rem; margin-bottom: 1.5rem; padding-left: 0.8rem; }
    .rates-grid { gap: 0.8rem; margin: 1.5rem 0; }
    .rate-item { padding: 1.2rem 0.8rem; border-radius: 28px; }
    .currency { font-size: 1.2rem; white-space: normal; }
    .value { font-size: 1.8rem; }
    .update-badge { font-size: 0.7rem; padding: 0.15rem 0.8rem; }
    .donation-button { font-size: 1.2rem; padding: 1rem 2rem; }
    .toast-message { white-space: normal; text-align: center; width: 90%; font-size: 0.8rem; }
}

@media (max-width: 600px) {
    .card { padding: 1.2rem 1rem; border-radius: 32px; }
    h1 { font-size: 2.2rem; }
    h1 img { width: 140px !important; }
    .rates-grid { flex-direction: column; }
    .rate-item { width: 100%; flex: auto; }
    .converter-area { padding: 1.2rem 1rem; border-radius: 30px; }
    .converter-title { font-size: 1.1rem; margin-bottom: 1rem; flex-direction: column; align-items: flex-start; }
    .share-button { align-self: flex-start; margin-top: 0.2rem; }
    .input-row { flex-direction: column; align-items: stretch; gap: 0.2rem; }
    .input-row label { width: auto; font-size: 1rem; margin-left: 0.2rem; white-space: normal; }
    .input-row input { min-width: 0; width: 100%; font-size: 1rem; padding: 0.8rem 1rem; }
    .app-download { padding: 1rem; border-radius: 30px; }
    .app-download-content { flex-direction: column; text-align: center; }
    .app-text { min-width: auto; }
    .app-button { width: 100%; text-align: center; }
    .donation-section { padding: 1.2rem; }
    .donation-button { width: 100%; text-align: center; font-size: 1.3rem; }
    .refresh-indicator { flex-direction: column; gap: 0.5rem; text-align: center; padding: 0.5rem; }
    .refresh-btn { padding: 0.3rem 1rem; width: 100%; max-width: 200px; }
    .theme-toggle { top: 1rem; right: 1rem; padding: 0.3rem 0.8rem; }
}

@media (max-width: 380px) {
    .currency { font-size: 1rem; }
    .value { font-size: 1.5rem; }
    .value small { font-size: 0.8rem; }
    .converter-title { font-size: 1rem; }
    .input-row input { font-size: 0.95rem; padding: 0.7rem; }
    footer { font-size: 0.7rem; }
    .donation-button { font-size: 1.1rem; }
}