/* 01_base.css — Typography, buttons, links, nav, and Dash component theming.
   Ported from styles.py inject_base_styles(); Streamlit/BaseWeb selectors
   were discarded and replaced with rules for real Dash components. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Typography hierarchy */
h1 { font-weight: var(--fw-semibold); letter-spacing: -0.8px; color: var(--text-primary); }
h2, h3 { font-weight: var(--fw-semibold); letter-spacing: -0.24px; color: var(--text-primary); }
p { color: var(--text-secondary); }

a { color: var(--brand-green-text); }

/* Raw-HTML embeds (dcc.Markdown wrapper) should not add paragraph margins */
.raw-html p { margin: 0; }

/* ------------------------------------------------------------------ */
/* Buttons — one shared mechanics system; variants keep visual deltas  */
/* ------------------------------------------------------------------ */
.btn-primary, .btn-secondary, .btn-form-submit, .btn-danger,
.nav-cta, .public-nav-cta, .public-btn, .report-add-btn, .benchmark-cta,
.sidebar-logout-btn {
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: transform var(--dur-base) var(--ease-standard),
                box-shadow var(--dur-base) var(--ease-standard),
                background-color var(--dur-base) var(--ease-standard),
                border-color var(--dur-base) var(--ease-standard),
                color var(--dur-base) var(--ease-standard),
                opacity var(--dur-base) var(--ease-standard);
}
.btn-primary:hover, .btn-secondary:hover, .btn-form-submit:hover,
.btn-danger:hover, .nav-cta:hover, .public-nav-cta:hover,
.public-btn:hover, .report-add-btn:hover, .benchmark-cta:hover,
.sidebar-logout-btn:hover {
    transform: translateY(-1px);
}
.btn-primary:focus-visible, .btn-secondary:focus-visible,
.btn-form-submit:focus-visible, .btn-danger:focus-visible,
.nav-cta:focus-visible, .public-nav-cta:focus-visible,
.public-btn:focus-visible, .report-add-btn:focus-visible,
.benchmark-cta:focus-visible, .sidebar-logout-btn:focus-visible,
.preview-card-link:focus-visible, .article-preview-cta:focus-visible,
.feature-card-link:focus-visible, .hero-secondary-link:focus-visible,
.trust-chip-link:focus-visible {
    outline: 2px solid var(--brand-green);
    outline-offset: 2px;
}
.btn-primary:disabled, .btn-secondary:disabled,
.btn-form-submit:disabled, .btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background-color: var(--text-primary);
    color: var(--bg-page);
    border: none;
    border-radius: var(--radius-pill);
    padding: 8px 24px;
    font-weight: var(--fw-medium);
    font-size: var(--fs-md);
    box-shadow: var(--shadow-1);
}
.btn-primary:hover { box-shadow: var(--shadow-2); }

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    padding: 8px 24px;
    font-weight: var(--fw-medium);
    font-size: var(--fs-md);
}
.btn-secondary:hover { border-color: var(--border-opaque); box-shadow: var(--shadow-2); }

/* Green form-submit button (auth forms only, per DESIGN.md) */
.btn-form-submit {
    background: var(--brand-green-fill);
    color: var(--on-fill);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-lg);
    padding: 10px 24px;
    width: 100%;
}
.btn-form-submit:hover { background: var(--brand-green-fill-hover); }

button:focus-visible {
    outline: 2px solid var(--brand-green);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Empty state (generic card for lists/sections with no content)        */
/* ------------------------------------------------------------------ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 1px dashed var(--border-medium);
    border-radius: var(--radius-md);
}
.empty-state-text {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    line-height: var(--lh-normal);
}
.empty-state-cta {
    color: var(--brand-green-text);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    text-decoration: none;
    border-radius: var(--radius-sm);
}
.empty-state-cta:hover { text-decoration: underline; }
.empty-state-cta:focus-visible {
    outline: 2px solid var(--brand-green);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Public nav bar                                                       */
/* ------------------------------------------------------------------ */
.public-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    padding: 10px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand { text-decoration: none; display: flex; align-items: center; }
.nav-links { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-link-muted {
    color: var(--text-muted); text-decoration: none;
    font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
    transition: color var(--dur-fast) var(--ease-standard);
}
.nav-link-muted:hover { color: var(--brand-green-text); }
.nav-link-plain {
    color: var(--text-primary); text-decoration: none;
    font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
    transition: color var(--dur-fast) var(--ease-standard);
}
.nav-link-plain:hover { color: var(--brand-green-text); }
.nav-cta {
    background-color: var(--text-primary);
    color: var(--bg-page);
    font-weight: var(--fw-semibold);
    padding: 7px 16px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-size: var(--fs-sm);
    box-shadow: var(--shadow-2);
    white-space: nowrap;
}
.nav-spacer { height: 64px; }

/* Icon-only toggle (conversion declutter): tight pill around the SVG. */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    padding: 7px 10px;
    line-height: 0;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}
.theme-toggle-btn:hover { background: var(--bg-hover); }

/* ------------------------------------------------------------------ */
/* dcc.Dropdown (react-select) theming                                  */
/* ------------------------------------------------------------------ */
.locale-select { width: 76px; font-size: var(--fs-xs); }

.dash-dropdown .Select-control {
    background-color: var(--bg-card);
    border: var(--field-border);
    border-radius: var(--field-radius);
    color: var(--text-primary);
    transition: var(--field-transition);
}
.dash-dropdown .Select-control:hover { border-color: var(--field-hover-border); }
.dash-dropdown .is-focused:not(.is-open) > .Select-control {
    border-color: var(--field-focus-border);
    box-shadow: var(--focus-ring);
}
.dash-dropdown .Select-value-label,
.dash-dropdown .Select-placeholder,
.dash-dropdown .Select-input > input {
    color: var(--text-primary) !important;
}
/* Dash's opacity-0 a11y focus helper has a fixed 185px width; inside a
   150px dropdown it pokes past the viewport edge (scrollWidth 1443 on
   /FPV). Cap it to the wrapper — invisible either way, focus() intact. */
.dash-dropdown-focus-target {
    max-width: 100%;
}
.dash-dropdown .Select-menu-outer {
    background-color: var(--bg-card);
    border: 1px solid var(--border-opaque);
    color: var(--text-primary);
    z-index: 10001;
}
.dash-dropdown .VirtualizedSelectOption { color: var(--text-primary); }
.dash-dropdown .VirtualizedSelectFocusedOption,
.dash-dropdown .VirtualizedSelectSelectedOption {
    background-color: var(--bg-green-light);
}
.dash-dropdown .Select-arrow { border-color: var(--text-muted) transparent transparent; }
.dash-dropdown .Select--multi .Select-value {
    background-color: var(--bg-green-light);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    font-weight: var(--fw-medium);
}
.dash-dropdown .Select--multi .Select-value-icon {
    border-right: 1px solid var(--border-medium);
}
.dash-dropdown .Select--multi .Select-value-icon:hover {
    background-color: var(--bg-hover);
    color: var(--error-text);
}

/* ------------------------------------------------------------------ */
/* dcc.Input / text inputs                                              */
/* ------------------------------------------------------------------ */
.text-input, input.text-input {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: var(--field-border);
    border-radius: var(--field-radius);
    padding: 10px 14px;
    /* 0.9rem + explicit line-height so typed text is fully visible (not clipped) */
    font-size: var(--fs-sm);
    line-height: var(--lh-ui);
    font-family: 'Inter', sans-serif;
    width: 100%;
    transition: var(--field-transition);
}
.text-input:hover { border-color: var(--field-hover-border); }
.text-input:focus {
    border-color: var(--field-focus-border);
    box-shadow: var(--focus-ring);
    outline: none;
}
/* Dash 4 puts dcc.Input className on the wrapper DIV, so :focus never
   matches it — the real input inside must drive the ring. */
.text-input:focus-within {
    border-color: var(--field-focus-border);
    box-shadow: var(--focus-ring);
}
.input-label {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    display: block;
    margin-bottom: 4px;
}

/* ------------------------------------------------------------------ */
/* dcc.DatePickerSingle (react-dates) theming                           */
/* ------------------------------------------------------------------ */
.DateInput { background: transparent; width: 130px; }
.DateInput_input {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: var(--field-border);
    border-radius: var(--field-radius);
    font-size: var(--fs-md);
    font-family: 'Inter', sans-serif;
    padding: 8px 12px;
    font-weight: var(--fw-regular);
    transition: var(--field-transition);
}
.DateInput_input__focused {
    border-color: var(--field-focus-border);
    box-shadow: var(--focus-ring);
}
.SingleDatePickerInput {
    background-color: transparent;
    border: none;
}
.SingleDatePicker_picker,
.DayPicker,
.CalendarMonth,
.CalendarMonthGrid {
    background-color: var(--bg-card);
    color: var(--text-primary);
}
.CalendarMonth_caption { color: var(--text-primary); }
.DayPicker_weekHeader { color: var(--text-muted); }
.CalendarDay__default {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-secondary);
}
.CalendarDay__default:hover { background: var(--bg-green-light); }
.CalendarDay__selected,
.CalendarDay__selected:active,
.CalendarDay__selected:hover {
    background: var(--brand-green-fill);
    border-color: var(--brand-green);
    color: var(--on-fill);
}
.CalendarDay__blocked_out_of_range {
    color: var(--border-opaque);
    background: var(--bg-card);
}
.DayPickerNavigation_button {
    background-color: var(--bg-card);
    border-color: var(--border-opaque);
}
.DayPickerNavigation_svg__horizontal { fill: var(--text-muted); }
.DayPickerKeyboardShortcuts_show { display: none; }

/* ------------------------------------------------------------------ */
/* dcc.Tabs                                                             */
/* ------------------------------------------------------------------ */
.custom-tabs .tab {
    background-color: transparent;
    border: none !important;
    border-bottom: 2px solid var(--border-opaque) !important;
    color: var(--text-muted);
    font-weight: var(--fw-regular);
    font-family: 'Inter', sans-serif;
    padding: 12px 16px;
}
.custom-tabs .tab--selected {
    border-bottom: 2px solid var(--brand-green) !important;
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
}

/* dcc.Loading spinner tint */
.dash-spinner, .dash-default-spinner div { border-color: var(--brand-green) !important; }

/* Alert boxes (info/warning/error/success) */
.alert {
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: var(--fs-md);
    margin: 8px 0;
    border: 1px solid var(--border-medium);
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.alert-info { border-left: 4px solid var(--trust-blue); }
.alert-warning { border-left: 4px solid var(--warning); }
.alert-error { border-left: 4px solid var(--error); }
.alert-success { border-left: 4px solid var(--success); }

/* Section header (green left border, no icon — DESIGN.md rule) */
.section-header {
    color: var(--text-primary);
    font-size: var(--fs-5xl);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.2px;
    margin: 0 0 1rem 0;
    border-left: 4px solid var(--brand-green);
    padding-left: 12px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border-medium);
    margin: 2rem 0;
}

.caption { font-size: var(--fs-xs); color: var(--text-muted); }

/* Sharpe grading scale — shared by the benchmark table legend and the
   /ArticuloBenchmark methodology article, which is why it lives here rather
   than in 02_dashboard.css. Chips stay colour-neutral on purpose: painting
   "Malo" green (or red) would read as a verdict on the fund rather than a
   position on a scale. Ranges come from eda.SHARPE_GRADE_THRESHOLDS. */
.sharpe-scale {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-3) var(--space-1) 0 var(--space-1);
    font-size: var(--fs-2xs);
}
.sharpe-scale-lead {
    color: var(--text-muted);
    font-weight: var(--fw-semibold);
}
.sharpe-scale-item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.sharpe-scale-item strong {
    color: var(--brand-green-text);
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ */
/* Theme audit: make every component follow the active theme            */
/* (near-black text in light mode, near-white in dark mode)             */
/* ------------------------------------------------------------------ */
.dash-shell, .public-page { color: var(--text-primary); }
.dash-shell h1, .dash-shell h2, .dash-shell h3, .dash-shell h4,
.public-page h1, .public-page h2, .public-page h3, .public-page h4 {
    color: var(--text-primary);
}
details summary { color: var(--text-secondary); }

/* dcc.Input placeholder */
.text-input::placeholder { color: var(--text-muted); opacity: 1; }

/* dcc.Tabs: neutralize the component's built-in light-only defaults */
.custom-tabs .tab,
.custom-tabs .tab--selected {
    background-color: transparent !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
}
.custom-tabs + div, .custom-tabs ~ div { color: var(--text-primary); }

/* react-select leftovers */
.dash-dropdown .Select-arrow-zone .Select-arrow {
    border-top-color: var(--text-muted);
}
.dash-dropdown .has-value .Select-value-label { color: var(--text-primary) !important; }
.dash-dropdown .Select.is-disabled > .Select-control {
    background-color: var(--bg-hover);
    color: var(--text-muted);
}

/* react-dates leftovers (containers behind the visible month grid) */
.CalendarMonthGrid,
.CalendarMonthGrid_month__horizontal,
.DayPicker_transitionContainer {
    background-color: var(--bg-card);
}
.CalendarMonth_caption strong { color: var(--text-primary); }
.DateInput_fang { display: none; }

/* Footer copyright link (PROTECTED Big Hub Solutions anchor): must stay a
   clickable, visibly-distinct link on every page. The anchor is a real html.A
   built by footer.py _copyright_paragraph(). Brand-green `!important` locks the
   distinct link color regardless of cascade order (and defends against any
   future inline styling), and `pointer-events: auto` keeps it always clickable. */
.footer-copyright a {
    color: var(--brand-green) !important;
    text-decoration: underline;
    pointer-events: auto;
}
.professional-footer { position: relative; z-index: 1; }

/* Export (CSV/Excel) download row — dashboard + benchmark surfaces. */
.export-buttons {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin: var(--space-2) 0;
}
.export-buttons .btn-secondary {
  padding: 4px 12px;
  font-size: 0.8125rem;
}
.export-status {
  min-height: 1.2em;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.export-status a {
  color: var(--brand-green);
  font-weight: var(--fw-semibold);
}
