/* components.css — Reusable UI components */

/* ── CARD ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    margin-bottom: var(--sp-4);
    transition: background var(--tr-normal), border-color var(--tr-normal);
}

.card-header {
    font-size: var(--text-sm);
    color: var(--text-muted);
    border-bottom: 1px dashed var(--border-dash);
    padding-bottom: var(--sp-2);
    margin-bottom: var(--sp-4);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    font-family: var(--font-ui);
}

.card-header::after {
    content: '';
    flex: 1;
    margin-left: var(--sp-3);
    border-bottom: 1px dashed var(--border-dash);
}

/* When header has a pill/tag child, the dashed line fills between text and pill */
.card-header:has(.readiness-pill)::after,
.card-header:has(.fasttrack-tag)::after,
.card-header:has(.resize-btn)::after {
    /* ::after still takes flex:1 between the text and the trailing element */
    min-width: var(--sp-3);
}

.card--flush { padding: 0; }
.card--accent { border-left: 3px solid var(--accent-teal, var(--accent-yellow)); }

/* ── READINESS HERO ─────────────────────────────────────── */
.readiness-hero {
    padding: var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    flex-wrap: wrap;
}

.readiness-pill {
    padding: var(--sp-2) var(--sp-5);
    border-radius: var(--radius-full);
    font-weight: var(--weight-black);
    font-size: var(--text-xl);
    font-family: var(--font-mono);
    letter-spacing: 1px;
}

.readiness-pill--go     { background: var(--status-green-bg); color: var(--status-green); }
.readiness-pill--adjust { background: var(--status-orange-bg); color: var(--status-orange); }
.readiness-pill--rest   { background: var(--status-red-bg); color: var(--status-red); }

.readiness-score {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
}

.readiness-meta {
    display: flex;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

/* ── METRICS ROW ────────────────────────────────────────── */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--sp-3);
}

.metric {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background var(--tr-normal);
}

.metric-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: var(--weight-semi);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: var(--weight-heavy);
    color: var(--text-main);
}

.metric-value--positive { color: var(--status-green); }
.metric-value--negative { color: var(--status-red); }
.metric-value--warning  { color: var(--status-orange); }

/* ── SPORT BADGE ────────────────────────────────────────── */
.sport-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    font-family: var(--font-mono);
}

.sport-badge--swim { background: var(--sport-swim-bg); color: var(--sport-swim-dot); }
.sport-badge--bike { background: var(--sport-bike-bg); color: var(--sport-bike-dot); }
.sport-badge--run  { background: var(--sport-run-bg);  color: var(--sport-run-dot); }
.sport-badge--renf { background: var(--sport-renf-bg); color: var(--sport-renf-dot); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-sm);
    font-weight: var(--weight-semi);
    font-size: var(--text-sm);
    line-height: 1.4;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--tr-fast);
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-teal, var(--accent-yellow));
    color: #0b0c0f;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-secondary {
    background: var(--bg-card-alt);
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-elevated); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-card-alt); color: var(--text-main); }

.btn-danger {
    background: var(--status-red-bg);
    color: var(--status-red);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: var(--text-base); }

/* ── INDICATOR (Couzens-style) ──────────────────────────── */
.indicator {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-left: 3px solid var(--border-color);
    font-size: var(--text-sm);
}

.indicator--green  { border-left-color: var(--status-green); }
.indicator--orange { border-left-color: var(--status-orange); }
.indicator--red    { border-left-color: var(--status-red); }
.indicator--grey   { border-left-color: var(--status-grey); }

.indicator-name { color: var(--text-muted); min-width: 80px; }
.indicator-value {
    font-family: var(--font-mono);
    font-weight: var(--weight-bold);
}

/* ── DRAWER / BOTTOM SHEET ──────────────────────────────── */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: var(--drawer-backdrop);
    z-index: var(--z-drawer-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--tr-normal), visibility var(--tr-normal);
}

.drawer-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--tr-normal);
    overflow-y: auto;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.drawer-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
}

.drawer-close {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background var(--tr-fast);
}

.drawer-close:hover { background: var(--bg-card-alt); }

.drawer-close svg {
    width: 18px; height: 18px;
    stroke: var(--text-muted);
    stroke-width: 2;
}

.drawer-body {
    flex: 1;
    padding: var(--sp-5);
}

.drawer-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
}

/* Mobile: bottom sheet */
@media (max-width: 767px) {
    .drawer {
        top: auto; right: 0; left: 0; bottom: 0;
        width: 100%;
        max-height: 85dvh;
        border-left: none;
        border-top: 1px solid var(--border-color);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
    }

    .drawer.open { transform: translateY(0); }

    .drawer-header::before {
        content: '';
        position: absolute;
        top: 8px; left: 50%;
        transform: translateX(-50%);
        width: 32px; height: 4px;
        background: var(--border-color);
        border-radius: 2px;
    }
}

/* ── FORM FIELDS ────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--sp-4);
}

.form-label {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: var(--sp-2);
}

.form-input {
    width: 100%;
    padding: var(--sp-3);
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--text-main);
    transition: border-color var(--tr-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

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

/* Segmented control (1-2-3 buttons) */
.seg-group {
    display: flex;
    gap: 2px;
    background: var(--bg-card-alt);
    border-radius: var(--radius-sm);
    padding: 2px;
    border: 1px solid var(--border-color);
}

.seg-btn {
    flex: 1;
    padding: var(--sp-2) var(--sp-3);
    border-radius: 3px;
    font-size: var(--text-sm);
    font-weight: var(--weight-semi);
    text-align: center;
    cursor: pointer;
    transition: all var(--tr-fast);
    color: var(--text-muted);
}

.seg-btn.active {
    background: var(--accent-teal, var(--accent-yellow));
    color: #0b0c0f;
}

/* Pill selectors */
.pill-group {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.pill {
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    cursor: pointer;
    transition: all var(--tr-fast);
    color: var(--text-muted);
}

.pill.active {
    background: var(--accent-teal, var(--accent-yellow));
    color: #0b0c0f;
    border-color: var(--accent-teal, var(--accent-yellow));
}

/* ── TOAST ──────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: var(--sp-5);
    right: var(--sp-5);
    padding: var(--sp-3) var(--sp-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-main);
    z-index: var(--z-toast);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity var(--tr-fast), transform var(--tr-fast);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast--success { border-left: 3px solid var(--status-green); }
.toast--warning { border-left: 3px solid var(--status-orange); }
.toast--error   { border-left: 3px solid var(--status-red); }

@media (max-width: 767px) {
    .toast {
        top: auto;
        bottom: calc(var(--bottom-nav-h) + var(--sp-3));
        right: var(--sp-4);
        left: var(--sp-4);
    }
}

/* ── UTILITIES ──────────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.font-bold { font-weight: var(--weight-bold); }
.font-heavy { font-weight: var(--weight-heavy); }
.uppercase { text-transform: uppercase; letter-spacing: 0.5px; }
.flex-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; gap: var(--sp-3); }
.grid-2col { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }
.mt-4 { margin-top: var(--sp-4); }
.mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }
