/* ============================================================
   The fAIfth Trader – WIZARD PREMIUM CSS (CORREGIDO)
   Tema dual (light/dark), sidebar estrecho expandible, switches iOS
   ============================================================ */

/* ------------------------------------------------------------
   VARIABLES DE TEMA (LIGHT)
------------------------------------------------------------ */
:root,
:root[data-theme="light"] {
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #1e1e1e;
    --text-muted: #5f6b7a;
    --border: #dce2eb;

    --primary: #1E6FD9;
    --primary-hover: #155bb1;

    --switch-off: #cfd6e0;
    --switch-on: var(--primary);
    --switch-knob: #ffffff;

    --sidebar-bg: #ffffff;
    --sidebar-hover: rgba(30,111,217,0.08);
    --sidebar-active: rgba(30,111,217,0.15);
}

/* ------------------------------------------------------------
   VARIABLES DE TEMA (DARK)
------------------------------------------------------------ */
:root[data-theme="dark"] {
    --bg: #0d1422;
    --bg-card: #111a2c;
    --text: #e6edf3;
    --text-muted: #a8b3c3;
    --border: #1f2a3a;

    --primary: #1E6FD9;
    --primary-hover: #3b8aff;

    --switch-off: #3a4556;
    --switch-on: #1E6FD9;
    --switch-knob: #ffffff;

    --sidebar-bg: #0f1828;
    --sidebar-hover: rgba(30,111,217,0.12);
    --sidebar-active: rgba(30,111,217,0.20);
}

/* ------------------------------------------------------------
   RESET & BASE
------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ------------------------------------------------------------
   ESTRUCTURA PRINCIPAL
------------------------------------------------------------ */
#wizard_root {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* ============================================================
   SIDEBAR ESTRECHO + EXPANDIBLE (CORREGIDO)
============================================================ */
.sidebar {
    width: 64px;                       /* Ancho colapsado */
    min-width: 64px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    transition: width 0.3s ease;
    overflow: hidden;                  /* Oculta contenido que sobresale */
    flex-shrink: 0;
}

/* Expandir al pasar el mouse */
.sidebar:hover {
    width: 240px;
}

/* Items del menú */
.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;               /* Evita salto de línea */
    border-left: 3px solid transparent;
    transition: all 0.25s ease;
    overflow: hidden;                  /* CLAVE: oculta texto que sobresale */
}

.menu-item i {
    font-size: 20px;
    min-width: 20px;                   /* Ancho fijo para el icono */
    text-align: center;
    flex-shrink: 0;                    /* No reducir el icono */
}

/* Texto del menú - se oculta cuando no hay espacio */
.menu-item .menu-text {
    opacity: 0;                        /* Invisible por defecto */
    transition: opacity 0.2s ease 0.1s;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mostrar texto solo cuando el sidebar está expandido */
.sidebar:hover .menu-item .menu-text {
    opacity: 1;
}

.menu-item:hover {
    background: var(--sidebar-hover);
}

.menu-item.active {
    background: var(--sidebar-active);
    border-left-color: var(--primary);
    font-weight: 600;
}

.menu-item.active i {
    color: var(--primary);
}

/* Separador en el sidebar */
.sidebar hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 15px 20px;
}

/* ============================================================
   MAIN CONTENT
============================================================ */
.main-container {
    flex: 1;
    padding: 40px 50px;
    overflow-y: auto;
    background: var(--bg);
}

.step-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.step-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 25px;
}

.step-content {
    min-height: 300px;
}

/* ============================================================
   TARJETAS / CARDS
============================================================ */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-body {
    padding: 0;
}

/* ============================================================
   FORMULARIOS
============================================================ */
.form-control,
.form-select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    background: var(--bg);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 111, 217, 0.15);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
}

/* ============================================================
   SWITCH iOS PREMIUM
============================================================ */
.switch-ios {
    position: relative;
    width: 46px;
    height: 26px;
    background: var(--switch-off);
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.25s ease;
}

.switch-ios .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    height: 20px;
    width: 20px;
    background: var(--switch-knob);
    border-radius: 50%;
    transition: left 0.25s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.switch-ios.active {
    background: var(--switch-on);
}

.switch-ios.active .knob {
    left: 23px;
}

.switch-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bootstrap switch override para tema */
.form-check-input {
    background-color: var(--switch-off);
    border-color: var(--border);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(30, 111, 217, 0.2);
}

/* ============================================================
   TABLAS
============================================================ */
.table {
    color: var(--text);
    background: var(--bg-card) !important;
    --bs-table-bg: var(--bg-card);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--sidebar-hover);
    --bs-table-hover-bg: var(--sidebar-hover);
    --bs-table-hover-color: var(--text);
}

.table thead th {
    background: var(--bg) !important;
    color: var(--text-muted) !important;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border) !important;
    padding: 12px;
}

.table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border) !important;
    vertical-align: middle;
    background: transparent !important;
    color: var(--text) !important;
}

.table tbody tr {
    background: var(--bg-card) !important;
}

.table tbody tr:hover {
    background: var(--sidebar-hover) !important;
}

/* Fix para table-hover de Bootstrap */
.table-hover > tbody > tr:hover > * {
    background: var(--sidebar-hover) !important;
    color: var(--text) !important;
}

/* ============================================================
   BOTONES
============================================================ */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid #ef5350;
    color: #ef5350;
}

.btn-outline-danger:hover {
    background: #ef5350;
    color: #fff;
}

/* Botones navegación */
.navigation-buttons {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.btn-nav {
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-prev {
    background: var(--border);
    color: var(--text);
}

.btn-prev:hover {
    background: var(--text-muted);
    color: #fff;
}

.btn-next {
    background: var(--primary);
    color: #fff;
}

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

/* Botón guardar borrador */
.save-draft-wrapper {
    margin-top: 15px;
    text-align: right;
}

.btn-draft {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s ease;
}

.btn-draft:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================================
   TOAST NOTIFICATIONS
============================================================ */
#toast-container {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 99999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    color: var(--text);
    margin-bottom: 10px;
    animation: slideInRight 0.3s ease;
    transition: opacity 0.3s ease;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.toast-success {
    border-left: 4px solid #26a69a;
}

.toast.toast-error {
    border-left: 4px solid #ef5350;
}

.toast.toast-warning {
    border-left: 4px solid #f0b90b;
}

.toast.toast-info {
    border-left: 4px solid var(--primary);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   SWITCH TEMA (iOS) – ABAJO IZQUIERDA
============================================================ */
.theme-toggle-container {
    position: fixed;
    bottom: 22px;
    left: 22px;
    z-index: 9999;
}

.theme-toggle {
    width: 60px;
    height: 32px;
    background: var(--switch-off);
    border-radius: 40px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    cursor: pointer;
    transition: background 0.25s ease;
}

.theme-toggle .icon {
    font-size: 14px;
    color: #ffffff;
    z-index: 1;
}

.theme-toggle .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    height: 26px;
    width: 26px;
    border-radius: 50%;
    background: var(--switch-knob);
    transition: left 0.25s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.theme-toggle.active {
    background: var(--switch-on);
}

.theme-toggle.active .knob {
    left: 31px;
}

/* ============================================================
   ALERTAS
============================================================ */
.alert {
    border-radius: 10px;
    padding: 14px 18px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.alert-info {
    border-left: 4px solid var(--primary);
}

.alert-warning,
.premium-hint {
    border-left: 4px solid #f0b90b;
}

.alert-danger {
    border-left: 4px solid #ef5350;
}

.alert-success {
    border-left: 4px solid #26a69a;
}

/* ============================================================
   BADGES
============================================================ */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-active {
    background: rgba(38, 166, 154, 0.15);
    color: #26a69a;
}

.badge-inactive {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-muted);
}

/* ============================================================
   ANIMACIONES
============================================================ */
.fade-in {
    animation: fadeIn 0.35s ease;
}

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

/* ============================================================
   ACCORDION (Bootstrap override)
============================================================ */
.accordion-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px !important;
    margin-bottom: 10px;
    overflow: hidden;
}

.accordion-button {
    background: var(--bg-card);
    color: var(--text);
    font-weight: 600;
    padding: 16px 20px;
}

.accordion-button:not(.collapsed) {
    background: var(--sidebar-hover);
    color: var(--text);
    box-shadow: none;
}

.accordion-button:focus {
    box-shadow: none;
    border-color: var(--border);
}

.accordion-body {
    background: var(--bg-card);
    color: var(--text);
    padding: 20px;
}

/* Invertir flecha en modo oscuro */
[data-theme="dark"] .accordion-button::after {
    filter: invert(1);
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 900px) {
    .sidebar {
        width: 64px;
    }
    
    .sidebar:hover {
        width: 64px;  /* No expandir en móvil */
    }
    
    .sidebar:hover .menu-item .menu-text {
        opacity: 0;   /* Mantener oculto en móvil */
    }
    
    .main-container {
        padding: 20px;
    }
    
    .navigation-buttons {
        flex-direction: column;
    }
    
    .btn-nav {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
    }
    
    .main-container {
        margin-left: 64px;
        width: calc(100% - 64px);
    }
}

/* ============================================================
   ESTILOS PREMIUM ADICIONALES (S1)
============================================================ */
:root {
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --shadow-premium: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-light: 0 4px 16px rgba(0,0,0,0.06);
    --transition-fast: 0.15s ease;
}

.s1-card {
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-light);
}

.title-premium {
    font-family: "Inter", sans-serif;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.premium-badge {
    background: var(--border) !important;
    color: var(--text) !important;
    font-size: 0.85rem;
    padding: 6px 12px;
}

.premium-select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.premium-select:hover {
    border-color: var(--primary);
}

.premium-btn {
    border-radius: var(--radius-md);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(30, 111, 217, 0.25);
}

.premium-hint {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-light);
}

/* Tabla de activos */
#selectedSymbols .table {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card) !important;
}

#selectedSymbols .table thead th {
    background: var(--bg) !important;
    color: var(--text-muted) !important;
}

#selectedSymbols .table td {
    padding: 14px 12px !important;
    background: var(--bg-card) !important;
    color: var(--text) !important;
}

#selectedSymbols .table tbody tr {
    background: var(--bg-card) !important;
}

#selectedSymbols .table tbody tr:hover,
#selectedSymbols .table tbody tr:hover td {
    background: var(--sidebar-hover) !important;
}
