/* ==========================================================================
   GLS Equity V4 - Stock Profile Module
   Module Specific Layouts (Depends on style.css for Core UI)
   ========================================================================== */

/* ==========================================
   1. PROFILE HEADER
   ========================================== */
.profile-sticky-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 74px; 
    z-index: 90;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.profile-header-inner { max-width: 1600px; margin: 0 auto; padding: 16px 20px 0 20px; }
.profile-title-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; }
.profile-title-flex { display: flex; align-items: baseline; gap: 12px; }

.company-main-title { margin: 0; font-size: 1.5rem; font-weight: 800; color: #0f172a; line-height: 1; }
.ticker-sub { font-size: 0.85rem; color: #64748b; font-weight: 600; }
.profile-title-group { min-width: 0; flex: 1; }
.cat-badge-pill { display: inline-block; white-space: nowrap; margin-left: 8px; padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.cat-growth { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.cat-deep-value, .cat-value { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.cat-high-yield { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.cat-quality { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.cat-defensive { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.cat-speculative { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.loading-desc { margin: 6px 0 0; color: #64748b; font-size: 0.9rem; }
.profile-desc { color: #475569; line-height: 1.6; font-size: 0.95rem; }
.current-price-display { font-size: 1.8rem; font-weight: 800; color: #0f172a; line-height: 1; text-align: right; }

.subnav-wrapper { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }
.subnav-wrapper::-webkit-scrollbar { display: none; }

.conviction-badges-container { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.conviction-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.conviction-badge:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

.conviction-high { color: #059669; background: #d1fae5; border: 1px solid currentColor; }
.conviction-med { color: #d97706; background: #fef3c7; border: 1px solid currentColor; }
.conviction-low { color: #dc2626; background: #fee2e2; border: 1px solid currentColor; }
.conviction-moat { color: #0284c7; background: #e0f2fe; border: 1px solid currentColor; }
.conviction-wheel { border: 1px solid currentColor; cursor: pointer; }
.conviction-wheel .ws-band { font-weight: 600; opacity: 0.85; margin-left: 2px; }

.next-earnings-label { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; margin-top: 6px; letter-spacing: 0.05em; }

/* Header buttons under the price (desktop): .wl-quick* is the shared watchlist menu in styles.css */
.wl-quick { margin-top: 8px; }
.cmp-quick { margin-top: 8px; margin-left: 6px; vertical-align: top; }
.cmp-quick.is-in { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }

/* ==========================================
   2. WORKSPACE & CHARTS
   ========================================== */
.workspace-grid { display: grid; grid-template-columns: 1fr; gap: 16px; width: 100%; }
@media (min-width: 992px) { .workspace-grid { grid-template-columns: 2fr 1fr; } }

.chart-workspace { position: relative; padding: 20px; min-height: 520px; display: flex; flex-direction: column; }
.chart-toolbar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.chart-canvas-container { flex: 1; min-height: 0; }
.chart-canvas-lg { min-height: 450px; }
.chart-canvas-md { min-height: 400px; }

/* ==========================================
   3. OVERVIEW & FUNDAMENTALS
   ========================================== */
.profile-details-grid { display: grid; grid-template-columns: 1fr; gap: 10px; font-size: 0.85rem; border-top: 1px solid #f1f5f9; padding-top: 16px; }
.profile-details-row { display: flex; justify-content: space-between; }
.profile-details-label { color: #64748b; }
.profile-details-val { font-weight: 600; color: #0f172a; }
.profile-web-link { font-weight: 600; color: #0284c7; text-decoration: none; }

.fundamentals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.fund-item { display: flex; flex-direction: column; }
.fund-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; margin-bottom: 2px; }
.fund-value { font-size: 0.85rem; font-weight: 700; color: #0f172a; }

/* ==========================================
   4. GROWTH RATES
   ========================================== */
.growth-summary-container { display: flex; flex-direction: column; gap: 12px; }
.growth-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.growth-label { color: #475569; }
.growth-val { font-weight: 700; }
.growth-val-null { font-weight: 700; color: #94a3b8; }
.growth-row.disabled .growth-label { color: #94a3b8; text-decoration: line-through; }

.growth-header-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding-top: 12px; border-top: 1px solid #e2e8f0; font-size: 0.9rem; }
.growth-header-label { font-weight: 700; color: #0f172a; }
.growth-header-val { font-weight: 800; color: #0f172a; }

.growth-highlight-box { display: flex; justify-content: space-between; align-items: center; background: #d1fae5; padding: 12px 16px; border-radius: 8px; margin-top: 12px; border: 1px solid #10b981; }
.growth-highlight-label { font-weight: 700; color: #059669; }
.growth-highlight-val { font-weight: 800; color: #059669; font-size: 1.1rem; }

.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.flex-align-center { display: flex; align-items: center; gap: 8px; }
.td-semi-dark { font-weight: 700; color: #0f172a; }
.td-muted { color: #64748b; }

/* ==========================================
   5. VALUATIONS
   ========================================== */
.master-avg-card { background: #cbd5e1; color: white; text-align: center; transition: background 0.3s ease; display: flex; flex-direction: column; align-items: center; }
.master-card-inactive { background: #cbd5e1; }
.master-card-active { background-color: #10b981 !important; }
.master-avg-note { margin-top: 10px; font-size: 0.75rem; font-weight: 600; color: rgba(255,255,255,0.92); line-height: 1.4; }
.master-avg-note:empty { display: none; }
.val-toggle-help { margin: 12px 0 0; font-size: 0.78rem; color: #64748b; line-height: 1.5; }
.val-toggle-help .link-btn { font-size: inherit; }
.master-avg-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.master-avg-val { font-size: 2.5rem; font-weight: 800; margin: 8px 0; line-height: 1; }
.mos-readout { font-size: 0.8rem; font-weight: bold; color: #64748b; background: white; padding: 6px 12px; border-radius: 4px; }

.val-toggle-grid { display: flex; flex-direction: column; gap: 8px; }
.val-toggle { background: #f1f5f9; border: 1px solid #e2e8f0; padding: 8px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; color: #64748b; cursor: pointer; user-select: none; transition: all 0.2s ease; }
.val-toggle:hover { background: #e2e8f0; }
.val-toggle.active-model { background: #64748b; color: white; border-color: #64748b; }

.target-row { font-size: 0.85rem; }
.target-label { color: #64748b; font-weight: 600; }
.target-breakdown-title { margin: 0; font-size: 0.85rem; color: #64748b; text-transform: uppercase; font-weight: 800; }

/* ==========================================
   6. FINANCIALS, PEERS & NEWS
   ========================================== */
.efficiency-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.efficiency-card { border: 1px solid #e2e8f0; padding: 20px; border-radius: 8px; background-color: #f8fafc; }
.efficiency-label { font-size: 0.7rem; font-weight: 700; color: #64748b; margin-bottom: 8px; }
.efficiency-val { font-size: 1.5rem; font-weight: 800; color: #0f172a; }

.score-col { background: #f1f5f9; border-left: 1px solid #cbd5e1; }
.scorecard-val-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scorecard-val-bold { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 800; color: #0f172a; background: #f8fafc; }
.table-empty-state { text-align: center; padding: 30px; color: #64748b; font-style: italic; }
.peer-link { color: #2563eb; font-weight: 700; text-decoration: none; }
.peer-link:hover { text-decoration: underline; }
.direct-links-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.direct-links-container { display: flex; flex-wrap: wrap; gap: 6px; }
.peer-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-size: 0.8rem; font-weight: 700; text-decoration: none; border: 1px solid #bfdbfe; }
.peer-tag:hover { background: #dbeafe; }
.inst-td-main { white-space: nowrap; }
.chart-no-data { display: flex; align-items: center; justify-content: center; min-height: 240px; padding: 30px; color: #64748b; font-style: italic; text-align: center; }
.drawer-close-btn { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: #64748b; padding: 4px 6px; border-radius: 6px; }
.drawer-close-btn:hover { background: #e2e8f0; color: #0f172a; }
.peer-median-row td { background: #f8fafc; border-top: 2px solid #e2e8f0; font-weight: 800;}

.benchmark-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.benchmark-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; display: flex; flex-direction: column; }
.benchmark-label { font-size: 0.7rem; font-weight: 700; color: #64748b; text-transform: uppercase; }
.benchmark-val { font-size: 1.5rem; font-weight: 800; margin: 8px 0; }
.benchmark-desc { font-size: 0.8rem; color: #475569; }

.news-feed-container { max-height: 600px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.news-item { display: flex; gap: 16px; text-decoration: none; padding: 16px; border: 1px solid #f1f5f9; border-radius: 8px; transition: background 0.2s; }
.news-item:hover { background: #f8fafc; }
.news-img { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: #e2e8f0; }
.news-meta { font-size: 0.7rem; color: #64748b; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.news-title { font-size: 0.9rem; font-weight: 700; color: #0f172a; line-height: 1.4; margin-bottom: 6px; }
.news-excerpt { font-size: 0.8rem; color: #475569; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Moat Scorecard Colors & Explainer */
.badge-recent-good, .text-score-high { color: #10b981; font-weight: 800; }
.badge-recent-bad, .text-score-low   { color: #ef4444; font-weight: 800; }
.text-score-med                      { color: #f59e0b; font-weight: 800; }

.moat-explainer-container { padding-top: 30px; border-top: 1px solid #e2e8f0; margin-top: 40px; }
.moat-explainer-title { font-size: 1.1rem; font-weight: 800; color: #0f172a; margin-bottom: 15px; }
.moat-explainer-text { margin-bottom: 12px; color: #475569; font-size: 0.95rem; line-height: 1.6; }
.moat-explainer-text strong { color: #334155; }

.moat-guide-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; margin-top: 25px; }
.moat-guide-title { font-size: 1rem; font-weight: 700; color: #0f172a; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.moat-guide-note { margin-bottom: 20px; color: #64748b; font-size: 0.85rem; font-style: italic; }

.moat-cards-wrapper { display: flex; gap: 20px; flex-wrap: wrap; }
.moat-guide-card { flex: 1; min-width: 250px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; }
.moat-card-title { font-weight: 700; color: #0f172a; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.moat-card-sub { color: #64748b; font-size: 0.85rem; font-style: italic; margin-bottom: 12px; }
.moat-card-desc { color: #475569; font-size: 0.9rem; line-height: 1.5; margin: 0; }

/* ==========================================
   7. HOLDERS FLOW SUMMARY
   ========================================== */
#inst-flow-summary, #insider-flow-summary, #congress-flow-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.flow-card { padding: 16px 20px; border-radius: 8px; display: flex; flex-direction: column; justify-content: center; border: 1px solid transparent; }
.flow-label { font-size: 0.75rem; font-weight: 800; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.flow-val { font-size: 1.6rem; font-weight: 800; line-height: 1; }

.flow-card-green { background-color: #f0fdf4; border-color: #bbf7d0; }
.text-green-light { color: #059669; } 
.text-green-dark { color: #064e3b; }  

.flow-card-red { background-color: #fef2f2; border-color: #fecaca; }
.text-red-light { color: #dc2626; } 
.text-red-dark { color: #7f1d1d; }

/* ==========================================
   8. NEWS & EVENTS
   ========================================== */
.event-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 500px;
    padding: 12px 10px; /* Added horizontal padding so the hover background frames the text */
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.2s ease;
}

/* Replicates the standard table row hover effect */
.event-row:hover {
    background-color: #f8fafc;
    border-radius: 6px; 
}

.event-row:last-child { border-bottom: none; }

.events-header {
    font-size: 1.1rem;
    color: #0f172a;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
    margin-bottom: 8px;
    max-width: 500px;
}

.event-date { font-weight: 700; color: #0f172a; font-size: 0.95rem; }
.event-sub { color: #64748b; font-size: 0.8rem; margin-top: 2px; }
.event-status { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; margin-bottom: 2px; }
.event-val { font-weight: 600; color: #475569; font-size: 0.9rem; }
.event-val-highlight { font-weight: 800; font-size: 1.2rem; color: #10b981; }

/* ==========================================
   9. STOCK MOBILE OVERRIDES (< 768px)
   ========================================== */
@media (max-width: 768px) {
    /* --- Workspace Compressions --- */
    .chart-workspace { min-height: 400px; padding-bottom: 0; }
    .chart-toolbar { gap: 4px; justify-content: center; }
    .val-header-row .flex-row { flex-wrap: wrap; }
    .mos-input-container { border-left: none; padding-left: 0; }
    .target-breakdown-box .flex-between { flex-direction: column; align-items: flex-start; gap: 12px; }
    #toggle-analyst-targets { width: 100%; text-align: center; }
    .val-toggle { flex-wrap: wrap; }
    .val-toggle span { white-space: normal; flex: 1; }

    /* --- Holders Flow Cards Mobile Stacking --- */
    #inst-flow-summary, #insider-flow-summary, #congress-flow-summary { grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
    .flow-card { padding: 12px 16px; }
    .flow-val { font-size: 1.35rem; }

    /* --- Profile Header Flex Fixes --- */
    .profile-title-row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0px; }
    .profile-title-flex { width: 100%; gap: 0px; }
    .profile-title-group { width: 100%; flex: none; }
    .cat-badge-pill { margin-left: 6px; }
    
    div:has(> #companyTitle) {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        width: 100%;
        min-width: 0;
    }

    #companyTitle { width: 100%; font-size: 1.6rem; line-height: 1.15; margin-bottom: 4px; }
    #tickerSubtitle { width: 100%; font-size: 0.8rem; margin-bottom: 12px; text-align: left; }

    /* --- Bulletproof Badge Wrapping --- */
    body #convictionBadges { display: flex; flex-wrap: wrap; width: 100%; min-width: 0; box-sizing: border-box; gap: 6px; margin-bottom: 10px; }
    .conviction-badges-container { margin-top: 0px; }
    body #convictionBadges .conviction-badge { font-size: 0.75rem; padding: 4px 8px; white-space: nowrap; margin: 0; }
    body #convictionBadges .conviction-badge .badge-icon { display: none; }

    /* --- Price & Earnings Inline Formatting --- */
    div:has(> #displayCurrentPrice) { display: flex; flex-direction: row; flex-wrap: wrap; align-items: baseline; width: 100%; }
    .current-price-display { text-align: left; }
    #displayCurrentPrice { width: auto; font-size: 1.6rem; margin-top: 0px; margin-bottom: 0px; margin-right: 12px; }
    #header-next-earnings { width: auto; font-size: 0.75rem; margin-bottom: 0px; margin-top: 0px; }
    .wl-quick { width: auto; display: inline-block; margin-top: 8px; }

    /* --- Moat Scorecard Mobile Header Stacking --- */
    #fin-panel-scorecard .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    #moat-overall-badge {
        width: 100%;
        text-align: center;
        padding: 10px; /* Adds a bit more vertical breathing room for the full-width badge */
    }
}