/* ================================================================
   PURPOSE MODULE — Styles
   Modulo de Proposito — Estilos

   Namespace: .purpose-*
   Ownership: Este arquivo e o unico que define seletores .purpose-*
   Nao definir .btn-*, .modal-*, ou outros seletores fora do namespace.

   Camada 1: Micro-toast (feedback instantaneo)
   Camada 2: Statusbar widget (sessao)
   Camada 3: Home grid section (retorno)
   Camada 4: Modal (reflexao) — Phase 2
   ================================================================ */

/* ================================================================
   CAMADA 1 — MICRO-TOAST
   Toast contextual discreto para acoes EIS.
   Menor e mais efemero que o toast padrao.
   ================================================================ */

.purpose-micro-toast-container {
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 150;
    pointer-events: none;
    max-width: 360px;
}

.purpose-micro-toast {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    border-left: 3px solid #888;
    background: var(--surface-2, #1e1e2e);
    color: var(--text-1, #e0e0e0);
    font-size: 12px;
    font-family: var(--font-mono, 'Fira Code', monospace);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 300ms ease, transform 300ms ease;
    pointer-events: auto;
}

.purpose-micro-toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.purpose-micro-toast-fade {
    opacity: 0;
    transform: translateX(20px);
}

.purpose-micro-toast-arrow {
    font-size: 10px;
    line-height: 1;
    flex-shrink: 0;
}

.purpose-micro-toast-axis {
    font-weight: 600;
    white-space: nowrap;
}

.purpose-micro-toast-sep {
    color: var(--text-3, #666);
    flex-shrink: 0;
}

.purpose-micro-toast-msg {
    color: var(--text-2, #aaa);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================================================
   CAMADA 2 — STATUSBAR WIDGET
   Indicador EIS compacto no statusbar.
   ================================================================ */

.purpose-status-widget {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font-mono, 'Fira Code', monospace);
    border-radius: 3px;
    transition: background 200ms ease;
    white-space: nowrap;
    user-select: none;
}

.purpose-status-widget:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.08));
}

.purpose-status-score {
    font-weight: 600;
}

.purpose-status-delta {
    font-size: 10px;
    opacity: 0.8;
}

.purpose-status-breakdown {
    font-size: 10px;
    opacity: 0.75;
}

.purpose-status-delta-positive {
    color: #22c55e;
}

.purpose-status-delta-negative {
    color: #ef4444;
}

.purpose-status-delta-neutral {
    color: #888;
}

/* Pulse animation — dispara quando delta muda */
@keyframes purpose-pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.purpose-status-pulse {
    animation: purpose-pulse 400ms ease-in-out;
}

/* Cor por verdict */
.purpose-status-high {
    color: #22c55e;
}

.purpose-status-medium {
    color: #f59e0b;
}

.purpose-status-low {
    color: #ef4444;
}

/* ================================================================
   CAMADA 3 — HOME GRID PURPOSE SECTION
   Secao de impacto no home grid.
   ================================================================ */

.purpose-home-section {
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--surface-2, #1e1e2e);
    border: 1px solid var(--border-1, #333);
    margin-bottom: 12px;
}

.purpose-home-meta {
    font-size: 11px;
    opacity: 0.78;
    margin-bottom: 6px;
}

.purpose-home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.purpose-home-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1, #e0e0e0);
}

.purpose-home-details-link {
    font-size: 11px;
    color: var(--accent-1, #4a9eff);
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
}

.purpose-home-details-link:hover {
    text-decoration: underline;
}

.purpose-home-score-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.purpose-home-score {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono, 'Fira Code', monospace);
}

.purpose-home-delta {
    font-size: 13px;
    font-family: var(--font-mono, 'Fira Code', monospace);
}

.purpose-home-narrative {
    font-size: 12px;
    color: var(--text-2, #aaa);
    margin-bottom: 8px;
}

/* Sparkline canvas */
.purpose-home-sparkline {
    display: block;
    height: 24px;
    max-width: 120px;
    margin-bottom: 6px;
}

/* Axis breakdown inline */
.purpose-home-breakdown {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-2, #aaa);
}

.purpose-home-axis-delta {
    white-space: nowrap;
}

/* Empty state */
.purpose-home-empty {
    font-size: 12px;
    color: var(--text-3, #666);
    text-align: center;
    padding: 8px 0;
}

/* ================================================================
   CAMADA 4 — REFLECTION MODAL
   Modal de reflexao com grafico, tabs e breakdown por eixo.
   ================================================================ */

.purpose-modal-box {
    width: min(560px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
}

.purpose-modal-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px 8px;
    border-bottom: 1px solid var(--border-1, #333);
}

.purpose-modal-tab {
    padding: 4px 12px;
    border: 1px solid var(--border-1, #444);
    border-radius: 4px;
    background: transparent;
    color: var(--text-2, #aaa);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms, color 150ms;
}

.purpose-modal-tab:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.08));
}

.purpose-modal-tab.active {
    background: var(--accent-1, #4a9eff);
    color: #fff;
    border-color: var(--accent-1, #4a9eff);
}

.purpose-modal-body {
    padding: 12px 16px 16px;
}

/* --- Summary --- */

.purpose-modal-score-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.purpose-modal-score {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono, 'Fira Code', monospace);
}

.purpose-modal-scale {
    font-size: 14px;
    color: var(--text-3, #666);
}

.purpose-modal-verdict {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}

.purpose-modal-deltas {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.purpose-modal-delta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.purpose-modal-delta-label {
    font-size: 10px;
    color: var(--text-3, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.purpose-modal-delta-value {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-mono, 'Fira Code', monospace);
}

/* --- Chart --- */

.purpose-modal-chart-wrapper {
    position: relative;
    height: 160px;
    margin-bottom: 16px;
}

.purpose-modal-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- Axes Breakdown --- */

.purpose-modal-axes-title,
.purpose-modal-priorities-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.purpose-modal-axes-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.purpose-modal-axis-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.purpose-modal-axis-label {
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-mono, 'Fira Code', monospace);
    width: 24px;
    flex-shrink: 0;
}

.purpose-modal-axis-name {
    font-size: 11px;
    color: var(--text-2, #aaa);
    width: 100px;
    flex-shrink: 0;
}

.purpose-modal-axis-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.purpose-modal-axis-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 300ms ease;
}

.purpose-modal-axis-score {
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono, 'Fira Code', monospace);
    width: 28px;
    text-align: right;
    flex-shrink: 0;
}

.purpose-modal-axis-delta {
    font-size: 11px;
    font-family: var(--font-mono, 'Fira Code', monospace);
    width: 32px;
    text-align: right;
    flex-shrink: 0;
}

/* --- Priorities --- */

.purpose-modal-priority-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    margin-bottom: 4px;
}

.purpose-modal-priority-axis {
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-mono, 'Fira Code', monospace);
    width: 24px;
    flex-shrink: 0;
}

.purpose-modal-priority-hint {
    flex: 1;
    font-size: 12px;
    color: var(--text-2, #aaa);
}

.purpose-modal-priority-score {
    font-size: 11px;
    font-family: var(--font-mono, 'Fira Code', monospace);
    color: var(--text-3, #666);
    flex-shrink: 0;
}

.purpose-modal-priority-ok {
    font-size: 12px;
    color: #22c55e;
    padding: 6px 0;
}

/* ================================================================
   CAMADA 5 — EIS SCOPE SELECTOR
   Seletor de escopo no dashboard EIS: Modelo / Por CNPJ / Por Area
   ================================================================ */

.purpose-scope-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 12px;
    background: var(--surface-2, #1e1e2e);
    border-bottom: 1px solid var(--border-1, #333);
    flex-shrink: 0;
}

.purpose-scope-tab {
    padding: 5px 12px;
    border: 1px solid var(--border-1, #444);
    border-radius: 4px;
    background: transparent;
    color: var(--text-2, #aaa);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms, color 150ms;
    white-space: nowrap;
}

.purpose-scope-tab:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.08));
}

.purpose-scope-tab.active {
    background: var(--accent-1, #4a9eff);
    color: #fff;
    border-color: var(--accent-1, #4a9eff);
}

.purpose-model-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 10px;
    font-family: var(--font-mono, 'Fira Code', monospace);
    color: var(--text-3, #666);
    margin-left: 4px;
    vertical-align: middle;
}

/* Scope list (CNPJ / area items) */
.purpose-scope-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    max-height: 200px;
    overflow-y: auto;
}

.purpose-scope-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 150ms, border-color 150ms;
}

.purpose-scope-item:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.08));
    border-color: var(--border-1, #444);
}

.purpose-scope-item.active {
    border-color: var(--accent-1, #4a9eff);
    background: rgba(74, 158, 255, 0.08);
}

.purpose-scope-item-info {
    flex: 1;
    min-width: 0;
}

.purpose-scope-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-1, #e0e0e0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.purpose-scope-item-detail {
    font-size: 10px;
    color: var(--text-3, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* EIS badge (circle + score) */
.purpose-eis-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono, 'Fira Code', monospace);
    flex-shrink: 0;
}

.purpose-eis-badge--high {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.purpose-eis-badge--medium {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.purpose-eis-badge--low {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.purpose-eis-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Spatial indicators panel */
.purpose-spatial-panel {
    padding: 8px 12px;
    border-top: 1px solid var(--border-1, #333);
}

.purpose-spatial-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.purpose-spatial-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.purpose-spatial-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.purpose-spatial-label {
    font-size: 11px;
    color: var(--text-2, #aaa);
    width: 140px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.purpose-spatial-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.purpose-spatial-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 300ms ease;
}

.purpose-spatial-score {
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono, 'Fira Code', monospace);
    width: 20px;
    text-align: right;
    flex-shrink: 0;
}

.purpose-spatial-critical {
    color: #ef4444;
}

/* Responsibles header */
.purpose-responsibles {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-2, #aaa);
    border-bottom: 1px solid var(--border-1, #333);
}

.purpose-responsible-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.purpose-responsible-role {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3, #666);
}

.purpose-responsible-name {
    font-size: 11px;
    color: var(--text-1, #e0e0e0);
    font-weight: 500;
}

.purpose-responsible-inherited {
    font-style: italic;
    opacity: 0.6;
}

/* Scope empty state */
.purpose-scope-empty {
    font-size: 12px;
    color: var(--text-3, #666);
    text-align: center;
    padding: 16px 0;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
    .purpose-micro-toast-container {
        right: 8px;
        bottom: 60px;
        max-width: 280px;
    }

    .purpose-status-widget {
        display: none;
    }

    .purpose-home-score {
        font-size: 20px;
    }
}
