/* ============================================================
   Lungespesialisten — Main Stylesheet
   Compact, clinical. No framework dependencies.
   ============================================================ */

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

:root {
    --blue-dark:   #1b3a5c;
    --blue-mid:    #2563a8;
    --blue-light:  #dbeafe;
    --green:       #16a34a;
    --red:         #dc2626;
    --yellow:      #ca8a04;
    --gray-50:     #f8fafc;
    --gray-100:    #f1f5f9;
    --gray-200:    #e2e8f0;
    --gray-400:    #94a3b8;
    --gray-600:    #475569;
    --gray-700:    #334155;
    --gray-900:    #0f172a;
    --white:       #ffffff;
    --radius:      5px;
    --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.5;
}

a { color: var(--blue-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Dev bar (hidden in production via SHOW_DEV) ---- */
.dev-bar {
    background: #1a1a2e;
    color: #a0a0c0;
    font-size: .72rem;
    padding: .25rem .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.dev-bar-label {
    background: #e63946;
    color: #fff;
    font-weight: 700;
    font-size: .65rem;
    padding: .1rem .35rem;
    border-radius: 3px;
    letter-spacing: .5px;
    flex-shrink: 0;
}
.dev-bar-sep {
    color: #555580;
    margin-left: .25rem;
}
.dev-bar a {
    color: #90e0ef;
    text-decoration: none;
    padding: .1rem .35rem;
    border-radius: 3px;
    transition: background .1s;
}
.dev-bar a:hover {
    background: rgba(144,224,239,.15);
    text-decoration: none;
    color: #caf0f8;
}

/* ---- Site nav ---- */
.site-header {
    background: var(--blue-dark);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-bar {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    height: 48px;
    gap: 1rem;
}

.nav-brand {
    font-weight: 700;
    font-size: .9375rem;
    color: var(--white);
    letter-spacing: .2px;
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--white); }

.nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
}

.nav-links a {
    color: rgba(255,255,255,.82);
    font-size: .8125rem;
    padding: .3rem .6rem;
    border-radius: var(--radius);
    transition: background .12s;
}
.nav-links a:hover {
    background: rgba(255,255,255,.13);
    text-decoration: none;
    color: var(--white);
}
.nav-links a.nav-logout { color: rgba(255,200,200,.85); }

.nav-user {
    color: rgba(255,255,255,.6);
    font-size: .8125rem;
    padding: 0 .6rem 0 .25rem;
    border-right: 1px solid rgba(255,255,255,.18);
    margin-right: .25rem;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Role indicator badge in nav bar ---- */
.nav-role {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .3px;
    padding: .15rem .55rem;
    border-radius: var(--radius);
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-role--doctor  { color: #fff;    background: rgba(255,255,255,.18); }
.nav-role--patient { color: #bbf7d0; background: rgba(22,163,74,.35);   }

/* ---- Main layout ---- */
.main-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 3rem;
}

/* ---- Flash / alert ---- */
.flash:not(:empty) {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    padding: .6rem .9rem;
    margin-bottom: 1rem;
    font-size: .875rem;
    color: #78350f;
}
.flash.error:not(:empty) {
    background: #fee2e2;
    border-color: #f87171;
    color: #7f1d1d;
}

/* ---- Page heading ---- */
.page-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin: 0 0 1.1rem;
}

/* ---- Hero (home) ---- */
.hero {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.hero h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin: 0 0 .6rem;
}
.hero p {
    font-size: .9375rem;
    color: var(--gray-700);
    margin: 0;
    max-width: 640px;
    line-height: 1.65;
}

/* ---- Card grid (home) ---- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--blue-dark);
    margin: 0 0 .5rem;
}
.card-body {
    font-size: .8125rem;
    color: var(--gray-700);
    margin: 0 0 .9rem;
    line-height: 1.6;
}

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: .4rem .85rem;
    border-radius: var(--radius);
    font-size: .8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-align: center;
    transition: filter .12s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn-primary  { background: var(--blue-mid); color: var(--white); border-color: var(--blue-mid); }
.btn-secondary { background: var(--white); color: var(--gray-700); border-color: var(--gray-200); }
.btn-sm { padding: .2rem .5rem; font-size: .75rem; }

/* ---- Login form ---- */
.login-wrap {
    max-width: 400px;
    margin: 2rem auto;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
}
.login-wrap h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin: 0 0 1.25rem;
}
.form-group { margin-bottom: .85rem; }
.form-group label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: .25rem;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--gray-900);
    background: var(--white);
    font-family: var(--font);
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 2px rgba(37,99,168,.18);
}
.form-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #7f1d1d;
    border-radius: var(--radius);
    padding: .5rem .75rem;
    font-size: .8125rem;
    margin-bottom: .85rem;
}
.dev-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: .4rem .65rem;
    font-size: .75rem;
    color: #92400e;
    margin-bottom: .85rem;
}
.dev-logins {
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}
.dev-logins p {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--gray-400);
    margin: 0 0 .4rem;
}
.dev-btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

/* ---- Section panels ---- */
.section {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.section-header {
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.section-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--blue-dark);
    margin: 0;
}
.section-body { padding: .75rem 1rem; }
.section-body-flush { padding: 0; }

/* ---- Data table ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8125rem;
}
.data-table th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: 600;
    font-size: .75rem;
    text-align: left;
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.data-table td {
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-900);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--gray-50); }
.data-table a { color: var(--blue-mid); }

/* ---- Status badges ---- */
.badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    padding: .1rem .45rem;
    border-radius: 9999px;
    letter-spacing: .2px;
}
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-paused    { background: #fef9c3; color: #854d0e; }
.badge-completed { background: #dbeafe; color: #1d4ed8; }
.badge-cancelled { background: var(--gray-100); color: var(--gray-600); }
.badge-progress  { background: #e0f2fe; color: #0369a1; }
.badge-not-started { background: var(--gray-100); color: var(--gray-600); }
.badge-skipped   { background: #fce7f3; color: #9d174d; }

/* ---- Search bar ---- */
.search-row {
    display: flex;
    gap: .5rem;
    align-items: center;
}
.search-row input {
    flex: 1;
    padding: .38rem .6rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .8125rem;
    font-family: var(--font);
}
.search-row input:focus {
    outline: none;
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 2px rgba(37,99,168,.15);
}

/* ---- Workflow step list ---- */
.step-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.step-item {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--gray-100);
}
.step-item:last-child { border-bottom: none; }
.step-num {
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--blue-light);
    color: var(--blue-mid);
    font-size: .6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: .1rem;
}
.step-num.done  { background: #dcfce7; color: var(--green); }
.step-num.skip  { background: var(--gray-100); color: var(--gray-400); }
.step-info { flex: 1; min-width: 0; }
.step-title { font-weight: 500; font-size: .8125rem; }
.step-note  { font-size: .75rem; color: var(--gray-600); margin-top: .1rem; }

/* ---- Step detail (forlop page) ---- */
.step-item--detail {
    align-items: flex-start;
    padding: .7rem .75rem;
    gap: .75rem;
}
.step-item--detail .step-info {
    flex: 1;
    min-width: 0;
}
.step-item--detail[data-status="in_progress"] {
    background: #f0f9ff;
    border-left: 3px solid var(--blue-mid);
}
.step-item--detail[data-status="completed"] {
    opacity: .75;
}
.step-desc {
    font-size: .75rem;
    color: var(--gray-700);
    margin-top: .2rem;
    line-height: 1.55;
}
.doc-note {
    color: var(--blue-dark);
    font-style: italic;
}
.pat-note {
    color: var(--green);
}
/* Badge + buttons sit below the step text, left-aligned, in a row */
.step-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin-top: .5rem;
}
.step-marked-by {
    font-size: .7rem;
    color: var(--gray-400);
    white-space: nowrap;
}

/* ---- Progress bar ---- */
.progress-track {
    height: 8px;
    background: var(--gray-100);
    border-radius: 9999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--blue-mid);
    border-radius: 9999px;
    transition: width .4s ease;
    min-width: 0;
}

/* ---- Forlop header ---- */
.forlop-back { margin-bottom: .75rem; }
.back-link {
    font-size: .8125rem;
    color: var(--gray-600);
}
.back-link:hover { color: var(--blue-mid); }
.forlop-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.forlop-header-main { flex: 1; }
.forlop-meta {
    font-size: .8125rem;
    color: var(--gray-600);
    margin: 0;
}
.forlop-count {
    font-size: .8125rem;
    color: var(--gray-600);
}

/* ---- Previous answer display ---- */
.prev-answer {
    font-size: .75rem;
    color: var(--gray-600);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .3rem .5rem;
    margin-top: .3rem;
    line-height: 1.5;
}
.answer-textarea {
    width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .8125rem;
    resize: vertical;
}
.answer-textarea:focus {
    outline: none;
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 2px rgba(37,99,168,.18);
}

/* ---- Empty state ---- */
.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--gray-400);
    font-size: .8125rem;
}

/* ---- Toolbar (section header actions) ---- */
.toolbar { display: flex; gap: .35rem; align-items: center; }

/* ---- 404 ---- */
.not-found {
    text-align: center;
    padding: 4rem 1rem;
}
.not-found .big-num {
    font-size: 5rem;
    font-weight: 900;
    color: var(--gray-200);
    line-height: 1;
    margin-bottom: .25rem;
}
.not-found h2 {
    font-size: 1.125rem;
    color: var(--blue-dark);
    margin: 0 0 .75rem;
}
.not-found p {
    font-size: .875rem;
    color: var(--gray-600);
    margin: 0 0 1.25rem;
}

/* ---- Patient profile grid ---- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .5rem .75rem;
}
.profile-field { display: flex; flex-direction: column; }
.profile-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-400);
    font-weight: 600;
}
.profile-value {
    font-size: .875rem;
    color: var(--gray-900);
    font-weight: 500;
}

/* ---- Template picker ---- */
.template-group { margin-bottom: 1.5rem; }
.template-group-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--gray-400);
    margin: 0 0 .6rem;
    padding-bottom: .3rem;
    border-bottom: 1px solid var(--gray-200);
}
.template-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: .75rem;
}
.template-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    box-shadow: var(--shadow);
}
.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin-bottom: .4rem;
}
.template-card-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--blue-dark);
}
.template-step-count {
    font-size: .75rem;
    color: var(--gray-400);
    white-space: nowrap;
}
.template-card-desc {
    font-size: .78rem;
    color: var(--gray-700);
    margin: 0 0 .5rem;
    line-height: 1.55;
}
.template-steps-preview {
    margin-bottom: .5rem;
    font-size: .78rem;
}
.template-steps-preview summary {
    cursor: pointer;
    color: var(--blue-mid);
    font-size: .78rem;
    padding: .15rem 0;
}
.template-step-list {
    margin: .4rem 0 0 0;
    padding-left: 0;
    list-style: none;
}
.template-step-list li {
    padding: .2rem 0;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: .4rem;
    border-bottom: 1px solid var(--gray-100);
}
.template-step-list li:last-child { border-bottom: none; }
.step-num-sm {
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--blue-light);
    color: var(--blue-mid);
    font-size: .625rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---- Action type tag ---- */
.type-tag {
    font-size: .68rem;
    color: var(--gray-400);
    font-style: normal;
    background: var(--gray-100);
    padding: .05rem .35rem;
    border-radius: 9999px;
    white-space: nowrap;
}

/* ---- Doctor workflow step controls ---- */
.step-item--dr {
    align-items: flex-start;
    padding: .7rem .75rem;
    gap: .75rem;
}
.step-item--dr[data-status="in_progress"] {
    background: #f0f9ff;
    border-left: 3px solid var(--blue-mid);
}
.step-item--dr[data-status="completed"] { opacity: .8; }
.step-item--dr[data-status="skipped"]   { opacity: .55; }

.step-dr-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .4rem;
    flex-shrink: 0;
    min-width: 160px;
}
.status-select {
    padding: .25rem .4rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .75rem;
    font-family: var(--font);
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    width: 100%;
}
.status-select:focus {
    outline: none;
    border-color: var(--blue-mid);
}
.inline-form {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}
.step-notes-detail { width: 100%; }
.step-notes-detail summary {
    cursor: pointer;
    font-size: .72rem;
    color: var(--blue-mid);
    padding: .1rem 0;
}
.notes-form { margin-top: .35rem; display: flex; flex-direction: column; gap: .3rem; }
.notes-textarea {
    width: 100%;
    padding: .3rem .5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .78rem;
    resize: vertical;
    min-height: 52px;
}
.notes-textarea:focus {
    outline: none;
    border-color: var(--blue-mid);
}
.toolbar-hint {
    font-size: .72rem;
    color: var(--gray-400);
    font-style: italic;
}

/* ---- Forlop header actions ---- */
.forlop-header-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ---- Step number cell in table ---- */
.step-num-cell {
    width: 32px;
    text-align: center;
    font-weight: 700;
    color: var(--blue-mid);
    font-size: .8125rem;
}

/* ---- Add step form ---- */
.add-step-form { }
.add-step-row {
    display: flex;
    gap: .5rem;
    align-items: center;
}
.action-select {
    flex: 1;
    padding: .38rem .5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .8125rem;
    font-family: var(--font);
    color: var(--gray-900);
    background: var(--white);
}
.action-select:focus {
    outline: none;
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 2px rgba(37,99,168,.15);
}

/* ---- Answer list (doctor view) ---- */
.answer-list { margin: 0; }
.answer-list dt {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-top: .6rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.answer-list dt:first-child { margin-top: 0; }
.answer-list dd {
    margin: .2rem 0 0 0;
    font-size: .8125rem;
    color: var(--gray-900);
    background: var(--gray-50);
    border-left: 2px solid var(--blue-light);
    padding: .3rem .6rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    line-height: 1.5;
}
.answer-date {
    font-size: .7rem;
    color: var(--gray-400);
    font-weight: 400;
}
.answer-date-ok   { color: var(--green); }
.answer-date-warn { color: var(--yellow); }
.answer-date-old  { color: var(--red); font-weight: 600; }

/* ---- Video cards ---- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .75rem;
}
.video-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .75rem;
    box-shadow: var(--shadow);
}
.video-card-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--blue-dark);
    margin-bottom: .25rem;
}
.video-meta {
    font-size: .72rem;
    color: var(--gray-400);
    margin: 0 0 .5rem;
}
.video-notes {
    font-size: .78rem;
    color: var(--gray-700);
    margin: .4rem 0 0;
    line-height: 1.5;
}
.video-embed-wrap {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    background: #000;
    margin: .4rem 0;
}
.video-embed-wrap iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: 0;
}
.video-player {
    width: 100%;
    border-radius: var(--radius);
    margin: .4rem 0;
}

/* ---- Form layout helpers ---- */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
@media (max-width: 600px) { .form-row-2 { grid-template-columns: 1fr; } }

.field-hint {
    display: block;
    font-size: .72rem;
    color: var(--gray-400);
    margin-top: .2rem;
}
.required { color: var(--red); }

/* ---- Date status badges (step scheduling) ---- */
.date-badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    padding: .1rem .45rem;
    border-radius: 3px;
    margin: .15rem 0 .25rem;
    letter-spacing: .01em;
}
.date-upcoming {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}
.date-ok {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}
.date-warn {
    background: #fefce8;
    color: #ca8a04;
    border: 1px solid #fde68a;
}
.date-overdue {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* ---- Patient step button group (non-sequential) ---- */
.step-btn-group {
    display: contents; /* children participate directly in .step-foot row */
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: .75rem;
    padding: .2rem .55rem;
}
.btn-ghost:hover { background: var(--gray-100); }

/* ---- Date picker in doctor step controls ---- */
.form-control-sm {
    width: 100%;
    padding: .25rem .4rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .78rem;
    color: var(--gray-900);
    background: var(--white);
    margin-top: .1rem;
}

/* ---- Patient portal two-column layout (50/50) ---- */
.patient-portal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) {
    .patient-portal-grid { grid-template-columns: 1fr; }
    .portal-inbox { order: -1; } /* inbox above treatment on mobile */
}

/* ---- Inbox panel (right column) ---- */
.inbox-panel {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.inbox-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .85rem;
    background: var(--blue-dark);
    color: var(--white);
}
.inbox-panel-title {
    font-size: .85rem;
    font-weight: 600;
    margin: 0;
    color: var(--white);
}
.inbox-unread-badge {
    background: #ef4444;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 10px;
    white-space: nowrap;
}
.inbox-scroll {
    max-height: 480px;
    overflow-y: auto;
}
.inbox-empty {
    padding: 1.2rem .85rem;
    color: var(--gray-400);
    font-size: .82rem;
    text-align: center;
}
.inbox-item {
    padding: .75rem .85rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: .82rem;
}
.inbox-item:last-child { border-bottom: none; }
.inbox-item--unread {
    background: #f0f9ff;
    border-left: 3px solid var(--blue-mid);
    padding-left: calc(.85rem - 3px);
}
.inbox-meta {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .25rem;
}
.inbox-dot {
    width: 7px;
    height: 7px;
    background: var(--blue-mid);
    border-radius: 50%;
    flex-shrink: 0;
}
.inbox-from {
    font-weight: 600;
    color: var(--blue-dark);
}
.inbox-date {
    color: var(--gray-400);
    font-size: .72rem;
    margin-left: auto;
}
.inbox-subject {
    font-weight: 600;
    margin-bottom: .2rem;
    color: var(--gray-900);
}
.inbox-body {
    color: var(--gray-700);
    line-height: 1.55;
    white-space: pre-wrap;
}
.inbox-see-all {
    display: block;
    text-align: center;
    padding: .55rem;
    font-size: .78rem;
    color: var(--blue-mid);
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}
.inbox-see-all:hover { background: var(--gray-100); text-decoration: none; }

/* Full messages page */
.messages-full-list {
    max-width: 760px;
}
.messages-full-list .inbox-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: .75rem;
    padding: .9rem 1rem;
}
.messages-full-list .inbox-item--unread {
    border-left: 4px solid var(--blue-mid);
    padding-left: calc(1rem - 1px);
}
.messages-full-list .inbox-body {
    font-size: .875rem;
    margin-top: .35rem;
}

/* ---- Doctor sent messages list ---- */
.sent-message {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: .6rem;
    overflow: hidden;
}
.sent-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .45rem .75rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: .82rem;
    gap: .5rem;
    flex-wrap: wrap;
}
.sent-message-body {
    padding: .55rem .75rem;
    font-size: .82rem;
    color: var(--gray-700);
    line-height: 1.55;
    white-space: pre-wrap;
}

/* ---- Message compose form ---- */
.message-compose .form-control {
    width: 100%;
}

/* ---- Sequential / freeflow badges ---- */
.badge-seq {
    background: #ede9fe;
    color: #6d28d9;
    border: 1px solid #c4b5fd;
    font-size: .7rem;
}
.badge-freeflow {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
    font-size: .7rem;
}

/* ---- Locked step (sequential workflows) ---- */
.step-locked {
    font-size: .72rem;
    color: var(--gray-400);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .2rem .5rem;
    cursor: not-allowed;
}
.step-item--detail[data-status="not_started"].is-locked {
    opacity: .6;
}

/* ---- Template library page ---- */
.section-subtitle {
    font-size: .78rem;
    color: var(--gray-400);
    align-self: center;
}
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    cursor: pointer;
    font-size: .88rem;
}
.checkbox-label input[type="checkbox"] { margin-top: .2rem; flex-shrink: 0; }

/* ---- Two-column doctor patient page ---- */
.dr-patient-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 1000px) {
    .dr-patient-grid { grid-template-columns: 1fr; }
}
.dr-patient-main  { min-width: 0; }
.dr-patient-aside { min-width: 0; }

.all-answers-scroll { max-height: 420px; overflow-y: auto; }
.timeline-scroll    { max-height: 560px; overflow-y: auto; }

/* All-answers list */
.all-answer-item {
    border-bottom: 1px solid var(--gray-100);
    padding: .5rem 0;
}
.all-answer-item:last-child { border-bottom: none; }
.all-answer-meta { margin-bottom: .15rem; }
.all-answer-dt   { font-size: .75rem; color: var(--gray-400); font-variant-numeric: tabular-nums; }
.all-answer-q    { font-size: .8rem; color: var(--gray-600); margin-bottom: .2rem; }
.all-answer-a    { font-size: .875rem; color: var(--gray-900); }

/* Timeline */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}
.timeline::before {
    content: '';
    position: absolute;
    left: .9rem;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.tl-item {
    display: flex;
    gap: .75rem;
    padding: .45rem 0 .45rem .15rem;
    position: relative;
}
.tl-dot {
    flex-shrink: 0;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    z-index: 1;
}
.tl-body   { flex: 1; min-width: 0; }
.tl-head   { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.tl-title  { font-size: .82rem; font-weight: 600; color: var(--gray-900); }
.tl-actor  { font-size: .72rem; color: var(--gray-400); }
.tl-time   { font-size: .72rem; color: var(--gray-400); margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-detail { font-size: .78rem; color: var(--gray-600); margin: .15rem 0 0; line-height: 1.4; }

/* Timeline event type colours */
.tl-workflow   .tl-dot { background:#dbeafe; border-color:#2563a8; color:#2563a8; }
.tl-step-start .tl-dot { background:#fef3c7; border-color:#ca8a04; color:#ca8a04; }
.tl-step-done  .tl-dot { background:#dcfce7; border-color:#16a34a; color:#16a34a; }
.tl-step-skip  .tl-dot { background:#f1f5f9; border-color:#94a3b8; color:#94a3b8; }
.tl-answer     .tl-dot { background:#ede9fe; border-color:#7c3aed; color:#7c3aed; }
.tl-message    .tl-dot { background:#fce7f3; border-color:#db2777; color:#db2777; }
.tl-video      .tl-dot { background:#fff7ed; border-color:#ea580c; color:#ea580c; }
.tl-event      .tl-dot { background:#f0fdf4; border-color:#16a34a; color:#16a34a; }
.tl-callback   .tl-dot { background:#eff6ff; border-color:#2563eb; color:#2563eb; }

/* ---- Notification disabled banner ---- */
.notif-disabled-banner {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-left: 4px solid #ca8a04;
    color: #713f12;
    padding: .6rem .9rem;
    border-radius: var(--radius);
    font-size: .85rem;
    margin-bottom: 1rem;
}
.notif-disabled-banner a { color: #92400e; font-weight:600; }
.notif-prefs-section { margin-top: 1.5rem; }

/* ---- Message channel tabs (web / WhatsApp) ---- */
.msg-channel-tabs { display:flex; gap:.25rem; border-bottom:2px solid var(--gray-200); margin-bottom:.25rem; }
.msg-tab {
    background: none; border: none; padding: .35rem .75rem;
    font-size: .82rem; cursor: pointer; color: var(--gray-600);
    border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.msg-tab--active { color: var(--blue-mid); border-bottom-color: var(--blue-mid); font-weight:600; }

/* ---- WhatsApp send button ---- */
.btn-whatsapp {
    background: #25d366;
    color: #fff;
    border: none;
    padding: .35rem .8rem;
    border-radius: var(--radius);
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-whatsapp:hover { background: #1da851; text-decoration:none; color:#fff; }

/* ---- Message direction indicators (inbound vs outbound) ---- */
.inbox-item--inbound {
    border-left-color: #7c3aed;   /* purple for patient replies */
    background: #faf5ff;
}
.inbox-channel-badge {
    font-size: .68rem;
    padding: .1rem .35rem;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: .2px;
}
.inbox-channel-badge--web      { background:#dbeafe; color:#1e40af; }
.inbox-channel-badge--whatsapp { background:#dcfce7; color:#166534; }
.inbox-channel-badge--sms      { background:#fef3c7; color:#92400e; }
.inbox-channel-badge--call     { background:#f3e8ff; color:#6b21a8; }

/* ---- Master nav link ---- */
.nav-master {
    font-weight: 700;
    color: #fbbf24 !important;  /* amber — visually distinct from regular nav */
}

/* ---- Master badge (in doctor activity table) ---- */
.badge-master {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ---- Master stats grid ---- */
.master-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
}
.stat-card.stat-ok   { border-color: #86efac; background: #f0fdf4; }
.stat-card.stat-warn { border-color: #fca5a5; background: #fef2f2; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: .7rem; color: var(--gray-500); text-align: center; }

.master-tools { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- Two-column master catalogue pages ---- */
.master-catalogue-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) {
    .master-catalogue-grid { grid-template-columns: 1fr; }
}

/* ---- Footer ---- */
.site-footer {
    background: var(--blue-dark);
    color: rgba(255,255,255,.5);
    text-align: center;
    padding: .7rem 1rem;
    font-size: .75rem;
}
.site-footer a { color: rgba(255,255,255,.65); }
.site-footer a:hover { color: var(--white); text-decoration: none; }
