/* BOTCYPR - PWA Mobile-First Design */

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-input: #1a1a24;
    --border: #252530;
    --text: #e8e8e8;
    --text-dim: #808090;
    --green: #00c896;
    --red: #ff5252;
    --blue: #4a9eff;
    --yellow: #ffb800;
    --purple: #8b5cf6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    font-size: 12px;
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    padding: 8px;
    padding-bottom: 60px;
}

/* Header */
.header-compacto {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 8px;
    align-items: center;
}

.header-izq {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 150px;
}

.header-izq h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--green);
    letter-spacing: 1px;
}

.header-stats {
    display: flex;
    gap: 6px;
    background: var(--bg-input);
    padding: 6px 10px;
    border-radius: 10px;
}

.mini-stat {
    text-align: center;
    padding: 2px 8px;
}

.mini-stat-num {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--blue);
    font-family: 'SF Mono', monospace;
}

.mini-stat.ganancia .mini-stat-num {
    color: var(--green);
}

.mini-stat-label {
    font-size: 7px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.estado {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-input);
    font-size: 10px;
    font-weight: 600;
}

.estado .indicador {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.estado.detenido .indicador { background: var(--red); }
.estado.corriendo .indicador { background: var(--green); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 200, 150, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(0, 200, 150, 0); }
}

.badge {
    background: var(--yellow);
    color: #000;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 700;
    margin-left: 4px;
}

.header-der {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Par Selector */
.par-selector {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.btn-par {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: transparent;
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-par.activo {
    background: var(--green);
    border-color: var(--green);
    color: #000;
}

.btn-par:not(.activo):active {
    background: var(--bg-input);
}

.btn-comparador {
    padding: 5px 10px;
    border: 1px solid var(--yellow);
    border-radius: 16px;
    background: transparent;
    color: var(--yellow);
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
}

/* Botones */
.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-sm { padding: 6px 10px; font-size: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; }
.btn:active:not(:disabled) { transform: scale(0.96); }

.btn-success { background: var(--green); color: #000; }
.btn-danger { background: var(--red); color: #fff; }
.btn-info { background: var(--blue); color: #fff; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-warning { background: var(--yellow); color: #000; }
.btn-secondary { background: var(--bg-input); color: var(--text); }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
}

.card-compacta {
    padding: 10px;
}

.card h2 {
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Layout */
.layout-principal {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.columna-izq, .columna-der {
    display: contents;
}

/* Precios Grid */
.precios-grid-compacta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.precio-item-mini {
    background: var(--bg-input);
    padding: 8px;
    border-radius: 8px;
}

.precio-item-mini .precio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.precio-item-mini .exchange-nombre {
    font-weight: 600;
    color: var(--blue);
    font-size: 10px;
}

.precio-item-mini .precio-datos {
    font-size: 10px;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.precio-item-mini .bid { color: var(--green); }
.precio-item-mini .ask { color: var(--red); }
.precio-item-mini.deshabilitado { opacity: 0.3; }

/* Toggle */
.toggle-exchange {
    width: 28px;
    height: 14px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    position: relative;
    background: var(--red);
    transition: all 0.2s;
}

.toggle-exchange.activo { background: var(--green); }

.toggle-indicator {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}

.toggle-exchange.activo .toggle-indicator { left: 16px; }

/* Tablas */
.tabla {
    width: 100%;
    border-collapse: collapse;
}

.tabla-mini th, .tabla-mini td {
    padding: 6px 4px;
    text-align: left;
    font-size: 9px;
    border-bottom: 1px solid var(--border);
}

.tabla th {
    background: var(--bg-input);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 8px;
    text-transform: uppercase;
}

.tabla .totales {
    background: var(--bg-input);
}

.tabla .totales td {
    color: var(--green);
    font-weight: 600;
}

.tabla-scroll {
    max-height: 150px;
    overflow-y: auto;
}

/* Orden rapida */
.orden-rapida {
    white-space: nowrap;
}

.btn-mini {
    padding: 3px 6px;
    border: none;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 700;
    cursor: pointer;
}

.btn-compra { background: var(--green); color: #000; }
.btn-venta { background: var(--red); color: #fff; }

/* Card Tabs */
.card-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--green);
    color: #000;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.transfer-info {
    padding: 6px 8px;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 9px;
    color: var(--text-dim);
    text-align: center;
}

/* Orden Form */
.orden-form-compacta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-fila {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.form-fila select, .form-fila input {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 11px;
}

.total-fila {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: var(--bg-input);
    border-radius: 8px;
    font-size: 10px;
}

.total-valor {
    font-weight: 700;
    color: var(--yellow);
}

.orden-resultado {
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    font-size: 10px;
    display: none;
}

.orden-resultado.exito {
    background: rgba(0, 200, 150, 0.1);
    color: var(--green);
    border: 1px solid var(--green);
    display: block;
}

.orden-resultado.error {
    background: rgba(255, 82, 82, 0.1);
    color: var(--red);
    border: 1px solid var(--red);
    display: block;
}

/* Config */
.config-compacta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.config-fila {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-input);
    padding: 6px 8px;
    border-radius: 6px;
}

.config-fila label {
    font-size: 9px;
    color: var(--text-dim);
}

.config-fila input[type="number"] {
    width: 50px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-dark);
    color: var(--text);
    font-size: 10px;
    text-align: right;
}

.config-fila input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.config-fila.full-width {
    grid-column: 1 / -1;
}


/* Historial */
.historial-section {
    max-height: 200px;
}

.historial-section .tabla-scroll {
    max-height: 160px;
}

.fila-operacion { cursor: pointer; }
.fila-operacion:active { background: rgba(74, 158, 255, 0.1); }

.estado-exito { color: var(--green); }
.estado-error { color: var(--red); }

.simulacion-badge, .editado-badge {
    background: var(--yellow);
    color: #000;
    padding: 1px 3px;
    border-radius: 3px;
    font-size: 7px;
    font-weight: 700;
    margin-left: 2px;
}

.editado-badge { background: var(--purple); color: #fff; }

.btn-editar {
    background: var(--bg-input);
    border: none;
    color: var(--text-dim);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
}

/* Tooltip */
.tooltip-operacion {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    z-index: 9999;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    min-width: 200px;
    display: none;
    font-size: 10px;
}

.tooltip-titulo {
    color: var(--blue);
    font-weight: 600;
    font-size: 10px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.tooltip-linea {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.tooltip-linea.fee { color: var(--red); font-size: 9px; }
.tooltip-separador { border-top: 1px dashed var(--border); margin: 4px 0; }
.tooltip-linea.neta { font-weight: 600; }
.tooltip-linea.neta span:last-child { color: var(--green); }

.tooltip-cerrar {
    display: none;
    text-align: center;
    font-size: 8px;
    color: var(--text-dim);
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

/* Mostrar mensaje de cerrar solo en mobile */
@media (max-width: 768px) {
    .tooltip-cerrar { display: block; }
}

/* === MARCOS ANIMADOS PROFESIONALES === */
@keyframes borderGlow {
    0% { border-color: var(--green); box-shadow: 0 0 5px rgba(0, 200, 150, 0.3); }
    25% { border-color: var(--blue); box-shadow: 0 0 5px rgba(74, 158, 255, 0.3); }
    50% { border-color: var(--purple); box-shadow: 0 0 5px rgba(139, 92, 246, 0.3); }
    75% { border-color: var(--yellow); box-shadow: 0 0 5px rgba(255, 184, 0, 0.3); }
    100% { border-color: var(--green); box-shadow: 0 0 5px rgba(0, 200, 150, 0.3); }
}

.strategy-section {
    border: 1px solid var(--green);
    animation: borderGlow 8s ease-in-out infinite;
    margin-top: 12px;
}

/* Maker Strategy */
.maker-section { margin-top: 8px; }
.maker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.maker-header h2 { margin: 0; }
.maker-config-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}
.maker-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.maker-subtitle {
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    margin: 8px 0 4px;
}

/* === SECCIONES COLAPSABLES === */
.collapsible-section {
    margin-bottom: 8px;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.collapsible-header:active {
    background: var(--bg-input);
}

.collapsible-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 11px;
}

.collapsible-icon {
    font-size: 14px;
    color: var(--text-dim);
    transition: transform 0.3s ease;
}

.collapsible-section.open .collapsible-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: var(--bg-card);
    border-radius: 0 0 10px 10px;
    margin-top: -10px;
    padding-top: 10px;
}

.collapsible-section.open .collapsible-content {
    max-height: 500px;
}

.collapsible-section.open .collapsible-header {
    border-radius: 10px 10px 0 0;
    border-bottom: none;
}

.collapsible-inner {
    padding: 10px 12px;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-input);
    border-radius: 20px;
    transition: 0.3s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-dim);
    border-radius: 50%;
    transition: 0.3s;
}
.switch input:checked + .slider { background-color: var(--green); }
.switch input:checked + .slider:before {
    transform: translateX(16px);
    background-color: #000;
}

@media (max-width: 767px) {
    .maker-config-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 10px;
    color: var(--text-dim);
    font-size: 9px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
}

.modal-contenido {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 320px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--green);
    font-size: 14px;
}

.modal-cerrar {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.modal-body { padding: 12px; }
.modal-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.edit-info {
    background: var(--bg-input);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 12px;
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
}

.form-grupo {
    margin-bottom: 10px;
}

.form-grupo label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-dim);
    font-size: 10px;
}

.form-grupo input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 12px;
}

.edit-preview {
    background: var(--bg-input);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 11px;
}

#edit-ganancia-preview {
    font-weight: 700;
    color: var(--green);
}

#edit-ganancia-preview.negativo { color: var(--red); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Desktop */
@media (min-width: 768px) {
    body { font-size: 13px; }
    .container { max-width: 1200px; margin: 0 auto; padding: 12px; }

    .header-compacto { flex-direction: row; justify-content: space-between; align-items: center; }
    .header-izq { justify-content: flex-start; gap: 16px; }
    .header-izq h1 { font-size: 20px; }

    .layout-principal {
        display: grid;
        grid-template-columns: 1fr 300px;
        gap: 12px;
    }

    .columna-izq, .columna-der {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .precios-grid-compacta { grid-template-columns: repeat(4, 1fr); }
    .historial-section { max-height: 300px; }
    .historial-section .tabla-scroll { max-height: 260px; }
}

/* Safe area for notch */
@supports (padding-top: env(safe-area-inset-top)) {
    .container {
        padding-top: calc(8px + env(safe-area-inset-top));
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
        padding-left: calc(8px + env(safe-area-inset-left));
        padding-right: calc(8px + env(safe-area-inset-right));
    }
}

/* --- Login Screen --- */
.pin-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0f;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.pin-screen.hidden { display: none; }
.pin-container {
    background: #12121a;
    padding: 24px;
    border-radius: 20px;
    text-align: center;
    width: 280px;
}
.pin-title {
    color: #00c896;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}
.pin-subtitle {
    color: #808090;
    font-size: 11px;
    margin-bottom: 16px;
}
.login-input {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a24;
    border: 2px solid #2a2a3a;
    border-radius: 12px;
    color: #e8e8e8;
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.login-input:focus { border-color: #00c896; }
.login-btn {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    background: #00c896;
    border: none;
    border-radius: 12px;
    color: #000;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.login-btn:active { opacity: 0.8; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pin-error-msg {
    color: #ff5252;
    margin-top: 12px;
    font-size: 11px;
    min-height: 16px;
}

/* --- Utilidades --- */
.mt-8 { margin-top: 8px; }
.clickable { cursor: pointer; }
.comparador-hint { color: #666; font-size: 11px; margin-top: 15px; text-align: center; }
