:root {
    --bg-body: #0f0f0f;
    --bg-container: rgba(26, 26, 26, 0.95);
    --text-main: #ffffff;
    --text-dim: #888888;
    --border-color: #333;
    --input-bg: #2a2a2a;
    --accent: #33ff99;
    --red-down: #ff4d4d;
    --green-up: #00e676;
    --dropdown-bg: #1e1e1e;
    --shadow-main: 0 30px 100px rgba(0, 0, 0, 0.8);
    --tooltip-bg: rgba(40, 40, 40, 0.95);
    --ad-height: 100px;
    --loading-orange: #ff9800;
}

body.light-mode {
    --bg-body: #f0f2f5;
    --bg-container: #ffffff;
    --text-main: #1a1a1a;
    --text-dim: #666;
    --border-color: #ddd;
    --input-bg: #f5f5f5;
    --accent: #00cc6a;
    --red-down: #e60000;
    --green-up: #00cc6a;
    --dropdown-bg: #ffffff;
    --shadow-main: 0 20px 60px rgba(0, 0, 0, 0.06);
    --tooltip-bg: rgba(255, 255, 255, 0.98);
}

body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    padding: 0;
    transition: background 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    padding: 8px 20px var(--ad-height) 20px;
    box-sizing: border-box;
}

.container {
    background: var(--bg-container);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 24px;
    width: 380px;
    min-width: 380px;
    border: 1px solid var(--border-color);
    position: relative;
    box-sizing: border-box;
    box-shadow: var(--shadow-main);
    transition: opacity 0.4s ease, filter 0.4s ease;
}

/* --- ANIMACIONES DE PRECIO --- */
@keyframes flash-green-solid {
    0%, 100% { color: inherit; }
    10%, 90% { color: var(--green-up); font-weight: 800; }
}
@keyframes flash-red-solid {
    0%, 100% { color: inherit; }
    10%, 90% { color: var(--red-down); font-weight: 800; }
}
@keyframes flash-neutral {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
.flash-up { animation: flash-green-solid 2.5s ease-in-out; }
.flash-down { animation: flash-red-solid 2.5s ease-in-out; }
.flash-neutral { animation: flash-neutral 0.5s ease-in-out; }

/* --- COLORES ESTÁTICOS --- */
.text-static-green { color: var(--green-up) !important; }
.text-static-red { color: var(--red-down) !important; }

/* --- SKELETON LOADING (SHIMMER) --- */
.skeleton-box {
    display: inline-block;
    width: 55px;
    height: 18px;
    border-radius: 4px;
    vertical-align: middle;
    position: relative;
    overflow: hidden;
    background-color: #777; 
    background: linear-gradient(90deg, #333 0%, #666 50%, #333 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

body.light-mode .skeleton-box {
    background: linear-gradient(90deg, #ccc 0%, #fff 50%, #ccc 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* --- RESTO DEL DISEÑO --- */
.ad-footer {
    position: fixed; bottom: 0; left: 0; width: 100%; height: var(--ad-height);
    background: var(--bg-body); border-top: 1px solid var(--border-color);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}

.refresh-wrapper { position: relative; display: flex; align-items: center; gap: 8px; }
.countdown-timer { font-size: 10px; color: var(--text-dim); font-weight: bold; opacity: 0.7; }

#total-container { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; min-height: 45px; }

#total-price { 
    font-size: clamp(24px, 8vw, 34px); 
    font-weight: 800; 
    color: var(--text-main); 
    letter-spacing: -1px; 
    white-space: nowrap; 
    transition: font-size 0.2s ease;
    z-index: 1;
}
#total-price.price-medium { font-size: clamp(20px, 6vw, 26px) !important; }
#total-price.price-small { font-size: clamp(16px, 5vw, 20px) !important; }
@media (max-width: 360px) { #total-price { font-size: 24px; margin-top: 10px; } }

.trend-arrow { font-size: 22px; opacity: 0; transition: opacity 0.3s; display: inline-block; }
.trend-visible { opacity: 1; }
.change-up { color: var(--green-up) !important; }
.change-down { color: var(--red-down) !important; }

.controls-wrapper { position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; z-index: 10; }
.icons-row { display: flex; gap: 6px; }
.ctrl-btn {
    background: var(--input-bg); color: var(--text-dim); border: 1px solid var(--border-color);
    border-radius: 10px; cursor: pointer; width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center; transition: 0.2s; outline: none; font-size: 16px;
}
.selectors-row-top { display: flex; gap: 4px; }
.selectors-row-top select {
    background: var(--input-bg); color: var(--text-dim); border: 1px solid var(--border-color);
    border-radius: 6px; padding: 4px 6px; font-size: 10px; outline: none; cursor: pointer; max-width: 80px;
}
.header-container { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
h2 { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; margin: 0; }
.chart-container { position: relative; margin-bottom: 20px; height: 160px; width: 100%; }

.inputs { display: flex; gap: 8px; margin-bottom: 20px; position: relative; }
input {
    background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-main);
    padding: 12px; border-radius: 14px; width: 100%; outline: none; font-size: 16px; box-sizing: border-box;
}
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
button#add-btn {
    background: var(--accent); border: none; padding: 0 18px; border-radius: 14px;
    cursor: pointer; font-weight: bold; font-size: 22px; color: #000;
}
.custom-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; background: var(--dropdown-bg);
    border: 1px solid var(--border-color); border-radius: 12px; max-height: 200px; overflow-y: auto;
    z-index: 9999; display: none; margin-top: 8px; box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}
.dropdown-item { display: flex; align-items: center; padding: 12px; cursor: pointer; border-bottom: 1px solid var(--border-color); }
.dropdown-item img { width: 24px; height: 24px; border-radius: 50%; margin-right: 12px; }

.list-header { display: flex; justify-content: space-between; align-items: center; padding: 0 5px 10px 5px; border-bottom: 1px solid var(--border-color); margin-bottom: 10px; }
.list-header span { font-size: 9px; color: var(--text-dim); font-weight: 800; text-transform: uppercase; }
#timeSelect {
    background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border-color);
    border-radius: 6px; font-size: 10px; font-weight: 800; cursor: pointer; outline: none; padding: 3px 6px;
}
.asset-list { max-height: 260px; overflow-y: auto; padding-right: 8px; transition: opacity 0.3s ease; }
.asset-list::-webkit-scrollbar { width: 4px; }
.asset-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.asset-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 6px; border-bottom: 1px solid var(--border-color); border-radius: 8px; }
.asset-ticker { font-weight: 800; color: var(--text-main); font-size: 16px; }
.asset-info { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.asset-value { text-align: right; font-weight: bold; font-size: 15px; color: var(--text-main); }
.change-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: bold; }
.remove-asset-btn { color: var(--text-dim); background: none; border: none; cursor: pointer; margin-left: 12px; font-size: 14px; opacity: 0.3; }
.backup-btn { flex: 1; background: none; border: 1px dashed var(--border-color); color: var(--text-dim); font-size: 9px; padding: 10px; border-radius: 10px; cursor: pointer; text-transform: uppercase; }

/* MODO PIP */
.is-pip body { background: var(--bg-body) !important; overflow: hidden; }
.is-pip .container { border: none; box-shadow: none; background: transparent; padding: 15px; width: 100%; min-width: 0; backdrop-filter: none; }
.is-pip .controls-wrapper, .is-pip .header-container, .is-pip .chart-container, .is-pip .inputs, .is-pip .bottom-zone, .is-pip .ad-footer, .is-pip .remove-asset-btn { display: none !important; }
.is-pip .app-footer-link { display: none !important; }
.is-pip #total-container { justify-content: center !important; margin-top: 0; margin-bottom: 15px; }
.is-pip .asset-list { max-height: 90vh; }


/* LOADING / OPTIMISTIC UI */
.row-loading { opacity: 0.6; pointer-events: none; background: rgba(128, 128, 128, 0.1); animation: pulse 1.5s infinite ease-in-out; position: relative; }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 0.9; } 100% { opacity: 0.6; } }
.status-text { font-size: 10px; color: var(--loading-orange); font-weight: 800; margin-left: 6px; text-transform: uppercase; font-style: italic; background: rgba(255, 166, 0, 0.15); padding: 2px 4px; border-radius: 4px; }
.stale-mode { opacity: 0.6 !important; pointer-events: none; }
.chart-stale canvas { filter: grayscale(100%) opacity(0.5); transition: filter 0.5s ease; }

/* TUTORIAL / EMPTY STATE */
.empty-state-container { display: flex; flex-direction: column; justify-content: center; height: 280px; opacity: 0.5; pointer-events: none; user-select: none; width: fit-content; margin: 0 auto; text-align: left; }
.tutorial-step { margin: 6px 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; font-weight: 500; }
body.light-mode .empty-state-container { opacity: 0.6; color: #666; }

/* ANIMACIÓN CHART */
@keyframes erratic-spin {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(20deg); animation-timing-function: ease-out; } 
    40% { transform: rotate(160deg); animation-timing-function: ease-in-out; } 
    45% { transform: rotate(150deg); animation-timing-function: ease-in; } 
    60% { transform: rotate(240deg); animation-timing-function: linear; } 
    85% { transform: rotate(340deg); animation-timing-function: ease-out; } 
    100% { transform: rotate(360deg); }
}
.chart-loading-state canvas { animation: erratic-spin 3s infinite linear; transform-origin: center center; opacity: 0.6; }

/* --- FOOTER LINK (DISIMULADO) --- */
.app-footer-link {
    margin-top: 15px;
    text-align: center;
    width: 100%;
}
.app-footer-link a {
    color: var(--text-dim);
    font-size: 9px;
    text-decoration: none;
    opacity: 0.4;
    transition: opacity 0.2s;
    
    /* AÑADIDO PARA QUE SALGA LA MANITA SIN HREF */
    cursor: pointer;
}
.app-footer-link a:hover { 
    opacity: 1; 
    text-decoration: underline;
}

/* --- VENTANA MODAL (POP-UP) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
    z-index: 9999; display: none; align-items: center; justify-content: center;
    padding: 20px; box-sizing: border-box; opacity: 0; transition: opacity 0.3s ease;
}
.modal-overlay.open { display: flex; opacity: 1; }
.modal-content {
    background: var(--bg-container); border: 1px solid var(--border-color);
    width: 100%; max-width: 500px; max-height: 80vh;
    border-radius: 20px; padding: 25px; position: relative;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.close-modal { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; color: var(--text-dim); line-height: 1; }
.close-modal:hover { color: var(--text-main); }
#about-title { font-size: 18px; margin-top: 0; margin-bottom: 15px; color: var(--text-main); letter-spacing: 0.5px; }
.about-text { font-size: 14px; line-height: 1.6; color: var(--text-dim); text-align: left; }
.about-text p { margin-bottom: 12px; }
.about-text strong { color: var(--text-main); }
.legal-footer { margin-top: 20px; border-top: 1px solid var(--border-color); padding-top: 15px; font-size: 10px; color: var(--text-dim); text-align: center; }