/*
 * GENERADOR DE EXPERT ADVISORS (EA) — CSS
 * Joel Pasapera · Trading Algorítmico
 * Prefijo .ea-gen__ (BEM) para evitar colisiones
 */

/* ==============================
   SECCIÓN RAÍZ
   ============================== */
.ea-gen {
    position: relative;
    padding: 100px 0 80px;
    background: #070e1f;
    overflow: hidden;
    color: #e2e8f0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.ea-gen__bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(16,185,129,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16,185,129,.04) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

.ea-gen::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 55% 45% at 20% 30%, rgba(16,185,129,.10), transparent),
        radial-gradient(ellipse 50% 40% at 80% 75%, rgba(59,130,246,.08), transparent);
    pointer-events: none;
}

.ea-gen__container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ==============================
   HEADER
   ============================== */
.ea-gen__header {
    text-align: center;
    margin-bottom: 48px;
}

.ea-gen__pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 22px;
    border-radius: 50px;
    background: rgba(16,185,129,.15);
    border: 1px solid rgba(16,185,129,.35);
    color: #34d399;
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 20px;
    backdrop-filter: blur(8px);
}

.ea-gen__pill-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981, 0 0 20px rgba(16,185,129,.4);
    animation: ea-pulse 1.8s ease-in-out infinite;
}

@keyframes ea-pulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50%     { opacity: .45; transform: scale(1.35); }
}

.ea-gen__title {
    font-size: clamp(2rem, 4.5vw, 3rem);
    font-weight: 800;
    color: #fff;
    margin-bottom: 14px;
    letter-spacing: -.02em;
}

.ea-gen__title-accent {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ea-gen__desc {
    font-size: 1.1rem;
    color: rgba(255,255,255,.55);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ==============================
   LAYOUT PRINCIPAL
   ============================== */
.ea-gen__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

/* ==============================
   PANEL DE ENTRADA (izquierda)
   ============================== */
.ea-gen__input-panel {
    background: rgba(15,23,42,.65);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.ea-gen__input-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    background: rgba(255,255,255,.02);
}

.ea-gen__input-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ea-gen__input-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.ea-gen__input-subtitle {
    font-size: .82rem;
    color: rgba(255,255,255,.4);
    margin-top: 2px;
}

.ea-gen__input-body {
    padding: 24px;
}

/* Campo nombre del EA */
.ea-gen__name-group {
    margin-bottom: 16px;
}

.ea-gen__name-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .85rem;
    font-weight: 600;
    color: rgba(255,255,255,.6);
    margin-bottom: 8px;
}

.ea-gen__name-label i {
    color: #10b981;
    font-size: .8rem;
}

.ea-gen__name-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0,0,0,.25);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    color: #e2e8f0;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: .92rem;
    transition: border-color .25s ease, box-shadow .25s ease;
    outline: none;
}

.ea-gen__name-input::placeholder {
    color: rgba(255,255,255,.2);
    font-family: 'Inter', sans-serif;
}

.ea-gen__name-input:focus {
    border-color: rgba(16,185,129,.5);
    box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}

/* Textarea */
.ea-gen__prompt-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .85rem;
    font-weight: 600;
    color: rgba(255,255,255,.6);
    margin-bottom: 8px;
}

.ea-gen__prompt-label i {
    color: #3b82f6;
    font-size: .8rem;
}

.ea-gen__textarea {
    width: 100%;
    min-height: 180px;
    max-height: 400px;
    padding: 16px;
    background: rgba(0,0,0,.25);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    color: #e2e8f0;
    font-family: 'Inter', sans-serif;
    font-size: .92rem;
    line-height: 1.7;
    resize: vertical;
    transition: border-color .25s ease, box-shadow .25s ease;
    outline: none;
}

.ea-gen__textarea::placeholder {
    color: rgba(255,255,255,.22);
}

.ea-gen__textarea:focus {
    border-color: rgba(16,185,129,.5);
    box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}

/* Contador de caracteres */
.ea-gen__char-count {
    text-align: right;
    font-size: .75rem;
    color: rgba(255,255,255,.25);
    margin-top: 6px;
}

/* Sugerencias rápidas */
.ea-gen__suggestions-label {
    font-size: .8rem;
    font-weight: 600;
    color: rgba(255,255,255,.35);
    margin: 18px 0 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.ea-gen__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
}

.ea-gen__suggestion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    background: rgba(255,255,255,.04);
    color: rgba(255,255,255,.6);
    font-weight: 500;
    font-size: .82rem;
    cursor: pointer;
    transition: all .25s ease;
    font-family: inherit;
}

.ea-gen__suggestion:hover {
    background: rgba(16,185,129,.15);
    border-color: rgba(16,185,129,.4);
    color: #fff;
    transform: translateY(-1px);
}

.ea-gen__suggestion i {
    font-size: .75rem;
    color: #10b981;
}

/* Botón generar */
.ea-gen__submit-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ea-gen__submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .25s ease, box-shadow .25s ease;
    font-family: inherit;
    flex-shrink: 0;
}

.ea-gen__submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 22px rgba(16,185,129,.35);
}

.ea-gen__submit-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ea-gen__submit-hint {
    font-size: .8rem;
    color: rgba(255,255,255,.3);
}

/* ==============================
   PANEL DE SALIDA (derecha)
   ============================== */
.ea-gen__output-panel {
    background: rgba(15,23,42,.65);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    /* Altura fija para que siempre tenga scroll interno */
    height: 620px;
}

/* Barra superior tipo IDE */
.ea-gen__output-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    background: rgba(255,255,255,.02);
    flex-shrink: 0;
}

.ea-gen__output-dots {
    display: flex;
    gap: 7px;
}

.ea-gen__dot {
    width: 11px; height: 11px;
    border-radius: 50%;
}
.ea-gen__dot--red    { background: #ef4444; }
.ea-gen__dot--yellow { background: #f59e0b; }
.ea-gen__dot--green  { background: #10b981; }

.ea-gen__output-filename {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'Fira Code', monospace;
    font-size: .82rem;
    color: rgba(255,255,255,.45);
}
.ea-gen__output-filename i { color: #10b981; }

.ea-gen__output-actions {
    display: flex;
    gap: 8px;
}

.ea-gen__action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 7px;
    background: rgba(255,255,255,.05);
    color: rgba(255,255,255,.6);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    font-family: inherit;
}

.ea-gen__action-btn:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-color: rgba(255,255,255,.2);
}

.ea-gen__action-btn--download {
    background: rgba(16,185,129,.15);
    border-color: rgba(16,185,129,.3);
    color: #34d399;
}

.ea-gen__action-btn--download:hover {
    background: rgba(16,185,129,.25);
    color: #fff;
}

/* ==============================
   ÁREA DEL CÓDIGO — SCROLL CORRECTO
   ============================== */
.ea-gen__code-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
    min-height: 0; /* necesario para que flex + overflow funcione */
}

/* Scrollbar personalizado */
.ea-gen__code-area::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.ea-gen__code-area::-webkit-scrollbar-track {
    background: rgba(255,255,255,.03);
}

.ea-gen__code-area::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
    border-radius: 4px;
}

.ea-gen__code-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.2);
}

.ea-gen__code-area::-webkit-scrollbar-corner {
    background: transparent;
}

/* Bloque de código */
.ea-gen__code-pre {
    margin: 0;
    padding: 20px 24px;
    font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', 'Courier New', monospace;
    font-size: .82rem;
    line-height: 1.7;
    color: #cbd5e1;
    white-space: pre;       /* pre — respetar espacios e indentación */
    word-break: normal;
    overflow-wrap: normal;
    tab-size: 4;
    counter-reset: line;
}

/* Números de línea opcionales (via JS) */
.ea-gen__code-pre .code-line {
    display: block;
}

.ea-gen__code-pre .code-line::before {
    counter-increment: line;
    content: counter(line);
    display: inline-block;
    width: 36px;
    margin-right: 18px;
    text-align: right;
    color: rgba(255,255,255,.12);
    font-size: .75rem;
    user-select: none;
    -webkit-user-select: none;
}

/* ==============================
   SYNTAX HIGHLIGHTING
   ============================== */
.ea-gen__code-pre .tok-comment  { color: #6b7280; font-style: italic; }
.ea-gen__code-pre .tok-keyword  { color: #c084fc; }
.ea-gen__code-pre .tok-type     { color: #60a5fa; }
.ea-gen__code-pre .tok-function { color: #34d399; }
.ea-gen__code-pre .tok-string   { color: #fbbf24; }
.ea-gen__code-pre .tok-number   { color: #fb923c; }
.ea-gen__code-pre .tok-preproc  { color: #f87171; }
.ea-gen__code-pre .tok-symbol   { color: #94a3b8; }

/* ==============================
   ESTADOS: EMPTY / LOADING / ERROR
   ============================== */
.ea-gen__empty-state,
.ea-gen__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 340px;
    text-align: center;
    padding: 40px 30px;
    color: rgba(255,255,255,.3);
}

.ea-gen__empty-icon {
    width: 80px; height: 80px;
    background: rgba(16,185,129,.08);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: rgba(16,185,129,.35);
}

.ea-gen__empty-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: rgba(255,255,255,.5);
    margin-bottom: 10px;
}

.ea-gen__empty-desc {
    font-size: .9rem;
    line-height: 1.5;
    max-width: 320px;
}

.ea-gen__spinner {
    width: 44px; height: 44px;
    border: 3px solid rgba(16,185,129,.2);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: ea-spin .8s linear infinite;
    margin-bottom: 18px;
}

@keyframes ea-spin { to { transform: rotate(360deg); } }

.ea-gen__loading-text {
    color: rgba(255,255,255,.45);
    font-size: .92rem;
    font-weight: 500;
}

.ea-gen__loading-sub {
    color: rgba(255,255,255,.25);
    font-size: .8rem;
    margin-top: 4px;
}

/* Barra de estado inferior */
.ea-gen__output-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-top: 1px solid rgba(255,255,255,.06);
    background: rgba(255,255,255,.02);
    font-size: .78rem;
    color: rgba(255,255,255,.35);
    flex-shrink: 0;
}

.ea-gen__status-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ea-gen__status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
}

.ea-gen__status-dot.active {
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
    animation: ea-pulse 2s ease-in-out infinite;
}

/* ==============================
   FEATURES ROW
   ============================== */
.ea-gen__features {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 48px;
}

.ea-gen__feature {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    transition: all .3s ease;
}

.ea-gen__feature:hover {
    background: rgba(255,255,255,.06);
    border-color: rgba(16,185,129,.2);
    transform: translateY(-3px);
}

.ea-gen__feature-icon {
    width: 48px; height: 48px;
    margin: 0 auto 14px;
    background: rgba(16,185,129,.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #34d399;
}

.ea-gen__feature-title {
    font-size: .92rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
}

.ea-gen__feature-desc {
    font-size: .8rem;
    color: rgba(255,255,255,.4);
    line-height: 1.4;
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 1024px) {
    .ea-gen__body {
        grid-template-columns: 1fr;
    }
    .ea-gen__output-panel {
        height: 500px;
    }
    .ea-gen__features {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .ea-gen { padding: 70px 0 60px; }
    .ea-gen__features {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }
    .ea-gen__submit-row {
        flex-direction: column;
        align-items: stretch;
    }
    .ea-gen__submit-btn {
        justify-content: center;
    }
    .ea-gen__output-actions {
        flex-wrap: wrap;
    }
    .ea-gen__output-panel {
        height: 450px;
    }
}

@media (max-width: 480px) {
    .ea-gen__container { padding: 0 16px; }
    .ea-gen__features { grid-template-columns: 1fr; }
    .ea-gen__suggestions { justify-content: center; }
    .ea-gen__output-panel { height: 400px; }
}
