/* ============================================================
   Shareholder Portal – App Styles
   Adapted from KirbyWebapp/app/assets/css/app.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:    #1a56db;
    --color-primary-dk: #1245b6;
    --color-success:    #057a55;
    --color-success-bg: #def7ec;
    --color-error:      #c81e1e;
    --color-error-bg:   #fde8e8;
    --color-warning-bg: #fef3c7;
    --color-border:     #d1d5db;
    --color-muted:      #6b7280;
    --color-bg:         #f9fafb;
    --color-white:      #ffffff;
    --radius:           6px;
    --shadow:           0 1px 3px rgba(0,0,0,.1);
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #111827;
    background: var(--color-bg);
}

/* ── Layout ─────────────────────────────────────────────── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.app-main {
    padding: 2rem 0 4rem;
}

/* ── Header / Nav ────────────────────────────────────────── */
.app-header {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-logo {
    font-weight: 700;
    font-size: 1rem;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.app-nav {
    display: flex;
    gap: .25rem;
    flex: 1;
}

.nav-link {
    padding: .375rem .75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--color-muted);
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
    background: #eff6ff;
    color: var(--color-primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
    white-space: nowrap;
}

.user-email {
    font-size: .85rem;
    color: var(--color-muted);
}

/* ── Flash messages ─────────────────────────────────────── */
.flash {
    padding: .875rem 1.25rem;
    border-radius: var(--radius);
    margin: 1rem auto;
    max-width: 960px;
    font-weight: 500;
}
.flash-success { background: var(--color-success-bg); color: var(--color-success); }
.flash-error   { background: var(--color-error-bg);   color: var(--color-error); }
.flash-info    { background: var(--color-warning-bg);  color: #92400e; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    padding: .5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
    line-height: 1;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dk); }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: #374151; }
.btn-outline:hover { background: #f3f4f6; }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }

/* ── Login page ─────────────────────────────────────────── */
.app-login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { background: var(--color-white); border: 1px solid var(--color-border); border-radius: 10px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.login-wrap h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-subtitle { color: var(--color-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.login-form .field { margin-bottom: 1rem; }
.login-form label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .3rem; }
.login-form input { width: 100%; padding: .55rem .75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: .95rem; }
.login-form input:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.login-form .btn { width: 100%; justify-content: center; margin-top: .5rem; padding: .7rem; }
.login-tabs { display: flex; gap: .375rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); padding: .25rem; margin-bottom: 1.5rem; }
.login-tab { flex: 1; padding: .45rem; font-size: .875rem; font-weight: 600; border: none; border-radius: calc(var(--radius) - 2px); background: transparent; cursor: pointer; color: var(--color-muted); transition: background .15s, color .15s; }
.login-tab.active { background: var(--color-white); color: var(--color-text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ── Tables ────────────────────────────────────────────── */
.startups-table,
.ratings-overview-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}
.startups-table th,
.startups-table td,
.ratings-overview-table th,
.ratings-overview-table td {
    padding: .65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: .9rem;
}
.startups-table th,
.ratings-overview-table th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
}
.startups-table tr:last-child td,
.ratings-overview-table tr:last-child td { border-bottom: none; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; margin-left: .5rem; vertical-align: middle; }
.badge-active { background: var(--color-success-bg); color: var(--color-success); }
.badge-closed { background: #f3f4f6; color: var(--color-muted); }

.status { font-size: .82rem; font-weight: 600; }
.status-rated   { color: var(--color-success); }
.status-pending { color: #d97706; }

/* ── Batch sections ─────────────────────────────────────── */
.batch-section { margin-bottom: 3rem; }
.batch-heading { font-size: 1.2rem; margin-bottom: 1rem; display: flex; align-items: center; }
.batch-subheading { font-size: 1rem; color: var(--color-muted); margin: 1rem 0 .5rem; }

/* ── Startup detail ─────────────────────────────────────── */
.container--wide { max-width: 98vw; padding: 0 1rem; }

.breadcrumb { margin-bottom: 1.25rem; font-size: .875rem; }
.breadcrumb a { color: var(--color-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.startup-header { margin-bottom: 1.5rem; }
.startup-header h1 { font-size: 1.75rem; margin-bottom: .5rem; }
.startup-meta { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: .75rem; }
.meta-item { font-size: .9rem; color: var(--color-muted); }
.startup-description { color: #374151; line-height: 1.7; max-width: 720px; }

/* ── Two-column workspace ────────────────────────────────── */
.startup-workspace {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 1.5rem;
    align-items: start;
}

/* ── PDF panel ───────────────────────────────────────────── */
.pdf-panel {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.pdf-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .875rem;
    border-bottom: 1px solid var(--color-border);
    background: #f9fafb;
    flex-wrap: wrap;
}

.pdf-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--color-muted);
    white-space: nowrap;
}

.pdf-select {
    flex: 1;
    min-width: 0;
    padding: .35rem .6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .85rem;
    background: var(--color-white);
    cursor: pointer;
}
.pdf-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.pdf-viewer {
    width: 100%;
    height: calc(100vh - 160px);
    min-height: 600px;
    border: none;
    display: block;
}

.pdf-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--color-muted);
    font-size: .9rem;
}

/* ── Rating panel ────────────────────────────────────────── */
.rating-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: .5rem;
}

@media (max-width: 900px) {
    .startup-workspace {
        grid-template-columns: 1fr;
    }
    .pdf-viewer {
        height: 60vw;
        min-height: 320px;
    }
}

/* ── Rating form ────────────────────────────────────────── */
.rating-form { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); }
.rating-field { margin-bottom: 1.5rem; }
.rating-field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.score-range { font-size: .8rem; font-weight: 400; color: var(--color-muted); }

.score-input-wrap { display: flex; align-items: center; gap: 1rem; }
.score-range-input { flex: 1; accent-color: var(--color-primary); cursor: pointer; }
.score-number-input { width: 56px; padding: .4rem .5rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: .95rem; text-align: center; }

.comment-textarea { width: 100%; padding: .6rem .75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: .9rem; font-family: inherit; line-height: 1.5; resize: vertical; }
.comment-textarea:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.last-saved { font-size: .8rem; color: var(--color-muted); margin-bottom: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; }

/* ── Rating readonly ────────────────────────────────────── */
.batch-closed-banner {
    background: var(--color-warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: .9rem;
    font-weight: 600;
}

.rating-display { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.rating-row { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--color-border); align-items: start; }
.rating-row:last-child { border-bottom: none; }
.rating-row dt { font-weight: 600; font-size: .875rem; padding-top: .15rem; }
.rating-row dd { font-size: .9rem; }
.rating-meta dt, .rating-meta dd { font-size: .8rem; color: var(--color-muted); }

.score-display { font-weight: 700; font-size: 1.05rem; display: block; margin-bottom: .35rem; }
.score-bar { height: 6px; background: #e5e7eb; border-radius: 999px; overflow: hidden; width: 100%; max-width: 200px; }
.score-bar-fill { height: 100%; background: var(--color-primary); border-radius: 999px; transition: width .3s; }

.comment-text { white-space: pre-wrap; font-size: .9rem; line-height: 1.6; }

/* ── My Company ─────────────────────────────────────────── */
.company-id-info { color: var(--color-muted); font-size: .9rem; margin-bottom: 2rem; }
.company-id-info code { background: #f3f4f6; padding: .1rem .35rem; border-radius: 3px; font-size: .85rem; }
.ratings-section { margin-bottom: 2.5rem; }
.ratings-section h2 { font-size: 1.1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--color-border); padding-bottom: .5rem; }

/* ── Seedhouse overview ─────────────────────────────────── */
details.startup-detail { margin-bottom: .75rem; background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); }
details.startup-detail summary { padding: .75rem 1rem; cursor: pointer; display: flex; align-items: center; gap: 1rem; list-style: none; }
details.startup-detail summary::-webkit-details-marker { display: none; }
details.startup-detail summary strong { flex: 1; }
.rating-count { font-size: .8rem; color: var(--color-muted); background: #f3f4f6; padding: .1rem .45rem; border-radius: 999px; }
details.startup-detail[open] { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
details.startup-detail .ratings-overview-table { margin: 0; box-shadow: none; border-radius: 0; border-top: 1px solid var(--color-border); }
.comment-cell { max-width: 220px; white-space: pre-wrap; font-size: .8rem; }

/* ── Overview sections ───────────────────────────────────── */
.overview-section { margin-bottom: 3rem; }
.overview-section h2 { font-size: 1.2rem; margin-bottom: .5rem; }
.section-subtitle { color: var(--color-muted); font-size: .875rem; margin-bottom: 1rem; }

/* Progress table */
.progress-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.progress-table th,
.progress-table td {
    padding: .65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: .9rem;
}
.progress-table th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
}
.progress-table tr:last-child td { border-bottom: none; }
.progress-done         { color: var(--color-success); font-weight: 700; }
.progress-in-progress  { color: #d97706; font-weight: 600; }
.progress-not-started  { color: var(--color-muted); }
.progress-bar-cell     { display: flex; align-items: center; gap: .6rem; min-width: 160px; }
.overview-progress-bar { flex: 1; height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.overview-progress-fill { height: 100%; background: var(--color-primary); border-radius: 999px; transition: width .3s; }
.overview-progress-pct { font-size: .8rem; color: var(--color-muted); white-space: nowrap; }

/* Leaderboard table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.leaderboard-table th,
.leaderboard-table td {
    padding: .65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: .9rem;
}
.leaderboard-table th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-rank  { font-weight: 700; color: var(--color-muted); width: 3rem; }
.leaderboard-score { font-weight: 700; color: var(--color-primary); }
.leaderboard-unrated td { color: var(--color-muted); }
.leaderboard-unrated .startup-link { color: var(--color-muted); font-weight: 400; }

/* Past batches */
.past-batch { margin-bottom: 2rem; }
.past-batch h3 { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; color: #374151; }
details.past-batches-toggle {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-white);
}
details.past-batches-toggle > summary {
    padding: .75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: .9rem;
    list-style: none;
    color: var(--color-muted);
}
details.past-batches-toggle > summary::-webkit-details-marker { display: none; }
details.past-batches-toggle[open] > summary { border-bottom: 1px solid var(--color-border); }
details.past-batches-toggle > :not(summary) { padding: 1.25rem 1rem 0; }

/* ── Misc ────────────────────────────────────────────────── */
.empty-state { color: var(--color-muted); font-size: .9rem; padding: 1.5rem 0; }
.muted-dash  { color: var(--color-muted); }

/* ── Wide container (startups table) ────────────────────── */
.container--xl {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Page heading row ────────────────────────────────────── */
.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.page-heading h1 { margin: 0; }

/* ── Batch filter (overview page heading) ────────────────── */
.batch-filter       { display: flex; align-items: center; gap: .5rem; }
.batch-filter-label { font-size: .875rem; font-weight: 600; color: var(--color-muted); white-space: nowrap; }

/* ── Progress banner ─────────────────────────────────────── */
.progress-banner {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .875rem 1.25rem;
    min-width: 260px;
    max-width: 360px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .4rem;
}
.progress-label   { font-size: .82rem; color: var(--color-muted); font-weight: 500; }
.progress-fraction { font-size: 1rem; color: #111827; }
.progress-track {
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: .35rem;
}
.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
    transition: width .4s ease;
    min-width: 2px;
}
.progress-sub { font-size: .78rem; color: var(--color-muted); margin: 0; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: .875rem 1rem;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.filter-group label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
}
.filter-select {
    padding: .375rem .625rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .875rem;
    background: var(--color-bg);
    cursor: pointer;
    min-width: 140px;
}
.filter-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.filter-count {
    margin-left: auto;
    align-self: center;
    font-size: .82rem;
    color: var(--color-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* ── Scrollable table wrapper ────────────────────────────── */
.table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.startups-table--full {
    min-width: 1000px;
}

/* ── Sortable column headers ─────────────────────────────── */
.th-sortable { user-select: none; white-space: nowrap; cursor: pointer; }
.th-sortable:hover { background: #e9ebee; }
.sort-icon { opacity: .35; font-size: .8em; margin-left: .25em; }
.th-sortable.sort-asc  .sort-icon { opacity: 1; color: var(--color-primary); }
.th-sortable.sort-desc .sort-icon { opacity: 1; color: var(--color-primary); }
.th-sortable.sort-asc  .sort-icon::after { content: ' ↑'; }
.th-sortable.sort-desc .sort-icon::after { content: ' ↓'; }
.th-sortable:not(.sort-asc):not(.sort-desc) .sort-icon::after { content: ' ↕'; }

/* ── Batch tag ───────────────────────────────────────────── */
.batch-tag {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: #f3f4f6;
    color: var(--color-muted);
    white-space: nowrap;
}
.batch-tag--active {
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* ── Score chip ──────────────────────────────────────────── */
.score-chip {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: var(--radius);
    background: #eff6ff;
    color: var(--color-primary);
    font-weight: 700;
    font-size: .875rem;
}

/* ── Table cell constraints ──────────────────────────────── */
.startup-link { color: var(--color-primary); text-decoration: none; font-weight: 600; white-space: nowrap; }
.startup-link:hover { text-decoration: underline; }
.col-name { white-space: nowrap; }
.col-desc {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .85rem;
    color: #374151;
}
.col-action { white-space: nowrap; }

/* ── Rating status notice ────────────────────────────────── */
.rating-status-notice {
    padding: .6rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.rating-status-notice--pending {
    background: var(--color-warning-bg);
    color: #92400e;
}
.rating-status-notice--submitted {
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* ── Rating criteria count / avg ─────────────────────────── */
.rating-criteria-count {
    font-size: .85rem;
    color: var(--color-muted);
    margin: .25rem 0 .75rem;
}
.rating-avg-score {
    font-size: .9rem;
    margin-bottom: 1.25rem;
}

/* ── Zero-state rating field ─────────────────────────────── */
.rating-field--zero > label { color: var(--color-muted); }
.rating-field--zero .score-range-input,
.rating-field--zero .score-number-input { opacity: .45; }

/* ── Loading / spinner ───────────────────────────────────── */
.loading {
    color: var(--color-muted);
    font-size: .9rem;
    padding: 2rem 0;
    text-align: center;
}

@media (max-width: 640px) {
    .header-inner { flex-wrap: wrap; height: auto; padding: .5rem 1rem; gap: .5rem; }
    .app-nav { order: 3; flex-wrap: wrap; flex: 0 0 100%; }
    .rating-row { grid-template-columns: 1fr; }
    .score-input-wrap { flex-direction: column; align-items: flex-start; }
}
