/* Ticker search widget — shared between finance section and company pages */

.ticker-search-widget {
    position: relative;
    max-width: 480px;
    margin: 1rem 0 1.5rem 0;
}

/* On section pages the widget sits outside .company-page (which has
   its own 1rem padding on entity pages). Match the .article-grid's
   padding so the search bar aligns with the article cards. */
.main-content > .ticker-search-widget {
    padding: 0 1rem;
}

.ticker-search-widget input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.ticker-search-widget input:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

.ticker-search-results {
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    z-index: 100;
    display: none;
    max-height: 360px;
    overflow-y: auto;
}

.ticker-result {
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    display: grid;
    grid-template-columns: 5rem 1fr auto;
    gap: 0.5rem;
    align-items: baseline;
    border-bottom: 1px solid #f0f0f0;
}

.ticker-result:last-child {
    border-bottom: none;
}

.ticker-result:hover,
.ticker-result.active {
    background: #f5f9ff;
}

.ticker-result-symbol {
    font-weight: 700;
    font-family: Menlo, Consolas, monospace;
}

.ticker-result-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticker-result-exchange {
    font-size: 0.8rem;
    color: #777;
    white-space: nowrap;
}

.ticker-result-empty {
    padding: 0.55rem 0.8rem;
    color: #888;
    font-style: italic;
    font-size: 0.9rem;
    cursor: default;
}

/* Company page styles */

.company-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

.company-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
    background: transparent;
}

.company-header h1 {
    margin: 0 0 0.35rem 0;
    font-size: 2rem;
    line-height: 1.2;
    color: #111;
}

.company-meta {
    color: #444;
    font-size: 0.95rem;
}

.company-meta .ticker {
    font-weight: 700;
    color: #111;
    font-family: Menlo, Consolas, monospace;
    letter-spacing: 0.02em;
}

.company-meta .sep {
    margin: 0 0.5rem;
    color: #999;
}

.security-selector {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

.security-link {
    display: inline-block;
    margin: 0 0.3rem;
    padding: 0.1rem 0.45rem;
    background: #f0f4ff;
    border: 1px solid #c5d5f0;
    border-radius: 3px;
    font-family: Menlo, Consolas, monospace;
    font-size: 0.9em;
    color: #1565c0;
    text-decoration: none;
}

.security-link:hover {
    background: #dbe5f5;
}

.security-type-tag {
    margin-left: 0.3rem;
    font-family: inherit;
    font-size: 0.85em;
    color: #888;
    font-weight: normal;
}

.company-chart {
    margin-bottom: 2rem;
    height: 520px;
    min-height: 520px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chart-loading-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.95rem;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 4px;
    z-index: 0;
}

.tradingview-widget-container {
    position: relative;
    z-index: 1;
}

.tradingview-widget-container {
    flex: 1;
    min-height: 0;
}

.tradingview-widget-container,
.tradingview-widget-container__widget {
    height: 100%;
    width: 100%;
}

.company-articles h2 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}

.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.article-list li {
    border-bottom: 1px solid #eee;
}

.article-list li:last-child {
    border-bottom: none;
}

.article-link {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.6rem 0;
    text-decoration: none;
    color: inherit;
}

.article-link:hover .article-title {
    text-decoration: underline;
}

.article-date {
    font-size: 0.85rem;
    color: #777;
    font-variant-numeric: tabular-nums;
    min-width: 5.5rem;
    flex-shrink: 0;
}

.article-title {
    flex: 1;
}

.no-coverage {
    color: #777;
    font-style: italic;
}

.company-financials {
    margin-top: 2rem;
}

.company-financials h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.period-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 0.5rem;
}

.period-tab {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    text-decoration: none;
    color: #555;
    border: 1px solid #ddd;
    background: #fafafa;
}

.period-tab:first-child {
    border-radius: 4px 0 0 4px;
}

.period-tab:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.period-tab.active {
    background: #1565c0;
    color: #fff;
    border-color: #1565c0;
}

.period-tab:hover:not(.active) {
    background: #eee;
}

.financials-note {
    font-size: 0.85rem;
    color: #777;
    margin: 0 0 1rem 0;
}

.statement-block {
    margin-bottom: 1.5rem;
}

.statement-block h3 {
    font-size: 1.05rem;
    margin: 0 0 0.4rem 0;
    color: #222;
}

/* Split the statement into two panes: pinned labels on the left,
 * horizontally-scrollable data on the right. This keeps the
 * scrollbar confined to the data area rather than spanning the full
 * width (including the label column, which doesn't scroll anyway). */
.statement-split {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.labels-pane {
    flex: 0 0 auto;
    background: #fff;
    border-right: 1px solid #e0e0e0;
}

.data-pane {
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: hidden;
}

.statement-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.statement-table.labels {
    width: 200px;
}

.statement-table.data {
    width: max-content;
    min-width: 100%;
}

.statement-table th,
.statement-table td {
    padding: 0.35rem 0.6rem;
    text-align: right;
    white-space: nowrap;
    min-width: 5.5rem;
    height: 2rem;          /* fixed height so labels and data rows align */
    box-sizing: border-box;
}

/* Labels pane — left-aligned, fixed-width */
.statement-table.labels th,
.statement-table.labels td {
    text-align: left;
    font-weight: 500;
    width: 200px;
    min-width: 200px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header styling shared between the two panes */
.statement-table thead tr:first-child th {
    background: #f5f5f5;
    font-weight: 700;
    font-family: Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

.statement-table thead .period-end-row th {
    font-size: 0.75rem;
    font-weight: normal;
    color: #888;
    background: #fafafa;
}

.statement-table tbody td {
    border-bottom: 1px solid #f0f0f0;
    font-variant-numeric: tabular-nums;
}

/* Header/body separator — applied on the TOP of the first body row's
 * cells so the line lives purely on horizontal borders, avoiding the
 * sub-pixel alignment issues that came from mixing the border-bottom
 * on period-end-row cells with the pane-split vertical border. */
.statement-table tbody tr:first-child td {
    border-top: 2px solid #ddd;
}

.statement-table td[title] {
    cursor: help;
}

/* "Load more periods" cell lives in the data pane, at the right edge
 * of the header row — always visible above the scrollbar's right end. */
.statement-table th.load-more-cell {
    min-width: 2.5rem;
    padding: 0.2rem 0.3rem;
    background: #f5f5f5;
    border-left: 1px solid #e0e0e0;
    position: sticky;
    right: 0;
    z-index: 1;
}

.load-more-btn {
    border: 1px solid #1565c0;
    background: #fff;
    color: #1565c0;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.load-more-btn:hover:not(:disabled) {
    background: #1565c0;
    color: #fff;
}

.load-more-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.statement-table tbody tr:last-child td {
    border-bottom: none;
}

.statement-table td.num {
    font-family: Menlo, Consolas, monospace;
}

.statement-table td[title] {
    cursor: help;
}

.statements-footer {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
    font-size: 0.8rem;
    color: #888;
}

.period-count-note {
    font-size: 0.8rem;
    color: #888;
}

.loading-indicator {
    font-size: 0.8rem;
    color: #1565c0;
    font-style: italic;
}

/* Period tabs as buttons (replacing the old anchor-based tabs since
 * Alpine handles click → fetch without navigation). */
.period-tab {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    text-decoration: none;
    color: #555;
    border: 1px solid #ddd;
    background: #fafafa;
    cursor: pointer;
    font-family: inherit;
}

.company-filings {
    margin-top: 2rem;
}

.company-filings h2 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}

.filing-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filing-list li {
    border-bottom: 1px solid #eee;
}

.filing-list li:last-child {
    border-bottom: none;
}

.filing-link {
    display: grid;
    grid-template-columns: 5.5rem 4rem 1fr;
    gap: 0.75rem;
    align-items: baseline;
    padding: 0.5rem 0;
    text-decoration: none;
    color: inherit;
}

.filing-link:hover .filing-title {
    text-decoration: underline;
}

.filing-date {
    font-size: 0.85rem;
    color: #777;
    font-variant-numeric: tabular-nums;
}

.filing-form {
    font-family: Menlo, Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1565c0;
}

.filing-title {
    color: #222;
}

@media (max-width: 720px) {
    .company-chart {
        height: 400px;
    }
    .article-link {
        flex-direction: column;
        gap: 0.15rem;
    }
    .article-date {
        min-width: 0;
    }
}
