/* ===================================
   COMPONENTS - Core (Universal)
   =================================== 
   
   Core UI components loaded on all pages.
   Includes: buttons, cards, toasts, search, basic features.
   
   Dependencies: abstracts/tokens.css
   Used by: All pages
*/

/* ===================================
   BUTTONS
   =================================== */

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 0px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--accent-color);
    color: #000;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color-30);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-color-60);
}

.btn-secondary {
    background: #1a1a1a;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
}

.btn-secondary:hover {
    background: var(--accent-color-10);
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--accent-color-40);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color, #333);
    color: var(--text-secondary, #888);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary, #888);
    color: var(--text-primary, #e0e0e0);
}

.form-actions {
    text-align: center;
    margin-top: 2rem;
}

/* ===================================
   TOAST NOTIFICATIONS
   =================================== */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0px;
    font-size: 0.88rem;
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    letter-spacing: 0.3px;
    z-index: 99999;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    max-width: 380px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #0a0a0a;
    color: var(--accent-color);
    border: 1.5px solid var(--accent-color);
}

.toast-error {
    background: #0a0a0a;
    color: #ff4444;
    border: 1.5px solid #ff4444;
}

.toast-info {
    background: #0a0a0a;
    color: #60a5fa;
    border: 1.5px solid #60a5fa;
}

/* ===================================
   SEARCH CONTAINER
   =================================== */

.search-container {
    position: relative;
    max-width: none;
    width: 100%;
    margin: 0 auto 10rem;
    padding: 0 3rem;
}

.search-box {
    position: relative;
    display: flex;
    background: #1a1a1a;
    border-radius: 0px;
    overflow: hidden;
    box-shadow: 0 0 20px var(--accent-color-30);
    border: 2px solid var(--accent-color);
}

#company-search {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    font-size: 1rem;
    outline: none;
    color: var(--accent-color);
    background: #1a1a1a;
}

#company-search::placeholder {
    color: var(--accent-color-dim);
}

.search-button {
    background: var(--accent-color);
    border: none;
    padding: 1rem 1.5rem;
    color: #000;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
}

.search-button:hover {
    background: var(--accent-color-dim);
    box-shadow: 0 0 15px var(--accent-color-70);
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border-radius: 0px;
    box-shadow: 0 0 20px var(--accent-color-30);
    border: 2px solid var(--accent-color);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-result {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid var(--accent-color-20);
    transition: all 0.2s ease;
}

.search-result:hover {
    background-color: #0d0d0d;
    box-shadow: inset 0 0 10px var(--accent-color-20);
}

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

.company-symbol {
    font-weight: 600;
    color: var(--accent-color);
    font-size: 0.9rem;
    text-shadow: 0 0 5px var(--accent-color-30);
}

.company-name {
    color: var(--accent-color-dim);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.no-results, .search-error {
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--accent-color-dim);
    font-style: italic;
}

.search-error {
    color: #ff3333;
}

/* ===================================
   FEATURE CARDS
   =================================== */

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature {
    text-align: center;
    padding: 2rem;
    background: var(--accent-color-05);
    border-radius: 0px;
    border: 1px solid var(--accent-color-20);
    backdrop-filter: blur(10px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--accent-color-30);
}

.feature p {
    color: var(--accent-color-dim);
    line-height: 1.5;
}

/* ===================================
   LOADING STATES
   =================================== */

.spinner {
    border: 3px solid var(--accent-color-20);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    text-align: center;
    color: var(--accent-color-dim);
    margin-top: 1rem;
}

/* ===================================
   DATE INPUTS & AUTOFILL — Global
   =================================== */

/* Dark color scheme so browser calendar popup uses dark theme */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"] {
    color-scheme: dark;
}

/* Calendar picker icon — white */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0);
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Prevent browser autofill from overriding dark background */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 9999px var(--bg-input, #0d0d0d) inset !important;
    box-shadow: 0 0 0 9999px var(--bg-input, #0d0d0d) inset !important;
    -webkit-text-fill-color: var(--text-primary, #e0e0e0) !important;
    caret-color: var(--text-primary, #e0e0e0);
}

/* ===================================
   DIAMOND SPINNER — Shared Component
   Used on: macro dashboard, company as-presented
   =================================== */

/* Full-panel overlay that sits above content while loading */
.chart-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0E0E0E;
    z-index: 6;
    pointer-events: none;
}

/* 2×2 grid of squares, permanently rotated 45° so corners point N/S/E/W.
   The bright spot cycles clockwise through the four squares via staggered
   opacity animations — the diamond itself never rotates. */
.chart-spinner-inner {
    width: 28px;
    height: 28px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    transform: rotate(45deg);
}

.chart-spinner-inner div {
    background: var(--accent-color, #00FF41);
    border-radius: 1px;
    animation: diamond-pulse 1.2s ease-in-out infinite;
}

/* Clockwise order: top-left (N) → top-right (E) → bottom-right (S) → bottom-left (W) */
.chart-spinner-inner div:nth-child(1) { animation-delay:  0s;    } /* N */
.chart-spinner-inner div:nth-child(2) { animation-delay: -0.9s;  } /* E */
.chart-spinner-inner div:nth-child(3) { animation-delay: -0.3s;  } /* W */
.chart-spinner-inner div:nth-child(4) { animation-delay: -0.6s;  } /* S */

@keyframes diamond-pulse {
    0%, 10%  { opacity: 1.0; }
    30%, 90% { opacity: 0.1; }
    100%     { opacity: 1.0; }
}

/* Also used standalone (e.g. heatmap loading-container) */
.loading-container .chart-spinner-inner {
    margin: 0 auto 1rem;
}

/* ===================================
   AS PRESENTED STATEMENTS — Shared
   Used on: company page P-01/02/03 tabs
   =================================== */

.ap-source-badge {
    font-size: 0.6rem;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--accent-color-dim, #00aa2b);
    border: 1px solid var(--accent-color-20, rgba(0,255,65,0.15));
    padding: 0.2rem 0.5rem;
    vertical-align: middle;
    margin-left: 0.75rem;
    white-space: nowrap;
}

.ap-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.ap-period-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--accent-color-20, rgba(0,255,65,0.15));
}

.ap-period-btn {
    flex: 1;
    min-width: 6rem;          /* ensures Annual and Quarterly have identical width */
    text-align: center;
    background: transparent;
    border: none;
    border-right: 1px solid var(--accent-color-20, rgba(0,255,65,0.15));
    color: #555;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ap-period-btn:last-child {
    border-right: none;
}

.ap-period-btn:hover {
    color: var(--accent-color, #00FF41);
}

.ap-period-btn.active {
    background: var(--accent-color-10, rgba(0,255,65,0.08));
    color: var(--accent-color, #00FF41);
}

.ap-filing-note {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.65rem;
    color: #333;
    letter-spacing: 0.05em;
}

/* Year-range toggle — same visual style as period toggle, sits beside it */
.ap-year-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--accent-color-20, rgba(0,255,65,0.15));
}

.ap-year-btn {
    background: transparent;
    border: none;
    border-right: 1px solid var(--accent-color-20, rgba(0,255,65,0.15));
    color: #555;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ap-year-btn:last-child {
    border-right: none;
}

.ap-year-btn:hover {
    color: var(--accent-color, #00FF41);
}

.ap-year-btn.active {
    background: var(--accent-color-10, rgba(0,255,65,0.08));
    color: var(--accent-color, #00FF41);
}

/* Relative wrapper so the overlay positions correctly over the table */
.ap-table-container {
    position: relative;
    min-height: 120px;
}

.ap-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 14, 14, 0.92);
    z-index: 6;
    min-height: 80px;
}

.ap-placeholder {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.8rem;
    color: #333;
    padding: 2.5rem 0;
    text-align: center;
    letter-spacing: 0.05em;
}

/* ── AP Table ─────────────────────────────────────────────────────────────── */

.ap-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ap-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.72rem;
    color: var(--text-primary, #e0e0e0);
}

.ap-table thead tr {
    border-bottom: 1px solid var(--accent-color-20, rgba(0,255,65,0.15));
}

.ap-table th {
    padding: 0.45rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ap-table th.ap-row-label {
    text-align: left;
    color: #555;
    position: sticky;
    left: 0;
    background: var(--bg-card, #111);
    z-index: 2;
    min-width: 280px;
}

.ap-table th.ap-col-header {
    text-align: right;
    color: var(--text-secondary, #888);
    min-width: 100px;
}

.ap-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.1s;
}

.ap-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.ap-table td {
    padding: 0.35rem 0.75rem;
    vertical-align: middle;
}

.ap-table td.ap-row-label {
    text-align: left;
    color: var(--text-secondary, #aaa);
    cursor: default;
    position: sticky;
    left: 0;
    background: var(--bg-card, #111);
    z-index: 1;
    min-width: 280px;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-table tbody tr:hover td.ap-row-label {
    background: #161616;
}

.ap-table td.ap-cell {
    text-align: right;
    color: var(--text-primary, #e0e0e0);
    white-space: nowrap;
}

.ap-cell-null {
    color: #2a2a2a;
}

/* ── AP row categories ─────────────────────────────────────────────────────
   Four visual tiers applied to rows in the As Presented tables:
     .ap-sub-item      indented detail line (e.g. PP&E Gross, equity components)
     .ap-subtotal      computed sub-total (e.g. PP&E Net, EPS) — green, no extra borders
     .ap-section-total section sum (e.g. Gross Profit, Total Current Assets) — green + border-bottom
     .ap-major-total   grand total (e.g. Total Assets, Net Income) — green + border-top + border-bottom
── */

/* Sub-item: indented detail line — same text color as regular rows */
.ap-table .ap-sub-item td.ap-row-label {
    padding-left: 2.4em;
    font-style: italic;
}

/* Subtotal: computed value — green, border-top only */
.ap-table .ap-subtotal {
    background: rgba(0,255,65,0.03);
}
.ap-table .ap-subtotal td {
    color: var(--accent-color, #00ff41);
    border-top: 1px solid rgba(0,255,65,0.22);
    font-size: 0.74rem;
}
.ap-table .ap-subtotal td.ap-row-label {
    color: var(--accent-color, #00ff41);
    font-weight: 700;
    background: rgba(0,255,65,0.03);
}

/* Section total: section sum — green, border-top only */
.ap-table .ap-section-total {
    background: rgba(0,255,65,0.04);
}
.ap-table .ap-section-total td {
    color: var(--accent-color, #00ff41);
    border-top: 1px solid rgba(0,255,65,0.22);
    font-size: 0.74rem;
}
.ap-table .ap-section-total td.ap-row-label {
    color: var(--accent-color, #00ff41);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(0,255,65,0.04);
}

/* Major total: grand total — green, border-top + border-bottom */
.ap-table .ap-major-total {
    background: rgba(0,255,65,0.06);
}
.ap-table .ap-major-total td {
    color: var(--accent-color, #00ff41);
    border-top: 2px solid rgba(0,255,65,0.35);
    border-bottom: 2px solid rgba(0,255,65,0.35);
    font-size: 0.74rem;
}
.ap-table .ap-major-total td.ap-row-label {
    color: var(--accent-color, #00ff41);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(0,255,65,0.06);
}

/* Hover: darken label background for sticky cell */
.ap-table tbody tr:hover.ap-subtotal td.ap-row-label {
    background: rgba(0,255,65,0.06);
}
.ap-table tbody tr:hover.ap-section-total td.ap-row-label {
    background: rgba(0,255,65,0.07);
}
.ap-table tbody tr:hover.ap-major-total td.ap-row-label {
    background: rgba(0,255,65,0.1);
}

/* Spacer rows between sections — approximately one row height */
.ap-table tr.ap-spacer {
    height: 2rem;
    pointer-events: none;
}
.ap-table tr.ap-spacer td {
    padding: 0;
    border: none;
    background: transparent;
}

/* ── Integrity check table ───────────────────────────────────────────────── */
.ap-integrity-wrap {
    margin-top: 1.5rem;
}
.ap-integrity-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #555;
    padding: 0 0.5rem 0.4rem;
    border-bottom: 1px solid #1e1e1e;
    margin-bottom: 0.25rem;
}
.ap-integrity-table td.ap-check-ok {
    color: #00cc44;
    font-weight: 700;
    text-align: center;
}
.ap-integrity-table td.ap-check-fail {
    color: #ff4444;
    font-weight: 700;
    text-align: right;
}
.ap-integrity-table td.ap-check-na {
    color: #333;
    text-align: center;
}
