/*
 * DermaMedica admin area.
 *
 * This file deliberately defines NO colours, fonts, radii or shadows of its own.
 * Every value below resolves to a custom property declared in dermamedica.css -
 * --navy, --sand, --font-display, --radius-md and so on - which the admin
 * layouts load first.
 *
 * That is the whole point: the admin panel is the same product as the public
 * site, so when the brand palette or the type scale changes there, the admin
 * follows without anyone having to remember this file exists. Hard-coding a hex
 * value here would create exactly the drift we are avoiding.
 *
 * Class names keep the `adm-` prefix carried over from CandleCraft.
 *
 * Layout is fluid from 320px up - Charlotte checks this on an iPad (US 5.1).
 */

/* ---------- Shell ---------- */

body.admin {
    margin: 0;
    background: var(--mist);
    color: var(--body);
    font-family: var(--font-ui);
    font-size: var(--text-base);
    line-height: 1.55;
}

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

.adm-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Mirrors the public .header: sticky, translucent, blurred. */
.adm-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}

.adm-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
    padding-block: 0.85rem;
}

.adm-header__logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.adm-header__logo img {
    display: block;
    width: auto;
    height: 34px;
}

/* Distinguishes the admin panel from the public site at a glance, without
   inventing a new colour - it is the brand sand on its own tint. */
.adm-badge-staff {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--sand-soft);
    color: var(--sand-deep);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.adm-session {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    font-size: var(--text-sm);
    color: var(--body);
}

.adm-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.adm-nav__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    padding-block: 0.4rem;
}

.adm-nav a {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-pill);
    color: var(--body);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

.adm-nav a:hover,
.adm-nav a:focus-visible {
    background: var(--line-soft);
    color: var(--navy);
}

.adm-nav a[aria-current="page"] {
    background: var(--navy);
    color: var(--white);
}

.adm-main {
    flex: 1;
    padding-block: var(--gap-lg) var(--gap-xl);
}

/* ---------- Toolbar ---------- */

.adm-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--gap-sm);
    margin-bottom: var(--gap-md);
}

/* Display serif, matching the public site's headings. */
.adm-toolbar__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-h3);
    font-weight: 400;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.adm-toolbar__sub {
    margin: 0.3rem 0 0;
    font-size: var(--text-sm);
    color: var(--muted);
}

/* ---------- Filter bar ---------- */

.adm-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-sm);
    align-items: flex-end;
    padding: var(--gap-md);
    margin-bottom: var(--gap-md);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.adm-filter__group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 12rem;
    flex: 1 1 12rem;
}

.adm-filter__group label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted);
}

.adm-filter__actions {
    display: flex;
    gap: 0.5rem;
}

/* ---------- Table ---------- */

.adm-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.adm-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    background: var(--line-soft);
    border-bottom: 1px solid var(--line);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.adm-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    font-size: var(--text-sm);
    color: var(--body);
}

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

.adm-strong {
    font-weight: 600;
    color: var(--ink);
}

.adm-muted {
    color: var(--muted);
}

/* Rows needing attention, e.g. stock at or below the reorder level (US 6.5).
   Colour alone is never the signal - always pair this with a text badge, or the
   state is invisible to a colour-blind user and to anyone printing the page. */
.adm-row--warn {
    background: var(--sand-soft);
}

/* ---------- Badges ---------- */

.adm-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
}

.adm-badge--green { background: #e7f2ec; color: #1f6b45; }
.adm-badge--amber { background: var(--sand-soft); color: var(--sand-deep); }
.adm-badge--red { background: #fbeceb; color: #a3342b; }
.adm-badge--grey { background: var(--line-soft); color: var(--muted); }
.adm-badge--navy { background: var(--mist); color: var(--navy); }

/* ---------- Buttons ----------
   .btn / .btn--primary / .btn--ghost come straight from dermamedica.css, so an
   admin button is literally the same component as a public one. Only the
   compact variant used inside table rows is defined here. */

.adm-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.25s var(--ease), color 0.25s var(--ease);
}

.adm-btn:hover {
    border-color: var(--navy);
    color: var(--navy);
}

.adm-btn--danger:hover {
    border-color: #a3342b;
    color: #a3342b;
}

.adm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* ---------- Cards ---------- */

.adm-card {
    padding: var(--gap-md);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.adm-card + .adm-card {
    margin-top: var(--gap-md);
}

.adm-card__title {
    margin: 0 0 var(--gap-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.adm-empty {
    padding: var(--gap-lg) var(--gap-md);
    text-align: center;
    color: var(--muted);
    background: var(--white);
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
}

/* ---------- Dashboard stat cards (US 5.1) ---------- */

/* auto-fit keeps this readable at 320px, 768px and 1440px without a single
   media query. */
.adm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: var(--gap-sm);
    margin-bottom: var(--gap-md);
}

.adm-stat {
    display: block;
    padding: var(--gap-md);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease),
                border-color 0.25s var(--ease);
}

.adm-stat:hover,
.adm-stat:focus-visible {
    transform: translateY(-2px);
    border-color: var(--navy-soft);
    box-shadow: var(--shadow-md);
}

.adm-stat__label {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

/* Display serif for the figure itself - the one flourish, matching the public
   hero's treatment of large numbers and headings. */
.adm-stat__number {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 300;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--navy);
}

.adm-stat__hint {
    margin-top: 0.35rem;
    font-size: var(--text-xs);
    color: var(--muted);
}

.adm-stat--alert .adm-stat__number { color: var(--sand-deep); }
.adm-stat--warn .adm-stat__number { color: var(--sand-deep); }

/* Iteration 2 placeholders - visibly inert, so nobody mistakes an empty card
   for a broken one. */
.adm-stat--pending {
    background: var(--cream);
    border-style: dashed;
    box-shadow: none;
}

.adm-stat--pending:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--line);
}

.adm-stat--pending .adm-stat__number {
    font-family: var(--font-ui);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--muted);
}

/* ---------- Forms ---------- */

.adm-form .input {
    margin-bottom: var(--gap-sm);
}

.adm-form label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
}

.adm-form input[type="text"],
.adm-form input[type="email"],
.adm-form input[type="password"],
.adm-form input[type="number"],
.adm-form input[type="date"],
.adm-form input[type="time"],
.adm-form textarea,
.adm-form select,
.adm-filter input,
.adm-filter select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.adm-form input:focus,
.adm-form textarea:focus,
.adm-form select:focus {
    outline: none;
    border-color: var(--navy-soft);
    box-shadow: 0 0 0 3px rgba(58, 84, 144, 0.14);
}

.adm-form .error-message {
    display: block;
    margin-top: 0.3rem;
    color: #a3342b;
    font-size: var(--text-xs);
}

.adm-form input.form-error,
.adm-form select.form-error,
.adm-form textarea.form-error {
    border-color: #a3342b;
}

.adm-hint {
    margin: 0.4rem 0 0;
    font-size: var(--text-xs);
    color: var(--muted);
}

/* ---------- Flash messages ---------- */

.adm-flash:not(:empty) {
    margin-bottom: var(--gap-md);
}

.adm-flash .message {
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}

.adm-flash .message.success { background: #e7f2ec; border-color: #b9dcc8; color: #1f6b45; }
.adm-flash .message.error { background: #fbeceb; border-color: #f0c9c6; color: #a3342b; }
.adm-flash .message.warning { background: var(--sand-soft); border-color: #e3d0b6; color: var(--sand-deep); }
.adm-flash .message.info { background: var(--mist); border-color: var(--line); color: var(--navy); }

/* ---------- Sign-in page ----------
   Reuses the public hero's layered radial wash so the first admin screen is
   recognisably the same site. */

.adm-auth {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--gap-lg) var(--gap-md);
    background: var(--cream);
}

.adm-auth::before,
.adm-auth::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.adm-auth::before {
    top: -22%;
    right: -12%;
    width: 58vw;
    height: 58vw;
    background: radial-gradient(circle at 35% 35%, rgba(58, 84, 144, 0.14), rgba(58, 84, 144, 0) 62%);
}

.adm-auth::after {
    bottom: -30%;
    left: -14%;
    width: 46vw;
    height: 46vw;
    background: radial-gradient(circle at 60% 40%, rgba(176, 141, 95, 0.16), rgba(176, 141, 95, 0) 65%);
}

.adm-auth__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 26rem;
}

.adm-auth__logo {
    display: block;
    margin: 0 auto var(--gap-md);
}

.adm-auth__logo img {
    display: block;
    width: 100%;
    max-width: 15rem;
    height: auto;
    margin-inline: auto;
}

.adm-auth__title {
    margin: 0 0 0.4rem;
    font-family: var(--font-display);
    font-size: var(--text-h3);
    font-weight: 400;
    letter-spacing: -0.015em;
    color: var(--ink);
    text-align: center;
}

.adm-auth__subtitle {
    margin: 0 0 var(--gap-md);
    font-size: var(--text-sm);
    color: var(--muted);
    text-align: center;
}

.adm-auth__card {
    padding: var(--gap-md);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.adm-auth__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
    flex-wrap: wrap;
    margin-top: var(--gap-sm);
}

.adm-auth__actions a {
    font-size: var(--text-sm);
    color: var(--navy);
}

/* Lockout countdown. Amber rather than red - this is a wait, not an error, and
   the person reading it may well be the legitimate owner of the account. */
.adm-lockout {
    margin: var(--gap-sm) 0 0;
    padding: 0.7rem 0.9rem;
    border: 1px solid #e3d0b6;
    border-radius: var(--radius-sm);
    background: var(--sand-soft);
    color: var(--sand-deep);
    font-size: var(--text-sm);
    text-align: center;
}

.adm-lockout__clock {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-variant-numeric: tabular-nums;
    /* Fixed-width digits stop the whole line jittering as the seconds tick. */
    letter-spacing: 0.02em;
}

.adm-auth__back {
    display: block;
    margin-top: var(--gap-md);
    font-size: var(--text-sm);
    color: var(--muted);
    text-align: center;
}

@media (max-width: 420px) {
    .adm-auth__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .adm-auth__actions .btn {
        width: 100%;
    }
}

/* ---------- Responsive tables ---------- */

/* Below 760px the table stacks into cards. Each cell shows its column name from
   the data-label attribute, which is why every <td> in an admin table must
   carry one. */
@media (max-width: 760px) {
    .adm-table thead {
        display: none;
    }

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

    .adm-table tr {
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--line);
    }

    .adm-table td {
        display: flex;
        justify-content: space-between;
        gap: var(--gap-sm);
        padding: 0.45rem 1rem;
        border: none;
    }

    .adm-table td::before {
        content: attr(data-label);
        font-size: var(--text-xs);
        font-weight: 600;
        color: var(--muted);
    }

    .adm-header__inner {
        justify-content: center;
        text-align: center;
    }
}

/* --- Secondary line inside a table cell -------------------------------- */

/* Used under a treatment's name to show its plain-language alternative
   without competing with the name itself. */
.adm-table__secondary {
    display: block;
    margin-top: 0.15rem;
    font-size: var(--text-xs);
    font-weight: 400;
}

/* --- Pagination --------------------------------------------------------- */

.adm-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
    margin-top: var(--gap-md);
}

.adm-pagination__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.adm-pagination__list li a {
    display: inline-flex;
    align-items: center;
    min-width: 2.25rem;
    justify-content: center;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: var(--text-sm);
    color: var(--ink);
    transition: border-color 0.2s ease, color 0.2s ease;
}

.adm-pagination__list li a:hover {
    border-color: var(--navy);
    color: var(--navy);
}

.adm-pagination__list li.active a {
    border-color: var(--navy);
    background: var(--navy);
    color: var(--white);
}

/* Paginator renders disabled controls as links with onclick="return false" -
   they must not read as clickable. */
.adm-pagination__list li.disabled a {
    opacity: 0.45;
    pointer-events: none;
}

.adm-pagination__counter {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--muted);
}
