/* ============================================================
   i-COACH — profile app stylesheet
   Palette: warm cream paper, terracotta accent, deep navy ink
   Type: Fraunces (display) / Inter (body)
   ============================================================ */

:root{
  --ink:#241E1A;
  --ink-soft:#6B6058;
  --paper:#FBF6EF;
  --paper-alt:#F3E4D7;
  --paper-raised:#FFFFFF;
  --navy:#171B21;
  --terracotta:#C97B4A;
  --terracotta-dark:#AD6238;
  --terracotta-pale:#F0C9A8;
  --line:#E8DCCB;
  --shadow: 0 14px 34px rgba(36,30,26,0.09);
  --danger:#B3261E;
  --danger-pale:#F8D9D5;

  --display: "Fraunces", "Iowan Old Style", serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

*{ box-sizing:border-box; }

body {
    font-family: var(--body);
    background: var(--paper);
    color: var(--ink);
    margin: 0;
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

.card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 2.25rem 2.5rem;
    width: 100%;
    max-width: 420px;
}

.card-wide {
    max-width: 640px;
}

/* Wide, top-aligned layout for content-heavy pages (profile, agent panel) - as opposed to
   .card, which is a narrow, vertically-centered surface for single-task forms (login, register,
   password flows). body.dashboard-body overrides the default centering for these pages. */
body.dashboard-body {
    align-items: flex-start;
    padding: 2.5rem 1.5rem;
}

.dashboard {
    width: 100%;
    max-width: 1100px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-header .brand {
    margin-bottom: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dropdown-caret {
    font-size: 0.7em;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
    padding: 0.5rem;
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.dropdown-menu[hidden] {
    display: none;
}

.dropdown-menu a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: var(--ink);
    font-family: var(--body);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: normal;
}

.dropdown-menu a:hover {
    background: var(--paper-alt);
}

.dropdown-divider {
    height: 1px;
    margin: 4px 2px;
    background: var(--line);
}

.dropdown-menu a.dropdown-danger {
    color: var(--danger);
}

.dropdown-menu a.dropdown-danger:hover {
    background: var(--danger-pale);
}

.panel {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 2rem 2.25rem;
}

.profile-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1.5rem 2.5rem;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
}

.profile-summary .btn {
    margin-top: 0;
    margin-left: auto;
}

.brand {
    display: block;
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.3rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-bottom: 1.25rem;
}

h1 {
    font-family: var(--display);
    font-weight: 600;
    margin-top: 0;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
}

label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
    font-family: var(--body);
    font-size: 0.98rem;
    color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--terracotta);
    outline-offset: 1px;
    border-color: var(--terracotta);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.4rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.35rem;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--ink-soft);
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--paper-alt);
    color: var(--ink);
    transform: translateY(-50%);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--terracotta);
    outline-offset: 1px;
}

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 1.5rem;
    padding: 0.7rem 1.4rem;
    background: var(--ink);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 100px;
    white-space: nowrap;
    font-family: var(--body);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform .18s ease, background .18s ease, color .18s ease;
}

button:hover, .btn:hover {
    background: var(--navy);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border-color: var(--ink);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--ink);
    color: #fff;
}

.error {
    background: #F7E3DC;
    color: var(--terracotta-dark);
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.success {
    background: var(--paper-alt);
    color: #5B7A5A;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.muted {
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.profile-field {
    margin-top: 1rem;
}

.profile-field .label {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
}

.profile-field .value {
    font-family: var(--display);
    font-size: 1.1rem;
    margin-top: 0.25rem;
    color: var(--ink);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.actions .btn,
.actions button,
.field-actions .btn,
.field-actions button {
    margin-top: 0;
}

form {
    margin: 0;
}

.top-links {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
}

.top-links a {
    color: var(--ink);
    font-weight: 600;
    border-bottom: 2px solid var(--terracotta);
    padding-bottom: 1px;
    text-decoration: none;
}

.top-links a:hover {
    color: var(--terracotta-dark);
}

/* ---------- questionnaire ---------- */
.module-heading {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--terracotta-dark);
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    scroll-margin-top: 4.5rem;
}

.module-heading:first-of-type {
    margin-top: 1.5rem;
    padding-top: 0;
    border-top: none;
}

.module-details > .module-heading {
    cursor: pointer;
    list-style: none;
}

.module-details > .module-heading::-webkit-details-marker {
    display: none;
}

.module-details > .module-heading::before {
    content: "\25B8";
    display: inline-block;
    width: 1em;
    color: var(--ink-soft);
}

.module-details[open] > .module-heading::before {
    content: "\25BE";
}

.profile-field.compact {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--line);
}

.profile-field.compact .label {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    flex: 0 0 40%;
}

.profile-field.compact .value {
    font-family: var(--display);
    font-size: 0.95rem;
    color: var(--ink);
    text-align: right;
}

.q-progress {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem 0;
    margin-bottom: 0.5rem;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.q-progress a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    border: 1px solid var(--line);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
    background: var(--paper-raised);
}

.q-progress a:hover {
    border-color: var(--terracotta);
    color: var(--terracotta-dark);
}

.q-progress a.active {
    background: var(--terracotta);
    border-color: var(--terracotta);
    color: #fff;
}

.hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.82rem;
    color: var(--ink-soft);
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
}

.sub-label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--ink);
}

.choice-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.choice-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
    font-size: 0.92rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}

.choice-option input {
    margin-top: 0.2rem;
    accent-color: var(--terracotta);
    flex-shrink: 0;
}

.choice-option:has(input:checked) {
    border-color: var(--terracotta);
    background: var(--paper-alt);
}

.choice-scale {
    flex-direction: row;
    flex-wrap: wrap;
}

.choice-scale .choice-option {
    flex: 1 0 auto;
    justify-content: center;
    padding: 0.5rem 0;
    min-width: 2.4rem;
}

.choice-scale .choice-option span {
    font-weight: 600;
}

.follow-up {
    margin-top: 0.75rem;
    padding-left: 1rem;
    border-left: 2px solid var(--line);
}

/* ---------- agent panel ---------- */
.agent-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.agent-nav a {
    color: var(--ink);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 1px;
}

.agent-nav a:hover {
    border-bottom-color: var(--terracotta);
}

.agent-nav .spacer {
    flex: 1;
}

.agent-nav button {
    margin-top: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.92rem;
}

.table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--line);
}

.table td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table select {
    width: auto;
    padding: 0.4rem 0.5rem;
}

.table a {
    color: var(--terracotta-dark);
    font-weight: 600;
    text-decoration: none;
}

.table a:hover {
    text-decoration: underline;
}

.btn-link {
    display: inline;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--terracotta-dark);
    font-family: var(--body);
    font-weight: 600;
    font-size: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: none;
}

.btn-link:hover {
    background: none;
    color: var(--terracotta-dark);
    text-decoration: underline;
    transform: none;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-submitted {
    background: var(--paper-alt);
    color: #5B7A5A;
}

.badge-pending {
    background: var(--paper-alt);
    color: var(--terracotta-dark);
}

.badge-expired {
    background: #F7E3DC;
    color: var(--terracotta-dark);
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.phase-table th,
.phase-table td {
    text-align: center;
}

.phase-table input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--terracotta);
    cursor: pointer;
}

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.profile-header .brand {
    margin-bottom: 0;
}

.link-button {
    display: inline;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-bottom: 2px solid var(--terracotta);
    padding-bottom: 1px;
    color: var(--ink);
    font-family: var(--body);
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    cursor: pointer;
}

.link-button:hover {
    background: none;
    color: var(--terracotta-dark);
    transform: none;
}

.field-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.edit-dialog {
    border: none;
    border-radius: 14px;
    padding: 1.5rem;
    max-width: 360px;
    width: calc(100% - 2rem);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.edit-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.edit-dialog h2 {
    margin-top: 0;
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--ink);
}

.upload-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.upload-control button {
    margin-top: 0;
}

/* Visually hides an element while keeping it focusable/clickable for assistive tech -
   used to hide the native file input, since its browser-supplied "Browse"/filename text
   can't be translated or width-constrained, and was what caused the upload row to reflow
   on file selection. A styled <label for="..."> triggers it instead. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Overrides the generic form `label` rule above (uppercase, block, margin-top) - this label
   is styled as a plain inline link/button, not a field caption. */
.upload-control label.btn-link {
    display: inline;
    margin: 0;
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}

.upload-file-name {
    display: inline-block;
    /* Fixed width (report-upload-pending.js caps the displayed name at 20 chars) so the box
       doesn't grow when a file is picked - with table-layout: auto, a growing box here would
       resize the whole column and shift the upload button in every row, not just this one. */
    width: 9rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.top-links.left {
    text-align: left;
    margin-top: 0;
}

.row-links {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.role-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.role-form button {
    margin-top: 0;
}

.agent-search {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    max-width: 480px;
}

.agent-search input {
    margin: 0;
}

.agent-search button {
    margin-top: 0;
    flex-shrink: 0;
}

.agent-search-checkbox {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    font-size: 0.9rem;
}

.agent-search-checkbox input {
    width: auto;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.pagination a {
    color: var(--ink);
    font-weight: 600;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.editor-grid textarea#markdownEditor {
    height: 60vh;
    max-height: 60vh;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.markdown-preview {
    height: 60vh;
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper-raised);
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    font-family: var(--display);
    margin-top: 1.2em;
}

.markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.markdown-preview th,
.markdown-preview td {
    border: 1px solid var(--line);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
    .editor-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    body {
        align-items: flex-start;
    }

    body.dashboard-body {
        padding: 1.25rem 1rem;
    }

    .panel {
        padding: 1.5rem 1.25rem;
        border-radius: 16px;
    }

    .dashboard-header {
        flex-wrap: wrap;
        row-gap: 0.75rem;
    }

    .header-actions {
        gap: 1rem;
    }

    .card {
        max-width: 100%;
        min-height: 100vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 1.5rem 1.25rem;
    }

    .card-wide {
        max-width: 100%;
    }

    .actions,
    .field-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .actions .btn,
    .actions button,
    .field-actions .btn,
    .field-actions button {
        width: 100%;
    }

    .agent-nav {
        gap: 0.6rem 1rem;
    }

    .choice-scale .choice-option {
        min-width: 2rem;
    }
}
