/* ==========================================================================
   BETO HUB SAAS - MODULE: STRATEGY & SIMULATOR STYLES
   v0.13.0 - Modularization phase
   ========================================================================== */

/* --- Filters & Header of Strategy Library --- */
.beto-strategy-library__filters {
    display: flex;
    gap: var(--space-s);
    align-items: center;
}

/* --- Sidebar: Strategy Box (Criação de Estratégia) --- */
.beto-strategy-box__head {
    margin-bottom: var(--space-s);
}
.beto-strategy-box__head h3 {
    margin: 0;
    color: var(--hub-text);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-semibold);
}
.beto-strategy-box__head span {
    color: var(--hub-text-muted);
    font-size: var(--hub-text-label);
}

/* --- Strategy Library and Cards --- */
.beto-strategy-library {
    display: grid;
    gap: var(--hub-view-section-gap, var(--space-s));
}

.beto-strategy-library:has([data-strategy-active-view]:not([hidden])) {
    min-height: 100%;
    height: calc(100vh - (var(--hub-view-section-gap) * 2));
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
}

.beto-strategy-library:has([data-strategy-active-view]:not([hidden])) .beto-strategy-active-view {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--hub-view-section-gap, var(--space-s));
    padding-top: 0;
    min-height: 0;
}

.beto-strategy-library:has([data-strategy-active-view]:not([hidden])) .beto-active-summary {
    gap: var(--hub-view-section-gap, var(--space-s));
}

.beto-strategy-library:has([data-strategy-active-view]:not([hidden])) .beto-active-table-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
}

.beto-strategy-library:has([data-strategy-active-view]:not([hidden])) .beto-active-table-container .hub-table-wrap {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

.beto-app[data-strategy-mode="editor"] .beto-strategy-library {
    display: none;
}

.beto-app[data-strategy-mode="library"] .beto-sim-panel {
    display: none;
}

.beto-app[data-view="estrategia"] .beto-sidebar .beto-sidebar-panel--motor,
.beto-app[data-view="simulador"] .beto-sidebar .beto-sidebar-panel--motor {
    display: none;
}

.beto-strategy-editor-drawer {
    z-index: 100150;
}

.beto-strategy-editor-drawer .hub-drawer__overlay {
    background: rgba(8, 10, 14, 0.26);
}

.beto-strategy-editor-modal__body {
    display: block;
    overflow: auto;
}

.beto-strategy-editor-modal__footer {
    gap: var(--space-xs);
}

.beto-strategy-editor-form {
    display: grid;
    gap: var(--space-s);
}

.beto-strategy-editor-form.beto-sidebar-panel--motor {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.beto-strategy-editor-form .hub-form-grid,
.beto-strategy-editor-form .hub-form-grid--compact {
    grid-template-columns: 1fr;
}

.beto-strategy-editor-form .beto-grid-2-cols .hub-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.beto-strategy-editor-form .beto-control-section,
.beto-strategy-editor-form .beto-strategy-box,
.beto-strategy-editor-form .beto-scenario-box,
.beto-strategy-editor-form .beto-advanced-rules {
    margin: 0;
}

.beto-strategy-save-actions [data-open-strategy-editor] {
    display: none;
}

.beto-strategy-editor-launcher {
    position: fixed;
    right: var(--space-m);
    bottom: var(--space-m);
    z-index: 100120;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--hub-button-height);
    padding: 0 var(--space-s);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-semibold);
    white-space: nowrap;
    min-width: 148px;
    box-shadow: var(--hub-modal-shadow);
}

.beto-app[data-view="estrategia"][data-strategy-mode="editor"] .beto-strategy-save-actions [data-save-strategy],
.beto-app[data-view="estrategia"][data-strategy-mode="editor"] .beto-strategy-save-actions #beto-save-as-strategy {
    display: none;
}

.beto-app[data-view="estrategia"][data-strategy-mode="editor"] .beto-strategy-save-actions {
    width: 0;
    min-width: 0;
    overflow: hidden;
}

.beto-app[data-view="estrategia"][data-strategy-mode="editor"] .beto-strategy-save-actions [data-open-strategy-editor] {
    display: none;
}

.beto-strategy-library__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-m);
}

.beto-strategy-card {
    display: grid;
    gap: var(--space-s);
    min-height: 220px;
    padding: var(--space-m);
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    background:
        linear-gradient(135deg, rgba(203, 123, 55, 0.055), transparent 48%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 70%),
        var(--hub-surface-raised);
}

.beto-strategy-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.beto-strategy-card__meta span {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 0 9px;
    border: 1px solid var(--hub-border);
    border-radius: 999px;
    color: var(--hub-text-muted);
    font-size: var(--hub-text-eyebrow);
    font-weight: var(--hub-weight-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.beto-strategy-card__meta .is-global {
    border-color: rgba(203, 123, 55, 0.32);
    background: rgba(203, 123, 55, 0.1);
    color: var(--hub-primary);
}

.beto-strategy-card h2 {
    margin: 0;
    color: var(--hub-text);
    font-size: var(--hub-text-heading);
    line-height: 1.18;
    font-weight: var(--hub-weight-medium);
}

.beto-strategy-card p {
    margin: 0;
    color: var(--hub-text-muted);
    font-size: var(--hub-text-table);
    line-height: var(--hub-leading-normal);
}

.beto-strategy-rules-grid {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    background: rgba(0, 0, 0, 0.18);
}

.beto-strategy-rule-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    color: var(--hub-text-muted);
    font-size: var(--hub-text-label);
    line-height: 1.2;
}

.beto-strategy-rule-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.beto-strategy-rule-row strong {
    flex: 0 0 auto;
    color: var(--hub-text);
    font-size: var(--hub-text-label);
    font-weight: var(--hub-weight-semibold);
}

.beto-strategy-rule-row--head {
    padding-bottom: 6px;
    border-bottom: 1px solid var(--hub-border);
    color: var(--hub-text);
    font-size: var(--hub-text-eyebrow);
    font-weight: var(--hub-weight-bold)
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.beto-strategy-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: auto;
}

.beto-strategy-card__actions .beto-button {
    flex: 1 1 130px;
}

.beto-strategy-card__actions [data-delete-strategy] {
    flex-basis: 100%;
}

/* --- Estruturas de Aplicação (Estratégia) --- */
.beto-strategy-app-list {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--hub-border);
}

.beto-strategy-app-list h4 {
    font-size: var(--hub-text-label);
    text-transform: uppercase;
    color: var(--hub-text-muted);
    margin: 0 0 8px 0;
    letter-spacing: 0.5px;
}

.beto-strategy-app-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 4px;
}

.beto-strategy-app-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 10px;
    align-items: center;
    padding: 4px 0;
    font-size: var(--hub-text-table);
}

.beto-strategy-app-item > div:first-child {
    min-width: 0;
}

.beto-strategy-app-item strong {
    color: var(--hub-text);
}

.beto-strategy-app-item span.period {
    color: var(--hub-text-muted);
    margin-left: 8px;
}

.beto-strategy-app-item__badges {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    min-width: max-content;
}

.beto-strategy-app-item__badges .beto-badge {
    min-width: max-content;
    white-space: nowrap;
}

.beto-strategy-app-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--hub-border);
    color: var(--hub-text-muted);
    font-size: var(--hub-text-table);
}

.beto-strategy-app-summary .beto-link-button {
    margin-top: 0;
    font-size: var(--hub-text-table);
}

.beto-strategy-app-empty {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--hub-border);
}

.beto-strategy-app-empty p {
    margin: 0;
    font-size: var(--hub-text-table);
    color: var(--hub-text-muted);
}

.beto-strategy-app-empty .beto-button {
    margin-top: 8px;
}

.beto-strategy-conflict-alert {
    background: rgba(220, 53, 69, 0.1);
    border-left: 4px solid #dc3545;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: var(--hub-radius);
    font-family: var(--beto-font);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-light);
    line-height: var(--hub-leading-snug);
    color: var(--hub-text);
}

.beto-strategy-conflict-alert strong {
    color: var(--hub-danger);
    display: block;
    margin-bottom: 4px;
}

.beto-strategy-conflict-alert p {
    margin: 0;
    font-size: var(--hub-text-body);
    color: var(--hub-text);
}

.beto-conflict-preview {
    margin-bottom: 16px;
}

.beto-conflict-preview:empty {
    display: none;
}

.beto-priority-note {
    margin-top: 0.25rem;
    color: var(--hub-text-muted);
    font-size: var(--hub-text-table);
    font-weight: var(--hub-weight-medium);
    line-height: var(--hub-leading-normal);
    max-width: 64ch;
}

/* --- Bulk / Batch Application Selectors --- */
.beto-modal-context-strategy {
    background: var(--hub-surface-hover);
    padding: 8px 12px;
    border-radius: var(--hub-radius);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-extralight);
    color: var(--hub-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.beto-modal-context-strategy span:first-child {
    color: var(--hub-text-muted);
}
.beto-modal-context-strategy span:last-child {
    font-weight: var(--hub-weight-semibold);
}

.beto-bulk-select-all-label {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    font-weight: var(--hub-weight-medium);
    font-size: var(--hub-text-body);
    margin-bottom: 8px;
}

.beto-bulk-select-all-label label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    cursor: pointer;
}

.beto-bulk-select-all-input {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin: 0;
    padding: 0;
    accent-color: var(--hub-primary);
}

.beto-bulk-select-all-input:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.beto-bulk-units-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--hub-border);
    padding: 12px;
    border-radius: var(--hub-radius);
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}

.beto-bulk-unit-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    cursor: pointer;
    font-size: var(--hub-text-body);
    line-height: 1.35;
    min-width: 0;
    width: 100%;
}

.beto-bulk-unit-option .beto-bulk-select-all-input {
    align-self: center;
}

.beto-bulk-units-empty {
    margin: 0;
    color: var(--hub-text-muted);
    font-size: var(--hub-text-body);
    line-height: var(--hub-leading-normal);
}

/* --- Modals for Batch Application --- */
.beto-strategy-apps-modal__body {
    min-height: 0;
    padding: var(--space-m);
    overflow: auto;
}

.beto-strategy-apps-modal__list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.beto-strategy-apps-modal__list .beto-strategy-app-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--hub-border);
}

.beto-strategy-apps-modal__list .beto-strategy-app-item:last-child {
    border-bottom: 0;
}

.beto-strategy-apps-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-xs);
    padding: var(--hub-modal-footer-padding);
    border-top: 1px solid var(--hub-border);
}

/* --- Sidebar: Painel de Regras Avançadas --- */
.beto-rule-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-s);
    margin-bottom: var(--space-s);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--hub-border);
}

.beto-rule-panel__head h3 {
    margin: 0;
    color: var(--hub-text);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-semibold);
}

/* --- Raio-X: Cards Competitivos (Estratégia) --- */
.beto-rx-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-s);
    margin-bottom: var(--space-s);
}

.beto-rx-card {
    padding: var(--space-s);
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    background: var(--hub-surface);
}

.beto-rx-card--a { border-left: 3px solid var(--hub-primary); }
.beto-rx-card--b { border-left: 3px solid var(--hub-info); }
.beto-rx-card--c { border-left: 3px solid var(--hub-success); }

/* --- Raio-X: Alerta Algorítmico --- */
.beto-alert-box {
    margin-top: var(--space-s);
    padding: 12px var(--space-s) !important;
    border: 1px solid rgba(193, 145, 56, 0.22) !important;
    border-radius: var(--hub-radius) !important;
    background: rgba(193, 145, 56, 0.05) !important;
    text-align: left !important;
}

.beto-alert-box strong {
    display: block !important;
    margin-bottom: 6px !important;
    color: var(--hub-warning) !important;
    font-size: var(--hub-text-table) !important;
    font-weight: var(--hub-weight-bold) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
}

.beto-alert-box span {
    color: var(--hub-text-muted) !important;
    font-size: var(--hub-text-label) !important;
    font-weight: var(--hub-weight-medium) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: var(--hub-leading-normal) !important;
}

/* --- Métrica: Variantes DRE e RX (Estratégia) --- */
.beto-metric-card--dre {
    grid-column: 1 / -1;
}

.beto-metric-card--rx {
    min-height: auto;
}

/* --- Demonstrativo financeiro compacto do simulador --- */
.beto-result-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.beto-result-list > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-s);
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid var(--hub-border);
}

.beto-result-list > div:last-child {
    border-bottom: 0;
}

.beto-result-list dt,
.beto-result-list dd {
    margin: 0;
}

.beto-result-list dt {
    color: var(--hub-text-muted);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-medium);
}

.beto-result-list dd {
    color: var(--hub-text);
    font-size: var(--hub-text-card-title);
    font-weight: var(--hub-weight-semibold);
    text-align: right;
    white-space: nowrap;
}

.beto-result-list .is-negative {
    color: var(--hub-text-muted);
}

.beto-result-list .is-total {
    padding-top: 12px;
}

.beto-result-list .is-total dt,
.beto-result-list .is-profit {
    color: var(--hub-primary-hover);
    font-weight: var(--hub-weight-bold);
}

/* --- Saved Strategies List Styles --- */
.beto-strategy-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: var(--space-xs);
}

.beto-strategy-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    background: rgba(255, 255, 255, 0.015);
    transition: background 0.18s ease, border-color 0.18s ease;
}

.beto-strategy-row:hover {
    background: rgba(255, 255, 255, 0.035);
    border-color: rgba(255, 255, 255, 0.08);
}

.beto-strategy-row.is-active {
    border-color: rgba(203, 123, 55, 0.42);
    background: rgba(203, 123, 55, 0.055);
}

.beto-strategy-row > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.beto-strategy-row strong {
    color: var(--hub-text);
    font-size: var(--hub-text-table);
    font-weight: var(--hub-weight-semibold);
}

.beto-strategy-row span {
    color: var(--hub-text-muted);
    font-size: var(--hub-text-label);
}

.beto-strategy-row .is-danger-profit {
    color: var(--hub-danger);
    font-weight: var(--hub-weight-medium);
}

.beto-strategy-row__actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.beto-strategy-row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
