/* =========================================================
   SAPP — Plain CSS stylesheet
   ========================================================= */

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:        #C8102E;
    --primary-dark:   #7c2529;
    --primary-light:  #e8edf5;
    --accent:         #2563eb;
    --success-bg:     #ecfdf5;
    --success-border: #6ee7b7;
    --success-text:   #065f46;
    --error-bg:       #fff1f2;
    --error-border:   #fda4af;
    --error-text:     #9f1239;
    --info-bg:        #eff6ff;
    --info-border:    #93c5fd;
    --info-text:      #1e40af;
    --warn-bg:        #fffbeb;
    --warn-border:    #fcd34d;
    --warn-text:      #92400e;
    --border:         #d1d9e6;
    --muted:          #6b7280;
    --text:           #111827;
    --bg:             #f3f6fb;
    --card:           #ffffff;
    --radius:         6px;
    --shadow:         0 1px 4px rgba(0,0,0,.08);
    --shadow-md:      0 4px 12px rgba(0,0,0,.10);
}

html { font-size: 16px; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem;   font-weight: 700; }

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

main.container { flex: 1; padding-top: 2rem; padding-bottom: 3.5rem; }

/* ----- Header ----- */
.site-header {
    background: var(--primary);
    color: #fff;
    padding: .8rem 0;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-logo {
    text-decoration: none;
    flex-shrink: 0;
    line-height: 0; /* collapse any inline gap around the h1 */
}
.site-logo:hover { text-decoration: none; opacity: .9; }

.site-subheader {
    color: rgba(255,255,255,.8);
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin: .2rem 0 0;
    line-height: 1;
}

.site-nameplate {
    display: block;
    width: 390px;
    height: 30px;
    background: url('/assets/images/sprite.png') no-repeat 0 0;
    overflow: hidden;
    text-indent: -9999px;
    white-space: nowrap;
    margin: 0;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-header nav a {
    color: rgba(255,255,255,.82);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: color .15s;
}
.site-header nav a:hover { color: #fff; text-decoration: none; }

.nav-cta {
    background: rgba(255,255,255,.18);
    padding: .3rem .85rem;
    border-radius: 999px;
}
.nav-cta:hover { background: rgba(255,255,255,.28) !important; }

.nav-logout { opacity: .7; }
.nav-logout:hover { opacity: 1 !important; }

.nav-dropdown { position: relative; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
    min-width: 170px;
    padding: .5rem 0 .3rem;
    z-index: 200;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block;
    padding: .5rem 1.1rem;
    color: #333 !important;
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
}
.nav-dropdown-menu a:hover { background: #f5f5f5; color: var(--primary) !important; }

/* ----- Footer ----- */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,.5);
    padding: .9rem 0;
    font-size: .8rem;
    text-align: center;
    margin-top: auto;
}

/* ----- Cards ----- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* ----- Alerts ----- */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .9rem;
    margin-bottom: 1.25rem;
}
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert-error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text);   }
.alert-info    { background: var(--info-bg);     border-color: var(--info-border);    color: var(--info-text);    }
.alert-warning { background: var(--warn-bg);     border-color: var(--warn-border);    color: var(--warn-text);    }

/* ----- Buttons ----- */
.btn {
    display: inline-block;
    padding: .55rem 1.3rem;
    border-radius: var(--radius);
    border: none;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background .15s, box-shadow .15s, transform .05s;
    line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #e5e9f0; color: var(--text); }
.btn-secondary:hover { background: #d5dbe8; }

.btn-sm { padding: .3rem .8rem; font-size: .8rem; }

/* ----- Forms ----- */
.form-page {
    max-width: 460px;
    margin: 2rem auto;
}
.form-page h1 { margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    appearance: auto;
}

/* Remove number input spinners */
.form-group input[type="number"]::-webkit-inner-spin-button,
.form-group input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.form-group input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.form-group textarea { min-height: 110px; resize: vertical; }

/* File inputs — hide native control, use a label + filename display instead */
.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.file-input-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
.file-chosen-name {
    font-size: .85rem;
    color: var(--muted);
}

.form-hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }

.form-footer { margin-top: 1.1rem; font-size: .9rem; color: var(--muted); }
.form-footer a { color: var(--accent); }

/* Radio buttons */
.radio-group { display: flex; gap: 1.75rem; margin-top: .25rem; }
.radio-group label {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-weight: normal;
    cursor: pointer;
    font-size: .95rem;
}
.radio-group input[type="radio"] { accent-color: var(--primary); width: 1rem; height: 1rem; }

.conditional-field { margin-top: .75rem; }

/* ----- Page header bar ----- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.4rem; }

/* ----- Tables ----- */
.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }

thead tr { background: var(--primary); color: #fff; }
th {
    padding: .7rem 1rem;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}
td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-light); }

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    min-width: 7rem;
    text-align: center;
}
.badge-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warn-bg);    color: var(--warn-text);    border: 1px solid var(--warn-border);    }
.badge-muted   { background: #f1f3f7;           color: var(--muted);        border: 1px solid var(--border);         }

/* ----- Detail list (label: value pairs) ----- */
.detail-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .5rem 1.5rem;
    font-size: .9rem;
}
.detail-grid dt { font-weight: 600; color: var(--muted); white-space: nowrap; }
.detail-grid dd { color: var(--text); }

/* ----- Message thread ----- */
.message-thread {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.msg-row {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border);
}
.msg-row:last-child { border-bottom: none; }

.from-applicant { background: #fff; }
.from-staff     { background: var(--primary-light); }

.msg-header {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    margin-bottom: .85rem;
}
.msg-sender {
    font-weight: 700;
    font-size: .875rem;
    color: var(--text);
}
.from-staff .msg-sender { color: var(--primary-dark); }
.msg-date {
    font-size: .78rem;
    color: var(--muted);
}
.msg-read-status {
    font-size: .72rem;
    font-style: italic;
}
.msg-read-yes { color: var(--success-text); }
.msg-read-no  { color: var(--muted); }

.msg-body {
    font-size: .9375rem;
    line-height: 1.75;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.empty-thread {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    padding: 2.5rem 0;
}

/* ----- Alphabet tracking index ----- */
.alpha-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    margin-bottom: 1.75rem;
    padding: .75rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.alpha-nav-link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 1.7rem;
    padding: .3rem .4rem;
    font-size: .875rem;
    font-weight: 700;
    border-radius: 4px;
    text-decoration: none;
    color: var(--primary);
    line-height: 1.2;
}
.alpha-nav-link:hover { background: var(--primary-light); }
.alpha-nav-active { background: var(--primary); color: #fff; }
.alpha-nav-active:hover { background: var(--primary-dark); }
.alpha-nav-count {
    font-size: .6rem;
    font-weight: 400;
    color: var(--muted);
    line-height: 1;
}
.alpha-nav-active .alpha-nav-count { color: rgba(255,255,255,.7); }
.alpha-nav-empty { color: var(--border); font-weight: 400; cursor: default; }
.alpha-nav-all {
    margin-left: .5rem;
    padding-left: .75rem;
    border-left: 1px solid var(--border);
    color: var(--text);
}

.alpha-section { margin-bottom: 2rem; }
.alpha-heading {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .6rem;
    padding-bottom: .35rem;
    border-bottom: 2px solid var(--border);
}

/* ----- Signature page ----- */
.sig-doc-header {
    text-align: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
}
.sig-doc-institution {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: .35rem;
}
.sig-doc-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.sig-fee-list {
    padding-left: 1.5rem;
    list-style: disc;
    line-height: 1.9;
}
.sig-waiver-section {
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.sig-waiver-disabled {
    opacity: .45;
    pointer-events: none;
}
.sig-checkbox-label {
    display: flex;
    width: 100%;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: .9rem;
    font-size: .925rem;
    line-height: 1.55;
    cursor: pointer;
}
.sig-checkbox-label input[type="checkbox"] {
    margin-top: .2rem;
    flex-shrink: 0;
    accent-color: var(--primary);
    width: 1rem;
    height: 1rem;
}
.sig-acknowledgments {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin: 1.5rem 0 1.25rem;
}
.sig-acknowledgments ul {
    padding-left: 1.5rem;
    list-style: disc;
    line-height: 1.9;
    font-size: .925rem;
}
.sig-line {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ----- Dashboard stat cards ----- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); }

/* ----- Pagination ----- */
.pagination {
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-wrap: wrap;
}

.pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 .5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: .85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.pg-btn:hover { background: var(--primary-light); border-color: var(--primary); text-decoration: none; }

.pg-current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
}
.pg-current:hover { background: var(--primary); }

.pg-disabled {
    color: var(--muted);
    cursor: default;
    pointer-events: none;
}

.pg-ellipsis {
    color: var(--muted);
    font-size: .85rem;
    padding: 0 .25rem;
    line-height: 2rem;
}

/* ----- Step tracker ----- */
.steps {
    display: flex;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    padding: 0 .5rem;
}

/* Connector line drawn before each step except the first */
.step + .step::before {
    content: '';
    position: absolute;
    top: 1.1rem;                          /* vertically centered on the icon */
    left: calc(-50% + 1.125rem);          /* starts at right edge of previous icon */
    right: calc(50% + 1.125rem);          /* ends at left edge of this icon */
    height: 2px;
    background: var(--border);
    z-index: 0;
}

/* Color the connector when the preceding step is complete */
.step-done + .step::before { background: var(--primary); }

.step-icon {
    position: relative;
    z-index: 1;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: .5rem;
    transition: background .2s, border-color .2s, color .2s;
}

.step-done  .step-icon { background: var(--primary); border-color: var(--primary); color: #fff; }
.step-active .step-icon { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.step-label {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    line-height: 1.3;
}
.step-done   .step-label { color: var(--text); }
.step-active .step-label { color: var(--primary); }

.step-desc {
    font-size: .78rem;
    color: var(--muted);
    margin-top: .2rem;
    line-height: 1.35;
}

/* ----- Admin landing cards ----- */
a.admin-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, transform .1s;
}
a.admin-card:hover {
    text-decoration: none;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ----- Utility ----- */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--muted); font-size: .875rem; }
.text-right { text-align: right; }
.flex-gap { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
