/**
 * Header Component Styles
 * Unified CSS for Row 1 (page-header) + Row 2 (SGE panel)
 *
 * NAMESPACE: All rules start with #app-header
 * NO !important - proper cascade with currentColor for icons
 */

/* ==================== ANIMATIONS ==================== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================== CONTAINER ==================== */
#app-header {
    background: rgb(18, 18, 28);
    position: relative;
    z-index: 100;
}

/* ==================== ROW 1: Page Header ==================== */
#app-header .header-row1 {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 16px;
    padding: 0px 24px;
    height: 44px;
    border-bottom: 1px solid var(--border-subtle);
}

#app-header .screen-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

#app-header .header-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    flex-shrink: 0;
}

/*
 * METRICS — CANONICAL SIZES (same for ALL screens)
 * Designed for 5-7 metrics with identical look.
 * 8 metrics: flex-shrink compresses gaps, fonts stay constant.
 */
#app-header .header-metrics {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;           /* Sweet spot: 5-7 identical, 8 compresses naturally */
    flex: 1 1 0%;
    min-width: 0;        /* Allows flex to shrink within header-row1 */
}

#app-header .metric-item {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 5px;            /* Label ↔ Value spacing */
    min-width: 0;        /* Allows shrinking for 8+ metrics */
    flex-shrink: 1;
    white-space: nowrap;
}

#app-header .metric-label {
    font-size: 11px;     /* CANONICAL — never change per screen */
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    font-weight: 400;
}

#app-header .metric-value {
    font-size: 15px;     /* CANONICAL — never change per screen */
    font-weight: 600;
    color: var(--text-primary);
    line-height: normal;
}

#app-header .metric-value.positive { color: var(--accent-green) !important; }
#app-header .metric-value.positive-light { color: #86EFAC !important; }
#app-header .metric-value.negative { color: var(--accent-red) !important; }
#app-header .metric-value.warning { color: var(--accent-yellow) !important; }
#app-header .metric-value.warning-light { color: #F97316 !important; }
#app-header .metric-value.neutral { color: var(--accent-blue) !important; }

#app-header .metric-sub {
    font-size: 10px;
    color: var(--text-secondary);
    line-height: normal;
}

#app-header .metric-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    flex-shrink: 0;
}

/* Metric Tooltips */
#app-header .header-metric-with-tooltip:hover .header-metric-tooltip {
    opacity: 1;
    visibility: visible;
}

#app-header .header-metric-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: normal;      /* Override nowrap inherited from .metric-item */
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 9999 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    pointer-events: none;
}

#app-header .header-metric-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
}

#app-header .tooltip-standard { width: 310px; }
#app-header .tooltip-medium { width: 280px; }
#app-header .tooltip-wide { width: 340px; }  /* CORRECTO: Dashboard usa 340px, NO 380px */
#app-header .tooltip-large { width: 320px; }

/* Icon Buttons - NO !important, use currentColor */
#app-header .header-icons {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

#app-header .icon-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: var(--text-secondary); /* Base color */
}

#app-header .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary); /* Hover color */
    transform: translateY(-1px);
}

#app-header .icon-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    stroke: currentColor; /* Icon inherits button text color */
    fill: none;
}

#app-header .icon-btn.hidden {
    display: none;
}

/* Portfolio/Account selector button - hidden by default, shown by JS if multiple accounts */
#app-header #btn-portfolio {
    display: none;
}

/* Connection Button Dots */
#app-header .connection-dots {
    display: flex;
    gap: 3px;
}

#app-header .dot-small {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-yellow);
}

#app-header .dot-small.connected { background: var(--accent-green); }
#app-header .dot-small.error { background: var(--accent-red); }
#app-header .dot-small.closed { background: var(--accent-red); }

/* Button Tooltips */
#app-header .refresh-tooltip,
#app-header .connection-tooltip,
#app-header .user-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 180px;
    width: max-content;
    max-width: 260px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 9999;
    pointer-events: none;
    font-size: 12px;
    line-height: 1.5;
}

#app-header .refresh-tooltip::before,
#app-header .connection-tooltip::before,
#app-header .user-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 12px;
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
}

#app-header #btn-refresh:hover .refresh-tooltip,
#app-header .connection-btn:hover .connection-tooltip,
#app-header #btn-user:hover .user-tooltip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#app-header .refresh-tooltip .tooltip-row,
#app-header .connection-tooltip .tooltip-row,
#app-header .user-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}

#app-header .refresh-tooltip .tooltip-label,
#app-header .connection-tooltip .tooltip-label,
#app-header .user-tooltip .tooltip-label {
    color: var(--text-muted);
}

#app-header .refresh-tooltip .tooltip-value,
#app-header .connection-tooltip .tooltip-value,
#app-header .user-tooltip .tooltip-value {
    font-weight: 600;
    color: var(--text-primary);
}

#app-header .connection-tooltip .tooltip-value.positive { color: var(--accent-green); }
#app-header .connection-tooltip .tooltip-value.negative { color: var(--accent-red); }

#app-header .user-tooltip .tooltip-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

#app-header .user-tooltip .tooltip-action {
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

#app-header .user-tooltip .tooltip-action:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* AI Tooltip */
#app-header .shield-ai-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 300px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 9999;
    pointer-events: none;
}

#app-header .shield-ai-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 12px;
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
}

#app-header #btn-ai:hover .shield-ai-tooltip {
    opacity: 1;
    visibility: visible;
}

#app-header .shield-ai-tooltip .tooltip-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

#app-header .shield-ai-tooltip .tooltip-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

#app-header .shield-ai-tooltip .capability-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

#app-header .shield-ai-tooltip .capability-item {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--text-secondary);
}

#app-header .shield-ai-tooltip .capability-icon {
    flex-shrink: 0;
}

#app-header .shield-ai-tooltip .tooltip-shortcut {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

#app-header .shield-ai-tooltip .shortcut-key {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

/* ==================== ROW 2: SGE Banner ==================== */
/* SGE Banner styles are in 3-components.css - DO NOT duplicate here */

/* ==================== AI PANEL MESSAGES (from panels.js) ==================== */

.ai-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.4;
}

.ai-message-user {
    margin-left: auto;
    background: var(--accent-blue);
    color: white;
    text-align: right;
}

.ai-message-ai {
    margin-right: auto;
    background: var(--bg-card);
    color: var(--text-primary);
}

.typing-indicator {
    padding: 10px 14px;
    margin-bottom: 12px;
    max-width: 85%;
    background: var(--bg-card);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 13px;
}
