/* Casus — shared design system for the auth pages and the personal cabinet.
   Light UI matching the consultation simulator (teal / indigo). */

:root {
    --bg: #eef2f7;
    --bg2: #e6ecf5;
    --panel: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #0d9488;
    --primary-d: #0f766e;
    --indigo: #4f46e5;
    --cyan: #0891b2;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --radius: 18px;
    --shadow: 0 24px 60px -24px rgba(16, 24, 40, .45);
    --shadow-sm: 0 2px 10px -4px rgba(16, 24, 40, .2);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a {
    color: var(--primary-d);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ─── Full-screen auth stage with a living gradient ───────────────────────── */
.auth-stage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(125deg, #0d9488, #0891b2 40%, #4f46e5 85%);
    background-size: 300% 300%;
    animation: bgShift 18s ease infinite;
}

@keyframes bgShift {
    0% { background-position: 0 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* Soft floating blobs behind the card. */
.auth-stage::before,
.auth-stage::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: .35;
    pointer-events: none;
}

.auth-stage::before {
    width: 420px;
    height: 420px;
    background: #5eead4;
    top: -120px;
    left: -80px;
    animation: float1 16s ease-in-out infinite;
}

.auth-stage::after {
    width: 380px;
    height: 380px;
    background: #a5b4fc;
    bottom: -140px;
    right: -60px;
    animation: float2 20s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(40px, 30px); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, -40px); }
}

/* ─── The card ────────────────────────────────────────────────────────────── */
.auth-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 430px;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px 30px 26px;
    animation: cardIn .55s cubic-bezier(.2, .8, .2, 1) both;
}

.auth-card.wide {
    max-width: 680px;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(22px) scale(.97); }
    to { opacity: 1; transform: none; }
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary-d);
    margin-bottom: 4px;
}

.auth-brand .logo {
    font-size: 1.7rem;
    animation: beat 2.4s ease-in-out infinite;
}

@keyframes beat {
    0%, 100% { transform: scale(1); }
    12% { transform: scale(1.22); }
    24% { transform: scale(1); }
}

.auth-title {
    margin: 10px 0 2px;
    font-size: 1.5rem;
    text-align: center;
    animation: fadeUp .5s .05s ease both;
}

.auth-sub {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    margin: 0 0 18px;
    animation: fadeUp .5s .12s ease both;
}

/* A one-shot typing reveal for the welcome line. */
.auth-welcome {
    text-align: center;
    color: var(--primary-d);
    font-weight: 600;
    font-size: .95rem;
    margin: 0 auto 16px;
    max-width: 30ch;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--primary);
    width: 0;
    animation: typing 1.6s steps(28, end) .2s forwards, caret .8s step-end infinite;
}

@keyframes typing {
    to { width: 26ch; }
}

@keyframes caret {
    50% { border-color: transparent; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-row {
    margin-bottom: 12px;
    animation: fadeUp .45s ease both;
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 520px) {
    .grid2 { grid-template-columns: 1fr; }
}

label, .lbl {
    display: block;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 0 0 5px;
    font-weight: 600;
}

.field {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: .95rem;
    outline: none;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
    font-family: inherit;
}

.field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .15);
}

select.field {
    appearance: none;
}

.helptext, .helptext ul {
    color: var(--muted);
    font-size: .72rem;
    margin: 4px 0 0;
    padding-left: 16px;
}

.errorlist {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    color: var(--red);
    font-size: .8rem;
}

.errorlist li {
    margin-top: 2px;
}

.alert {
    border-radius: 12px;
    padding: 10px 14px;
    font-size: .88rem;
    margin-bottom: 14px;
}

.alert.err {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert.ok {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.alert.info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    border: 1.5px solid transparent;
    border-radius: 12px;
    padding: 11px 18px;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: var(--ink);
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease, opacity .14s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: linear-gradient(120deg, var(--primary), var(--indigo));
    color: #fff;
    border: none;
}

.btn.block {
    width: 100%;
    padding: 13px 18px;
    font-size: 1rem;
    margin-top: 6px;
}

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

.btn.o-grey {
    background: #fff;
    color: var(--muted);
    border-color: var(--line);
}

.auth-foot {
    text-align: center;
    margin-top: 16px;
    font-size: .9rem;
    color: var(--muted);
}

.auth-foot .sep {
    margin: 0 8px;
    opacity: .5;
}

.link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2px 2px 14px;
    font-size: .84rem;
}

/* ─── App shell (cabinet pages) ───────────────────────────────────────────── */
.app-body {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--bg), var(--bg2));
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    color: #fff;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(110deg, #0d9488, #0ea5e9 45%, #4f46e5);
    background-size: 220% 100%;
    animation: shimmer 14s ease infinite;
    box-shadow: 0 8px 24px -12px rgba(13, 148, 136, .7);
}

@keyframes shimmer {
    0% { background-position: 0 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.08rem;
    color: #fff;
}

.topbar .brand:hover { text-decoration: none; }

.topbar .brand .logo {
    font-size: 1.35rem;
    animation: beat 2.4s ease-in-out infinite;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.topnav a {
    color: #fff;
    font-size: .88rem;
    padding: 7px 12px;
    border-radius: 10px;
    opacity: .9;
    transition: background .14s ease, opacity .14s ease;
}

.topnav a:hover {
    background: rgba(255, 255, 255, .18);
    opacity: 1;
    text-decoration: none;
}

.topnav a.active {
    background: rgba(255, 255, 255, .22);
    opacity: 1;
}

.topnav .logout {
    background: rgba(255, 255, 255, .16);
    border: none;
    color: #fff;
    font: inherit;
    font-size: .88rem;
    padding: 7px 12px;
    border-radius: 10px;
    cursor: pointer;
}

.topnav .logout:hover {
    background: rgba(255, 255, 255, .28);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: .86rem;
}

.avatar-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, .7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .22);
    font-size: .8rem;
    font-weight: 700;
}

.wrap {
    max-width: 940px;
    margin: 26px auto;
    padding: 0 18px;
}

.page-head {
    margin-bottom: 18px;
    animation: fadeUp .5s ease both;
}

.page-head h1 {
    margin: 0;
    font-size: 1.5rem;
}

.page-head .muted {
    color: var(--muted);
    font-size: .9rem;
    margin-top: 3px;
}

/* Personal progress summary above the visit list — deliberately plain numbers
   (no badges/levels/emoji), the same register as the rest of the cabinet. */
.progress-row {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 22px;
    margin-bottom: 18px;
    animation: fadeUp .5s ease both;
}

.progress-stat .progress-n {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
}

.progress-stat .progress-l {
    font-size: .82rem;
    color: var(--muted);
    margin-top: 2px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    animation: fadeUp .5s ease both;
}

.card + .card {
    margin-top: 18px;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 1.05rem;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 8px 24px -8px rgba(13, 148, 136, .5);
    background: linear-gradient(135deg, var(--primary), var(--indigo));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.profile-head .pname {
    font-size: 1.2rem;
    font-weight: 700;
}

.profile-head .pmail {
    color: var(--muted);
    font-size: .9rem;
}

/* ─── Avatar picker (click-to-change + crop modal) ───────────────────────── */
.avatar-picker {
    position: relative;
    flex: 0 0 auto;
    width: 78px;
    height: 78px;
}

.avatar-picker-trigger {
    all: unset;
    display: block;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
}

.avatar-picker-trigger:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.avatar-picker-preview {
    width: 78px;
    height: 78px;
    margin: 0;
}

.avatar-picker-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar-picker-placeholder {
    font-size: 1.9rem;
    line-height: 1;
    opacity: .85;
}

.avatar-picker-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .58);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: .62rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .01em;
    opacity: 0;
    transition: opacity .15s ease;
    pointer-events: none;
}

.avatar-picker-trigger:hover .avatar-picker-overlay,
.avatar-picker-trigger:focus-visible .avatar-picker-overlay,
.avatar-picker.dragover .avatar-picker-overlay {
    opacity: 1;
}

.avatar-picker.dragover .avatar-picker-trigger {
    box-shadow: 0 0 0 3px var(--primary), 0 0 0 6px rgba(13, 148, 136, .25);
    border-radius: 50%;
}

.avatar-picker-remove {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--red);
    color: #fff;
    font-size: .7rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, background .12s ease;
    padding: 0;
}

.avatar-picker-remove:hover {
    background: #b91c1c;
    transform: scale(1.08);
}

.avatar-picker-remove[hidden] {
    display: none;
}

.avatar-picker-hint {
    color: var(--muted);
    font-size: .78rem;
    margin-top: 4px;
    max-width: 46ch;
    transition: color .15s ease;
}

.avatar-picker-hint.err {
    color: var(--red);
    font-weight: 600;
}

/* Standalone variant (e.g. the registration page, before there's a name/photo). */
.avatar-picker-standalone {
    margin: 0 auto 4px;
}

/* ─── Crop modal ──────────────────────────────────────────────────────────── */
body.ap-lock-scroll {
    overflow: hidden;
}

.ap-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 23, 42, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: apFadeIn .15s ease both;
}

@keyframes apFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ap-modal {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px 20px;
    animation: cardIn .25s cubic-bezier(.2, .8, .2, 1) both;
}

.ap-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.ap-modal-head h3 {
    margin: 0;
    font-size: 1.02rem;
}

.ap-close {
    all: unset;
    cursor: pointer;
    color: var(--muted);
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: 8px;
    line-height: 1;
}

.ap-close:hover {
    background: #f1f5f9;
    color: var(--ink);
}

.ap-stage-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ap-stage {
    position: relative;
    width: min(300px, 100%);
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    background: #0b1220;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.ap-stage.dragging {
    cursor: grabbing;
}

.ap-img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    pointer-events: none;
    will-change: left, top, width, height;
}

.ap-mask {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, .68);
    pointer-events: none;
}

.ap-hint {
    color: var(--muted);
    font-size: .74rem;
    text-align: center;
}

.ap-zoom-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 2px 4px;
    font-size: .95rem;
}

.ap-zoom-row input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

.ap-error {
    color: var(--red);
    font-size: .82rem;
    margin: 8px 2px 0;
    font-weight: 600;
}

.ap-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

/* ─── History list ────────────────────────────────────────────────────────── */
.visit-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.visit-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
    animation: fadeUp .45s ease both;
}

.visit-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: #99f6e4;
    text-decoration: none;
}

.visit-card .vc-main {
    flex: 1;
    min-width: 0;
}

.visit-card .vc-name {
    font-weight: 600;
    color: var(--ink);
}

.visit-card .vc-meta {
    color: var(--muted);
    font-size: .82rem;
    margin-top: 2px;
}

.score-badge {
    flex: 0 0 auto;
    min-width: 58px;
    text-align: center;
    padding: 8px 12px;
    border-radius: 12px;
    font-weight: 800;
    color: #fff;
    font-size: 1rem;
    background: #94a3b8;
}

.score-badge.good { background: #16a34a; }
.score-badge.mid { background: #d97706; }
.score-badge.low { background: #dc2626; }

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}

.pill.done { background: #dcfce7; color: #166534; }
.pill.prog { background: #fef9c3; color: #854d0e; }
.pill.aband { background: #fee2e2; color: #991b1b; }
.pill.cancel { background: #f1f5f9; color: #475569; }

.pill.diff-easy { background: #dcfce7; color: #166534; }
.pill.diff-medium { background: #ccfbf1; color: #0f766e; }
.pill.diff-hard { background: #ffedd5; color: #9a3412; }
.pill.diff-dr_hlus { background: #fee2e2; color: #991b1b; }

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}

.empty-state .big {
    font-size: 2.4rem;
    margin-bottom: 8px;
}

/* ─── Visit detail ────────────────────────────────────────────────────────── */
.sec-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin: 16px 0 6px;
    font-weight: 700;
}

.kv {
    margin: 6px 0;
    font-size: .92rem;
}

.kv b {
    font-weight: 600;
}

.debrief {
    white-space: pre-wrap;
    font-size: .92rem;
    line-height: 1.5;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}

.photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.photo {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #f1f5f9;
}

.photo img {
    display: block;
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.photo .cap {
    font-size: .78rem;
    color: var(--muted);
    padding: 6px 10px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tl-item {
    display: flex;
    gap: 10px;
    font-size: .9rem;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--line);
}

.tl-item .tl-kind {
    flex: 0 0 auto;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    font-weight: 700;
    color: var(--muted);
    min-width: 92px;
}

.tl-item.doctor { background: #eef2ff; border-color: #c7d2fe; }
.tl-item.patient { background: #ecfdf5; border-color: #a7f3d0; }
.tl-item.exam { background: #f0f9ff; border-color: #bae6fd; }
.tl-item.evaluation { background: #fef3c7; border-color: #fde68a; }

/* ─── flatpickr calendar — themed to the project palette ──────────────────── */
.flatpickr-calendar {
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    font-family: inherit;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.flatpickr-day:hover {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.flatpickr-day.today {
    border-color: var(--primary);
}

.flatpickr-day.today:hover {
    background: var(--primary);
    color: #fff;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekday {
    color: var(--ink);
    fill: var(--ink);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--primary);
}

span.flatpickr-weekday {
    color: var(--muted);
}

.flatpickr-current-month input.cur-year {
    font-weight: 600;
}
