/*
 * Panel additions.
 *
 * style.css is the design system ported from the original templates and is
 * left untouched. Everything here covers the components the Blade/Livewire
 * markup introduces that the templates did not have: data tables, status
 * badges, loading indicators, empty states and the auth shell.
 *
 * Reuses the same custom properties as style.css, so both themes follow along.
 */

.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;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: panel-spin 0.6s linear infinite;
    vertical-align: -0.125em;
}

.spinner-sm {
    width: 0.85em;
    height: 0.85em;
}

@keyframes panel-spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-spinner-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

/* Honour a reduced-motion preference: the spinner stops moving but stays
   visible, so the pending state is still communicated. */
@media (prefers-reduced-motion: reduce) {

    .spinner {
        animation-duration: 2.4s;
    }
}

button[disabled],
.submit-order-btn[disabled] {
    opacity: 0.65;
    cursor: not-allowed;
}

.table-placeholder {
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state p {
    margin: 0;
    max-width: 46ch;
}

.empty-state code {
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 0.9em;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */

.field-error {
    margin: 0.35rem 0 0;
    color: #d63939;
    font-size: 0.8125rem;
    font-weight: 500;
}

.field-hint {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.mass-payload {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.service-description {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.mass-summary {
    margin: 1rem 0 0.5rem;
    font-weight: 600;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */

.orders-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.orders-table th,
.orders-table td {
    padding: 0.75rem 0.625rem;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    vertical-align: middle;
}

.orders-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    white-space: nowrap;
}

.orders-table tbody tr:last-child th,
.orders-table tbody tr:last-child td {
    border-bottom: 0;
}

.cell-sub {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

.truncate-link {
    display: inline-block;
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.amount-in {
    color: #1a8754;
    font-weight: 600;
}

.amount-out {
    color: #d63939;
    font-weight: 600;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.panel-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Below 720px each row becomes its own stacked block and the header is hidden,
   with every cell labelled by its data-label. */
@media (max-width: 720px) {
    .orders-toolbar {
        grid-template-columns: 1fr;
    }

    .orders-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .orders-table tbody tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.125rem;
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    }

    .orders-table td,
    .orders-table tbody th {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.25rem 0;
        border: 0;
        text-align: right;
    }

    .orders-table td::before,
    .orders-table tbody th::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        text-align: left;
    }

    .truncate-link {
        max-width: 18ch;
    }
}

/* ── Status badges ───────────────────────────────────────────────────────── */

.status-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-muted);
}

.status-pending {
    background: rgba(0, 176, 78, 0.12);
    color: #076b30;
}

.status-processing {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.status-partial {
    background: rgba(0, 232, 131, 0.18);
    color: #007942;
}

.status-completed {
    background: rgba(25, 135, 84, 0.14);
    color: #198754;
}

.status-canceled,
.status-failed {
    background: rgba(214, 57, 57, 0.13);
    color: #d63939;
}

.status-refunded,
.status-refilled {
    background: rgba(102, 16, 242, 0.12);
    color: #6610f2;
}

/* ── Sidebar: tier card, wallet chip, logout ─────────────────────────────── */

.sidebar-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.user-tier-card {
    padding: 0.875rem;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(0, 176, 78, 0.12), rgba(7, 111, 49, 0.08));
}

.tier-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tier-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--white);
    color: var(--green);
    font-size: 1.25rem;
    flex: 0 0 auto;
}

.tier-meta p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tier-name {
    font-size: 0.9375rem;
    letter-spacing: 0.02em;
}

.tier-progress {
    height: 6px;
    margin-top: 0.75rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.tier-progress-bar {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary-gradient);
    transition: width 0.3s ease;
}

.tier-spend {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-logout {
    display: block;
    margin-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    padding-top: 0.75rem;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.sidebar-logout-btn:hover {
    background: rgba(214, 57, 57, 0.08);
    color: #d63939;
}

.wallet-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: rgba(0, 176, 78, 0.1);
    color: var(--green-dark);
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
}

.page-title-date {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */

.panel-toasts {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(24rem, calc(100vw - 2rem));
    pointer-events: none;
}

.panel-toast {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    color: var(--white);
    background: #1a1a1a;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.panel-toast-success {
    background: #198754;
}

.panel-toast-error {
    background: #d63939;
}

/* ── Auth shell ──────────────────────────────────────────────────────────── */

/* Split layout: a brand panel on the left carrying the illustration, and the
   form on the right. Below 900px the illustration is dropped rather than
   stacked, because on a phone the form is what matters. */
.auth-body {
    min-height: 100vh;
    margin: 0;
    background: #f6faf8;
    font-family: "Inter", system-ui, sans-serif;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    min-height: 100vh;
}

/* ── Left: brand panel ───────────────────────────────────────────────────── */

.auth-aside {
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 3rem clamp(2rem, 4vw, 4rem);
    background: linear-gradient(150deg, #076b30 0%, #0e8548 52%, #00b04e 100%);
    color: #fff;
}

/* Soft light bloom, so the flat gradient has some depth without an image. */
.auth-aside::before,
.auth-aside::after {
    position: absolute;
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.auth-aside::before {
    top: -14rem;
    right: -10rem;
    width: 34rem;
    height: 34rem;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 70%);
}

.auth-aside::after {
    bottom: -12rem;
    left: -8rem;
    width: 26rem;
    height: 26rem;
    background: radial-gradient(circle, rgba(6, 61, 32, 0.35) 0%, rgba(6, 61, 32, 0) 70%);
}

.auth-aside-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 34rem;
    margin-inline: auto;
}

.auth-aside-brand {
    display: inline-flex;
    align-items: center;
    margin-bottom: 1.75rem;
}

.auth-artwork {
    display: block;
    width: 100%;
    max-width: 30rem;
    height: auto;
    margin: 0 auto 1.5rem;
}

/* A slow drift keeps the panel from feeling like a static screenshot. */
.auth-artwork .za-float {
    animation: za-drift 7s ease-in-out infinite;
}

.auth-artwork .za-float--slow {
    animation-duration: 9s;
    animation-delay: -2s;
}

@keyframes za-drift {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-9px);
    }
}

.auth-aside-headline {
    margin: 0 0 0.6rem;
    font-family: "Poppins", sans-serif;
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.auth-aside-copy {
    margin: 0 0 1.5rem;
    max-width: 30rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.975rem;
    line-height: 1.65;
}

.auth-aside-points {
    display: grid;
    gap: 0.7rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-aside-points li {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.9rem;
    line-height: 1.5;
}

.auth-aside-points iconify-icon {
    flex: 0 0 auto;
    margin-top: 0.1rem;
    color: #9ff0c4;
    font-size: 1.15rem;
}

/* ── Right: form ─────────────────────────────────────────────────────────── */

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem clamp(1.25rem, 4vw, 3.5rem);
    background: #f6faf8;
}

.auth-panel-inner {
    width: 100%;
    max-width: 26rem;
}

.auth-card {
    padding: 2.25rem 2rem;
    border: 1px solid #e3ece7;
    border-radius: 1.5rem;
    background: #fff;
    box-shadow: 0 24px 60px rgba(9, 61, 36, 0.1);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.auth-brand-tag {
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #e6fff2;
    color: var(--green-dark);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.auth-footnote {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 1.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

.auth-footnote iconify-icon {
    color: var(--green);
    font-size: 1rem;
}

.auth-title {
    margin: 0 0 0.25rem;
    font-family: "Poppins", sans-serif;
    font-size: 1.5rem;
}

.auth-subtitle {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Icon-led inputs. The icon sits inside the control's box, so the input's own
   left padding leaves room for it. */
.auth-field {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-field-icon {
    position: absolute;
    left: 0.85rem;
    display: grid;
    place-items: center;
    color: var(--green);
    font-size: 1.15rem;
    pointer-events: none;
}

.auth-field .form-control {
    width: 100%;
    min-height: 3rem;
    padding: 0.7rem 2.9rem 0.7rem 2.6rem;
    border: 1px solid #dfe8e3;
    border-radius: 0.75rem;
    background: #fbfdfc;
    font-size: 0.9375rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.auth-field .form-control:focus {
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 176, 78, 0.14);
    outline: none;
}

.auth-reveal {
    position: absolute;
    right: 0.5rem;
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 0;
    border-radius: 0.55rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.auth-reveal:hover {
    background: #e6fff2;
    color: var(--green-dark);
}

.auth-form .control-label.terms {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-muted);
}

.auth-alt {
    margin: 1.25rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid #eef3f0;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.auth-alt a {
    color: var(--green);
    font-weight: 600;
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    /* The illustration is decoration; the form needs the whole viewport. */
    .auth-aside {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-artwork .za-float,
    .auth-artwork .za-float--slow {
        animation: none;
    }
}

/* ── Attribution ─────────────────────────────────────────────────────────── */

.auth-attribution {
    margin: 1.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

.auth-attribution a {
    color: var(--green-dark);
    font-weight: 600;
    text-decoration: none;
}

.auth-attribution a:hover {
    text-decoration: underline;
}

/* ── Support tickets ─────────────────────────────────────────────────────── */

.ticket-thread .breadcrumb-row {
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.ticket-status-open {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.ticket-status-answered {
    background: rgba(25, 135, 84, 0.14);
    color: #198754;
}

.ticket-status-closed {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-muted);
}

.ticket-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
}

.ticket-message {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
}

/* Staff replies read as inbound, so the customer can tell them apart at a
   glance without relying on colour alone — the label says "Support" too. */
.ticket-message.from-staff {
    border-color: rgba(13, 110, 253, 0.28);
    background: rgba(13, 110, 253, 0.06);
}

.ticket-message-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

.ticket-message-body {
    margin: 0;
    /* Ticket bodies are customer prose: preserve the line breaks they typed. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ── Brand logo ──────────────────────────────────────────────────────────── */

/* The artwork is a pre-cut PNG, so this only has to size it. Height drives the
   scale because the lockup is wide and fixed-proportion; the max-width stops a
   large rendering from pushing the sidebar header wider than its column. */
.brand-logo {
    display: inline-flex;
    align-items: center;
    /* The base sheet gives `.brand-logo` a 30px bottom margin, written for the
       marketing hero banner — a layout this panel has no use for. It is inherited
       because the component's root carries that class, and because the row
       centres with `align-items: center`, a bottom margin shifts the logo up by
       half its height. That is what left it looking off-centre. */
    margin: 0;
}

.brand-logo-image {
    display: block;
    width: auto;
    height: var(--brand-logo-height, 34px);
    max-width: 100%;
    object-fit: contain;
}

/* On the coloured brand panel the artwork already carries white ink, so nothing
   here needs to recolour it. */
.auth-aside-logo .brand-logo-image {
    height: var(--brand-logo-height, 40px);
}

/* ── Iconify ─────────────────────────────────────────────────────────────── */

/*
 * <iconify-icon> is a web component and puts its stylesheet in a shadow root,
 * where `svg { display: block }` and `:host { display: inline-block }` are
 * encapsulated. Nothing outside the component can restyle that inner svg, so the
 * host is all there is to work with — and a bare inline-block host around a
 * block-level svg reserves a full line box. On a narrow screen that pushes the
 * nav rows and the header out of alignment, which is what made the mobile drawer
 * look unstable.
 *
 * Making the host an inline-flex box solves it at the source: the inner svg is
 * centred in a box sized by font-size instead of being laid out in the text
 * flow, and the icon can no longer stretch a flex row.
 */
iconify-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    line-height: 1;
    vertical-align: middle;
}

/* An icon inside a text run should never be a flex item, or it stops being
   baseline-aligned with the words beside it. */
p iconify-icon,
li iconify-icon,
span iconify-icon,
label iconify-icon,
a iconify-icon {
    flex: initial;
}

/* The stock control is 40px on touch; below that the label is fighting the icon
   for room and the row height starts to jump between breakpoints. */
@media (max-width: 991px) {

    .admin-body .nav-item .icon-box {
        width: 32px;
        height: 32px;
    }

    .admin-body .nav-item .icon-box iconify-icon {
        font-size: 1.05rem;
    }
}
