/* Patient-facing "My Appointments" page */

/* --appt-* colour tokens live in :root (templates/layout/patient.php) so
   every patient-flow page can use them, including chrome outside any single
   page's content wrapper (e.g. the shared header's Log Out link). Don't
   redefine them here - this file only consumes var(--appt-*). */
.appointments-page {
    color: var(--appt-text);
}

.appointments-page .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.appointments-page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.appointments-page-header h1 {
    margin-bottom: 0.25rem;
    color: var(--appt-heading);
}

.appointments-page-subtitle {
    color: var(--appt-text-muted);
    margin: 0;
}

.appointments-sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--appt-text-muted);
    margin-bottom: 1rem;
}

.appointments-sort a {
    text-decoration: none;
}

/* Card wrapper */
.appointments-card {
    background: var(--appt-surface);
    border: 1px solid var(--appt-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(20, 24, 31, 0.04), 0 1px 8px rgba(20, 24, 31, 0.03);
}

/* Table */
.appointments-table {
    width: 100%;
    border-collapse: collapse;
}

.appointments-table thead th {
    text-align: left;
    /* Sizes are rem against milligram's 62.5% root (1rem = 10px), set so body
       cells render at 16px - the body text size used across the rest of the
       booking flow (confirm/overview labels, inputs, selects). Column headers
       sit just under body text at 14px. */
    font-size: 1.4rem;
    color: var(--appt-text-muted);
    background: var(--appt-bg);
    padding: 1.3rem 1.6rem;
    border-bottom: 1px solid var(--appt-border);
    font-weight: 600;
}

.appointments-table thead th a {
    color: inherit;
    text-decoration: none;
}

.appointments-table thead th a:hover {
    color: var(--appt-accent);
}

.appointments-table tbody tr {
    border-bottom: 1px solid var(--appt-border);
    transition: background-color 0.12s ease-in-out;
}

.appointments-table tbody tr:last-child {
    border-bottom: none;
}

.appointments-table tbody tr:hover {
    background: var(--appt-row-hover);
}

.appointments-table td {
    padding: 1.5rem 1.6rem;
    vertical-align: middle;
    font-size: 1.6rem;
}

.appt-date {
    display: block;
    font-weight: 600;
    color: var(--appt-heading);
}

.appt-time {
    display: block;
    color: var(--appt-text-muted);
    font-size: 1.3rem;
    margin-top: 0.15rem;
}

.practitioner-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.practitioner-avatar {
    flex: 0 0 auto;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: var(--appt-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.practitioner-name {
    font-weight: 600;
    color: var(--appt-heading);
}

.appt-reason {
    display: block;
    color: var(--appt-text);
}

.appt-reason-secondary {
    display: block;
    color: var(--appt-text-muted);
    font-size: 1.3rem;
    margin-top: 0.15rem;
}

.status-badge {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 1.2rem;
    font-weight: 600;
}

.status-badge.status-confirmed {
    background: var(--appt-confirmed-bg);
    color: var(--appt-confirmed-text);
}

.status-badge.status-cancelled {
    background: var(--appt-cancelled-bg);
    color: var(--appt-cancelled-text);
}

.appointments-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.appointments-actions-cell .button {
    font-size: 1.3rem;
    padding: 0.7rem 1.4rem;
    height: auto;
    line-height: 1.4;
}

/* Empty state */
.appointments-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--appt-text-muted);
}

.appointments-empty p {
    margin: 0;
}

/* Back to home link */
.appointments-footer {
    margin-top: 1.75rem;
}

.appointments-footer a {
    color: var(--appt-accent);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
}

.appointments-footer a:hover {
    color: var(--appt-accent-hover);
    text-decoration: underline;
}

/* Responsive: stack into cards below tablet width */
@media (max-width: 720px) {
    .appointments-card {
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .appointments-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .appointments-table, .appointments-table tbody, .appointments-table tr, .appointments-table td {
        display: block;
        width: 100%;
    }

    .appointments-table tbody tr {
        background: var(--appt-surface);
        border: 1px solid var(--appt-border);
        border-radius: 10px;
        margin-bottom: 0.9rem;
        padding: 0.25rem 0;
        box-shadow: 0 1px 2px rgba(20, 24, 31, 0.04);
    }

    .appointments-table tbody tr:hover {
        background: var(--appt-surface);
    }

    .appointments-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.65rem 1rem;
        border-bottom: 1px solid var(--appt-border);
        text-align: right;
    }

    .appointments-table td:last-child {
        border-bottom: none;
    }

    .appointments-table td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 0.72rem;
        color: var(--appt-text-muted);
        font-weight: 600;
        text-align: left;
    }

    .appt-date, .appt-time, .appt-reason, .appt-reason-secondary {
        text-align: right;
    }

    .practitioner-cell {
        justify-content: flex-end;
    }

    .appointments-actions-cell {
        justify-content: flex-end;
    }

    .appointments-actions-cell::before {
        content: none;
    }
}
