/* Smart BSE Alerts - Custom styles */

/* ──────────────────────────────────────────────────────────────────────
 *  Global typography — pack more info per screen, refined density
 * ────────────────────────────────────────────────────────────────────── */

:root {
    /* Override Pico v2 sizing scale. Pico's default is ~16/18px which
       feels like a consumer blog; financial dashboards read better at
       13-14px with tighter line-height. */
    --pico-font-size: 14px;
    --pico-line-height: 1.5;
    --pico-typography-spacing-vertical: 0.75rem;
    --pico-spacing: 0.85rem;
    --pico-form-element-spacing-vertical: 0.45rem;
    --pico-form-element-spacing-horizontal: 0.7rem;
    --pico-border-radius: 0.4rem;
    --pico-block-spacing-vertical: 1rem;
    --pico-block-spacing-horizontal: 1rem;

    /* System font stack: native UI fonts on each OS for an immediately
       'premium' feel, falling back to Inter (Pico ships it as default).
       Numbers use tabular figures wherever they appear in tables. */
    --pico-font-family-sans-serif:
        -apple-system, BlinkMacSystemFont,
        "Segoe UI Variable", "Segoe UI",
        Inter, Roboto, "Helvetica Neue", Helvetica,
        Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    --pico-font-family: var(--pico-font-family-sans-serif);
    --pico-font-family-monospace:
        ui-monospace, "SF Mono", Menlo, Monaco, Consolas,
        "Cascadia Code", "Roboto Mono", monospace;
    --pico-font-weight: 400;
}

html { font-size: 14px; }

body {
    font-feature-settings: "ss01", "cv11", "kern";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1 { font-size: 1.5rem;  margin: 0.6rem 0 0.5rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem;  margin: 0.6rem 0 0.4rem; line-height: 1.3;  font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 1.02rem; margin: 0.55rem 0 0.35rem; line-height: 1.35; font-weight: 600; }
h4 { font-size: 0.92rem; margin: 0.5rem 0 0.3rem; line-height: 1.35; font-weight: 600; }
h5 { font-size: 0.85rem; margin: 0.4rem 0 0.25rem; font-weight: 600; }
h6 { font-size: 0.8rem;  margin: 0.4rem 0 0.25rem; font-weight: 600; }

p, li { line-height: 1.5; }
small { font-size: 0.82rem; }
code, kbd, pre, samp { font-size: 0.85em; }

/* Tables inherit a denser default everywhere - alerts table, deals
   table, IPO table, IPO financials table all benefit. Per-table CSS
   below can still override. */
table { font-size: 0.85rem; }
table th { font-weight: 600; }
table th, table td { padding: 0.4rem 0.65rem; }

/* Pico's <article> has a chunky 1.25rem-ish padding by default; tighten
   it across the board. Specific .alert-card / .ipo-table-wrap classes
   tune themselves further. */
article {
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.6rem;
}

/* Container width slightly larger so dense tables don't feel squeezed. */
@media (min-width: 992px) {
    body > main.container,
    body > header.container,
    body > footer.container {
        max-width: 1100px;
    }
}

/* Form inputs feel premium when sized to match the body text exactly. */
input:not([type="checkbox"]):not([type="radio"]),
select, textarea, button[type="submit"], .button, [role="button"] {
    font-size: 0.9rem;
}

/* Top-nav: tighter, smaller. Logo stays at strong weight. */
header.container nav {
    padding: 0.4rem 0;
}
header.container nav a, header.container nav strong {
    font-size: 0.92rem;
}

footer.container small {
    font-size: 0.78rem;
    color: var(--muted-color, #6b7280);
}

/* ── Mobile nav toggle ── */
.nav-toggle {
    display: none;
    background: none;
    border: 0;
    box-shadow: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    margin-bottom: 0;
    line-height: 1;
    width: auto;
    appearance: none;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: inline-block;
    }

    nav {
        flex-wrap: wrap;
    }

    nav .nav-links {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    nav .nav-links.open {
        display: flex;
    }

    nav .nav-links li {
        display: block;
        width: 100%;
        padding: 0.4rem 0;
    }
}

/* ── Category badges ── */
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-financial { background: #dbeafe; color: #1e40af; }
.badge-dividend { background: #d1fae5; color: #065f46; }
.badge-board { background: #fef3c7; color: #92400e; }
.badge-insider { background: #fce7f3; color: #9d174d; }
.badge-corporate { background: #e0e7ff; color: #3730a3; }
.badge-management { background: #f3e8ff; color: #6b21a8; }
.badge-merger { background: #ffedd5; color: #9a3412; }
.badge-compliance { background: #f1f5f9; color: #475569; }
.badge-general { background: #f5f5f5; color: #737373; }
.badge-unanalyzed { background: #fef2f2; color: #991b1b; }

/* ── Impact indicators ── */
.impact-high { color: #dc2626; font-weight: 700; }
.impact-medium { color: #d97706; font-weight: 600; }
.impact-low { color: #6b7280; }

/* ── Alert cards ── */
.alert-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.15s;
}

.alert-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.alert-card-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.alert-company {
    font-size: 0.95rem;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 28ch;
}

.alert-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted-color, #6b7280);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.alert-meta small { font-size: 0.8rem; }

.alert-link {
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
}

.impact-pill {
    font-size: 0.85rem;
    line-height: 1;
}

.alert-summary {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--color, #1f2937);
    /* Clamp the summary to two lines so each card stays compact (3 lines
       total: header row + 2 lines of summary). Multi-line ellipsis is
       supported in all modern browsers via -webkit-line-clamp. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Older legacy class kept for any cached pages or tests; keeps space-between layout. */
.alert-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

/* ── Watchlist entries ── */
.watchlist-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* ── Responsive stacking ── */
@media (max-width: 576px) {
    .alert-card-row {
        gap: 0.35rem;
    }

    .alert-company {
        max-width: 18ch;
    }

    .alert-meta {
        margin-left: auto;
        gap: 0.4rem;
    }

    .alert-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .watchlist-entry {
        flex-direction: column;
        align-items: flex-start;
    }

    .watchlist-entry button {
        align-self: flex-end;
    }
}

/* ── Status indicators ── */
.status-ok { color: #16a34a; }
.status-warn { color: #d97706; }
.status-error { color: #dc2626; }


/* -- IPO list table -- */
.ipo-table-wrap {
    margin-top: 1rem;
    border: 1px solid var(--card-border-color, #e5e7eb);
    border-radius: 0.5rem;
    overflow-x: auto;
}
.ipo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: 0;
}
.ipo-table thead th {
    background: var(--card-sectionning-background-color, #f9fafb);
    text-align: left;
    padding: 0.4rem 0.6rem;
    font-weight: 600;
    color: var(--muted-color, #6b7280);
    text-transform: uppercase;
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--card-border-color, #e5e7eb);
    white-space: nowrap;
}
.ipo-table tbody td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--card-border-color, #f1f5f9);
    vertical-align: middle;
    white-space: nowrap;
}
.ipo-table tbody tr:last-child td { border-bottom: none; }
.ipo-table tbody tr:hover { background: var(--card-sectionning-background-color, #fafbfd); }
.ipo-table th.num, .ipo-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.ipo-company-link {
    font-weight: 600;
    text-decoration: none;
    color: var(--primary, #2563eb);
}
.ipo-company-link:hover { text-decoration: underline; }
.ipo-company {
    max-width: 24ch;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ipo-symbol code {
    font-size: 0.78rem;
    background: var(--card-sectionning-background-color, #f3f4f6);
    padding: 0.05rem 0.3rem;
    border-radius: 0.2rem;
}

.ipo-status-live    { color: #dc2626; font-weight: 600; }
.ipo-status-upcoming { color: #b45309; font-weight: 600; }
.ipo-status-closed  { color: #6d28d9; font-weight: 600; }
.ipo-status-listed  { color: #15803d; font-weight: 600; }
.ipo-status-other   { color: #6b7280; }

@media (max-width: 600px) {
    .ipo-table { font-size: 0.75rem; }
    /* On phones drop the optional columns to keep the row scannable */
    .ipo-table th:nth-child(4),  .ipo-table td:nth-child(4),  /* Issue ₹ */
    .ipo-table th:nth-child(5),  .ipo-table td:nth-child(5),  /* Band */
    .ipo-table th:nth-child(8),  .ipo-table td:nth-child(8),  /* Open */
    .ipo-table th:nth-child(10), .ipo-table td:nth-child(10) { /* Listing */
        display: none;
    }
    .ipo-company { max-width: 14ch; }
}

/* -- Footer last-updated badge -- */
.last-updated {
    color: var(--muted-color, #6b7280);
    font-variant-numeric: tabular-nums;
}