/*
  Silverleaf Academy brand palette.
  Font requested is "Messarat Light" - no font file has been provided yet, so it's
  referenced by name with a system sans-serif fallback. If you send the actual font
  file (.woff2/.ttf), an @font-face rule can be added here so it renders correctly
  for every visitor instead of only those who happen to have it installed locally.
*/
:root {
    --brand: #002368;       /* main theme */
    --brand-dark: #001a4d;  /* hover/pressed state of the main theme colour */
    --on-brand: #ffffff;    /* text on top of the main theme colour */
    --bg: #ececec;
    --card: #ffffff;
    --border: #d4d4d4;
    --text: #000000;
    --muted: #4a4a4a;
    --highlight: #80bfec;   /* highlighting */
    --accent: #ffc952;      /* decorations/shapes */
    --danger: #b3261e;      /* not part of the brand palette - kept for reject/error states */
    --danger-bg: #fbeceb;

    /* Pipeline stage identity + status colours (accessible hues, not decorative picks) */
    --stage-new: #898781;
    --stage-online: #2a78d6;
    --stage-inperson: #4a3aa7;
    --stage-culture: #c98500;
    --stage-performance: #eb6834;
    --stage-awaiting: #fab219;
    --stage-selected: #0ca30c;
    --stage-selected-bg: #e6f6e6;
    --stage-rejected: #d03b3b;
    --stage-rejected-bg: #fbeceb;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Messarat Light", "Messarat", -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

h1, h2, h3 { color: var(--brand); }

a { color: var(--brand); }
a:hover { color: var(--highlight); }

.topbar {
    background: var(--brand);
    color: var(--on-brand);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--accent);
}

.topbar a { color: var(--on-brand); text-decoration: none; }
.topbar a:hover { color: var(--highlight); }
.topbar .brand { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--on-brand);
    cursor: pointer;
    padding: 6px;
    display: inline-flex;
    width: auto;
}
.menu-toggle:hover { background: rgba(255, 255, 255, 0.12); color: var(--on-brand); }
.menu-toggle .icon { width: 24px; height: 24px; }

.side-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 90;
}
.side-nav-backdrop.open { display: block; }

.side-nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 260px;
    max-width: 80vw;
    background: var(--brand);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 16px;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 95;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.25);
    border-left: 3px solid var(--accent);
}
.side-nav.open { transform: translateX(0); }

.side-nav-close {
    align-self: flex-end;
    background: transparent;
    border: none;
    color: var(--on-brand);
    cursor: pointer;
    padding: 6px;
    margin-bottom: 12px;
    width: auto;
}
.side-nav-close:hover { background: rgba(255, 255, 255, 0.12); color: var(--on-brand); }
.side-nav-close .icon { width: 22px; height: 22px; }

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 6px;
    color: var(--on-brand);
    text-decoration: none;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.12); color: var(--on-brand); }
.side-nav a small { display: block; opacity: 0.75; font-weight: 400; font-size: 11px; margin-top: 2px; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.auth-card {
    max-width: 380px;
    margin: 80px auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 10px;
    padding: 32px;
    box-shadow: var(--shadow-card);
}

.auth-card h1 { font-size: 20px; margin-top: 0; }

.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.15em;
    flex-shrink: 0;
}
.icon-lg { width: 36px; height: 36px; color: var(--brand); margin-bottom: 8px; }
.badge .icon, .stage-icon .icon { width: 14px; height: 14px; }
h1 .icon, h3 .icon { width: 18px; height: 18px; }
.brand .icon { width: 20px; height: 20px; vertical-align: -0.25em; }

label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }

input[type="email"], input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="file"], textarea, select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    margin-bottom: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(128, 191, 236, 0.35);
}

button, .btn {
    background: var(--brand);
    color: var(--on-brand);
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover, .btn:hover { background: var(--brand-dark); color: var(--on-brand); }

.btn-danger { background: var(--danger); }
.btn-secondary { background: #5b6472; }

.flash {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-ok { background: #e3eefb; color: var(--brand); }

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--tile-color, var(--brand));
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
}
.stat-tile .value { font-size: 28px; font-weight: 700; color: var(--tile-color, var(--brand)); line-height: 1.1; }
.stat-tile .label { font-size: 13px; color: var(--muted); margin-top: 2px; }

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.chart-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
}
.chart-card h3 { margin-top: 0; margin-bottom: 14px; font-size: 15px; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 32px; align-items: center; gap: 10px; }
.bar-row .bar-label {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
}
.bar-row .bar-label .icon { flex-shrink: 0; }
.bar-track { background: var(--bg); border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--col-color, var(--brand)); min-width: 3px; }
.bar-row .bar-value { font-size: 13px; font-weight: 600; color: var(--muted); text-align: right; }

.board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: start;
}

.stage-column {
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 4px solid var(--col-color, var(--accent));
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-card);
}
.stage-column summary {
    font-size: 14px;
    font-weight: 600;
    color: var(--col-color, var(--muted));
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    list-style: none;
}
.stage-column summary::-webkit-details-marker { display: none; }
.stage-column summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--col-color, var(--muted));
    border-bottom: 2px solid var(--col-color, var(--muted));
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}
.stage-column:not([open]) summary::after { transform: rotate(-45deg); }
.stage-column summary .stage-icon { display: inline-flex; }
.stage-column[open] summary { margin-bottom: 10px; }
.stage-column:not([open]) { padding-bottom: 12px; }

/* Reusable stage-colour modifiers - apply to .stage-column (board) or .badge-stage (detail page) alike */
.stage-new { --col-color: var(--stage-new); }
.stage-online { --col-color: var(--stage-online); }
.stage-inperson { --col-color: var(--stage-inperson); }
.stage-culture { --col-color: var(--stage-culture); }
.stage-performance { --col-color: var(--stage-performance); }
.stage-awaiting { --col-color: var(--stage-awaiting); }
.stage-selected { --col-color: var(--stage-selected); }
.stage-rejected { --col-color: var(--stage-rejected); }

.badge-stage {
    background: color-mix(in srgb, var(--col-color, var(--brand)) 16%, white);
    color: var(--col-color, var(--brand));
    font-size: 13px;
    padding: 5px 12px;
}

.candidate-card {
    display: block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--text);
}
.candidate-card:hover { border-color: var(--highlight); box-shadow: var(--shadow-card); }
.candidate-card .name { font-weight: 600; color: var(--brand); }
.candidate-card .position { font-size: 13px; color: var(--muted); }

/* Small status/role labels - always icon-or-text + colour, never colour alone */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-good { background: var(--stage-selected-bg); color: #075c07; }
.badge-bad { background: var(--stage-rejected-bg); color: var(--danger); }
.badge-pending { background: #fff4de; color: #8a5a00; }
.badge-admin { background: #fff1d1; color: #8a5a00; }
.badge-member { background: #e3eefb; color: var(--brand); }
.badge-neutral { background: var(--bg); color: var(--muted); }

.filters { margin-bottom: 16px; }
.filters select { display: inline-block; width: auto; margin-right: 10px; }
.filters-right { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 10px; }
.filters-right select, .filters-right input, .filters-right button { margin: 0; }

.detail-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}
.detail-card h3 { display: flex; align-items: center; gap: 8px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 20px; margin-bottom: 16px; }
.field-grid .field label { margin-bottom: 2px; }
.field-grid .field div { font-size: 15px; }

.action-form { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.action-form h3 { font-size: 15px; margin-bottom: 10px; }

.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--accent); font-size: 14px; color: var(--brand); }
td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }

.decision-actions { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.decision-actions .action-form { flex: 1 1 220px; min-width: 220px; border-top: none; padding-top: 0; margin-top: 0; }

.modal-dialog {
    border: none;
    border-radius: 10px;
    padding: 24px;
    box-shadow: var(--shadow-card);
    max-width: 400px;
    width: 90vw;
}
.modal-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.modal-dialog h3 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions button { width: auto; }

@media (max-width: 640px) {
    .container { padding: 14px; }

    .topbar { padding: 12px 16px; }
    .side-nav { width: 85vw; }

    .auth-card { margin: 32px auto; padding: 20px; max-width: 100%; }

    .board { grid-template-columns: 1fr; }
    .charts-row { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 100px 1fr 28px; gap: 6px; }
    .chart-card { padding: 14px; }
    .field-grid { grid-template-columns: 1fr; }
    .decision-actions { flex-direction: column; gap: 16px; }
    .decision-actions .action-form { min-width: 0; }

    .detail-card { padding: 16px; }

    button, .btn { width: 100%; text-align: center; }
    .filters select { width: 100%; margin-right: 0; margin-bottom: 10px; }
    .filters-right { flex-direction: column; align-items: stretch; }
    .filters-right input[type="search"] { width: 100% !important; }

    th, td { padding: 8px 6px; font-size: 13px; }
}
