/**
 * ALJA — Order Document CSS
 * Styles pour :
 *  - .alja-order-doc (reçu/document, partagé entre detail-commande et thankyou)
 *  - .alja-order-table (tableau articles)
 *  - .alja-thankyou (page confirmation post-paiement)
 *  - @media print (PDF propre)
 *
 * Tokens : var(--alja-*) définis dans main.css :root
 *
 * @package ALJA
 */

/* ─────────────────────────────────────────
   1. Page wrapper (order-detail-template)
───────────────────────────────────────── */
.alja-order-detail__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.alja-order-detail__back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--alja-primary);
    text-decoration: none;
    transition: gap var(--alja-trans-fast);
}
.alja-order-detail__back:hover { gap: 0.75rem; }

.alja-order-detail__actions {
    display: flex;
    gap: 0.875rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ─────────────────────────────────────────
   2. Button ghost (local only)
───────────────────────────────────────── */
.alja-btn--ghost {
    background: transparent;
    color: var(--alja-primary);
    border: 1px solid var(--alja-gray-200);
    padding: 0.375rem 0.75rem;
    border-radius: var(--alja-radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--alja-trans-fast);
    cursor: pointer;
}
.alja-btn--ghost:hover {
    border-color: var(--alja-primary);
    background: rgba(58,138,106,0.05);
}

.alja-btn--sm { padding: 0.5rem 1rem; font-size: 0.8125rem; }

/* ─────────────────────────────────────────
   3. Order Document (.alja-order-doc)
───────────────────────────────────────── */
.alja-order-doc {
    background: #fff;
    border: 1px solid var(--alja-gray-200);
    border-radius: var(--alja-radius-lg);
    box-shadow: var(--alja-shadow-sm);
    /* overflow:clip keeps border-radius visible without blocking internal scroll */
    overflow: clip;
    max-width: 100%;
}

/* 3.1 Header */
.alja-order-doc__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 2rem 2.5rem 1.75rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.alja-order-doc__brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.alja-order-doc__logo {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.alja-order-doc__brand-name {
    font-family: 'Outfit', sans-serif;
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--alja-primary);
    letter-spacing: -0.02em;
}

.alja-order-doc__brand-info {
    display: flex;
    flex-direction: column;
}
.alja-order-doc__brand-info strong { font-size: 0.9375rem; color: var(--alja-charcoal); }
.alja-order-doc__brand-info span   { font-size: 0.75rem; color: var(--alja-gray-600); }

.alja-order-doc__meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.625rem;
}

.alja-order-doc__title-wrap { display: flex; flex-direction: column; }

.alja-order-doc__label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--alja-gray-400);
}

.alja-order-doc__order-num {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--alja-charcoal);
    line-height: 1;
    margin: 0.25rem 0 0;
}

.alja-order-doc__status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.875rem;
    border-radius: var(--alja-radius-full);
    font-size: 0.8125rem;
    font-weight: 700;
}

/* 3.2 Divider */
.alja-order-doc__divider {
    height: 1px;
    background: var(--alja-gray-200);
    margin: 0 2.5rem;
}

/* 3.3 Info row */
.alja-order-doc__info-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
    padding: 1.75rem 2.5rem;
}

.alja-order-doc__col-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--alja-gray-400);
    margin: 0 0 0.375rem;
}

.alja-order-doc__col-val {
    font-size: 0.9375rem;
    color: var(--alja-charcoal);
    font-weight: 600;
    margin: 0;
    line-height: 1.5;
}

.alja-order-doc__col-val small {
    display: block;
    font-weight: 400;
    font-size: 0.8125rem;
    color: var(--alja-gray-600);
}

/* 3.4 Table wrapper */
.alja-order-doc__table-wrap {
    padding: 0 2.5rem 1.75rem;
    overflow-x: auto;
}

/* 3.5 Note client */
.alja-order-doc__note {
    margin: 0 2.5rem 1.75rem;
    padding: 1rem 1.25rem;
    background: var(--alja-sand-lt);
    border: 1px solid var(--alja-gray-200);
    border-radius: var(--alja-radius-sm);
}

/* 3.6 Footer doc */
.alja-order-doc__footer {
    background: var(--alja-gray-50);
    border-top: 1px solid var(--alja-gray-200);
    padding: 1.375rem 2.5rem;
    text-align: center;
    /* Prevent long strings (email, names) from overflowing */
    overflow-wrap: break-word;
    word-break: break-word;
}
.alja-order-doc__footer p {
    font-size: 0.8125rem;
    color: var(--alja-gray-600);
    margin: 0.25rem 0;
    overflow-wrap: break-word;
    word-break: break-word;
}
.alja-order-doc__footer a {
    color: var(--alja-primary);
    text-decoration: none;
    overflow-wrap: break-word;
    word-break: break-word;
}
.alja-order-doc__footer a:hover { text-decoration: underline; }
.alja-order-doc__footer-legal { font-size: 0.6875rem !important; color: var(--alja-gray-400) !important; }

/* ─────────────────────────────────────────
   4. Order Table (.alja-order-table)
───────────────────────────────────────── */
.alja-order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.alja-order-table thead tr {
    border-bottom: 2px solid var(--alja-gray-200);
}

.alja-order-table th {
    padding: 0.75rem 0.625rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--alja-gray-400);
    white-space: nowrap;
}

.alja-order-table__qty,
.alja-order-table__price,
.alja-order-table__total { text-align: right; }

.alja-order-table__item td {
    padding: 1rem 0.625rem;
    border-bottom: 1px solid var(--alja-gray-200);
    vertical-align: middle;
}
.alja-order-table__item:last-child td { border-bottom: none; }

.alja-order-table__product-wrap {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.alja-order-table__img {
    width: 52px;
    height: 52px;
    border-radius: var(--alja-radius-sm);
    object-fit: cover;
    border: 1px solid var(--alja-gray-200);
    flex-shrink: 0;
    background: var(--alja-gray-100-alt);
}

.alja-order-table__img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.alja-order-table__qty  { color: var(--alja-gray-600); }
.alja-order-table__price { color: var(--alja-gray-600); white-space: nowrap; }
.alja-order-table__total { color: var(--alja-charcoal); font-weight: 700; white-space: nowrap; }

/* Totals footer rows */
.alja-order-table__total-row td {
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    color: var(--alja-gray-600);
}
.alja-order-table__total-row--grand td {
    padding: 0.875rem 0.625rem;
    font-size: 1rem;
    color: var(--alja-charcoal);
    font-weight: 800;
    border-top: 2px solid var(--alja-gray-200);
}
.alja-order-table__total-label { text-align: right; }
.alja-order-table__total-val   { text-align: right; white-space: nowrap; color: var(--alja-primary) !important; }

/* ─────────────────────────────────────────
   5. Thank You Page (.alja-thankyou)
───────────────────────────────────────── */
.alja-thankyou {
    max-width: 780px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
    position: relative;
}

/* Confetti */
.alja-thankyou__confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.alja-confetti-particle {
    position: absolute;
    top: -20px;
    border-radius: 2px;
    animation: alja-confetti-fall 3s ease-in forwards;
}

@keyframes alja-confetti-fall {
    0%   { transform: translateY(-20px) rotate(0deg);    opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg);  opacity: 0; }
}

/* Hero */
.alja-thankyou__hero {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
}

.alja-thankyou__checkmark {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
}

.alja-thankyou__svg { width: 72px; height: 72px; }

.alja-thankyou__check-path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: alja-draw-check 0.6s ease 0.3s forwards;
}

@keyframes alja-draw-check {
    to { stroke-dashoffset: 0; }
}

.alja-thankyou__title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--alja-charcoal);
    margin: 0 0 0.75rem;
}

.alja-thankyou__subtitle {
    font-size: 1rem;
    color: var(--alja-gray-600);
    line-height: 1.7;
    margin: 0 auto 1.25rem;
    max-width: 500px;
}

.alja-thankyou__status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 1rem;
    border-radius: var(--alja-radius-full);
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

/* Document in thankyou page */
.alja-thankyou__doc {
    margin-bottom: 2rem;
}

/* Actions */
.alja-thankyou__actions {
    display: flex;
    gap: 0.875rem;
    justify-content: center;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    align-items: center;
}

/* Normalize button.alja-btn to match a.alja-btn exactly */
.alja-thankyou__actions .alja-btn,
.alja-order-detail__actions .alja-btn {
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    line-height: 1.2;
    vertical-align: middle;
    height: auto;
    min-height: 0;
    padding: 0.75rem 1.5rem;
    border-radius: var(--alja-radius-lg);
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.01em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 200ms ease;
}

/* Hide <br> injected by WordPress wpautop() inside buttons */
.alja-thankyou__actions br,
.alja-order-detail__actions br,
.alja-thankyou__actions .alja-btn br,
.alja-order-detail__actions .alja-btn br {
    display: none;
}

/* ─────────────────────────────────────────
   6. Responsive — ordre mobile-first
───────────────────────────────────────── */

/* ── Tablet + phone: < 900px ─── */
@media (max-width: 899px) {

    /* Prevent any horizontal overflow on the whole page */
    body.alja-order-detail-page,
    body.alja-order-detail-page .alja-profile-wrap,
    body.alja-order-detail-page .alja-dashboard,
    body.alja-order-detail-page .alja-dashboard__main {
        overflow-x: hidden;
    }
    .alja-profile-wrap {
        padding-inline: 1rem;
    }

    /* ─── Top action bar: ← Mes Commandes | PDF ─── */
    .alja-order-detail__bar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 0.625rem;
        margin-bottom: 1rem;
    }
    /* PDF button in the bar: compact, never clip */
    .alja-order-detail__bar .alja-btn {
        flex-shrink: 0;
        padding: 0.45rem 0.875rem;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    /* ─── Order document: contain content ─── */
    .alja-order-doc {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    /* ─── Order document header: stack vertically ─── */
    .alja-order-doc__header {
        padding: 1.25rem;
        gap: 0.875rem;
        flex-direction: column;
        align-items: flex-start;
    }
    /* Brand row: limit width so it never overflows */
    .alja-order-doc__brand {
        max-width: 100%;
        overflow: hidden;
    }
    /* Hide redundant text info (name + URL) shown next to the logo on mobile */
    .alja-order-doc__brand-info {
        display: none;
    }
    /* Brand-name (text fallback when no logo): wrap nicely */
    .alja-order-doc__brand-name {
        max-width: 100%;
        word-break: break-word;
    }
    /* Meta block: spread order number and status pill side by side */
    .alja-order-doc__meta {
        text-align: left;
        align-items: flex-start;
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* ─── Spacing ─── */
    .alja-order-doc__divider    { margin: 0 1.25rem; }
    .alja-order-doc__info-row   { padding: 1rem 1.25rem; gap: 0.875rem; }
    .alja-order-doc__footer     { padding: 1rem 1.25rem; }

    /* ─── Info row: 2 cols ─── */
    .alja-order-doc__info-row {
        grid-template-columns: 1fr 1fr;
    }

    /* ─── Table wrapper: scrollable horizontally ─── */
    .alja-order-doc__table-wrap {
        padding: 0 1.25rem 1.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Ensure the wrapper itself never exceeds the card width */
        max-width: 100%;
        box-sizing: border-box;
    }
    .alja-order-table {
        width: 100%;
        /* Remove fixed min-width — let the table adapt or scroll at breakpoint */
        min-width: 420px;
    }
    .alja-order-table__item td { padding: 0.75rem 0.5rem; }

    /* ─── Bottom action buttons ─── */
    .alja-order-detail__actions {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.25rem;
        padding-right: 0;
    }
    .alja-order-detail__actions .alja-btn {
        width: 100%;
        justify-content: center;
    }

    /* Thank you page action buttons */
    .alja-thankyou__actions .alja-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── Phone: < 480px ─── */
@media (max-width: 480px) {

    .alja-profile-wrap { padding-inline: 0.75rem; }

    /* Header doc: tighten padding */
    .alja-order-doc__header { padding: 0.875rem; gap: 0.625rem; }
    .alja-order-doc__divider { margin: 0 0.875rem; }
    .alja-order-doc__info-row { padding: 0.875rem; }
    .alja-order-doc__table-wrap { padding: 0 0.875rem 0.875rem; }
    .alja-order-doc__footer { padding: 0.875rem; }

    /* Meta row: stack order number + status pill vertically */
    .alja-order-doc__meta   { flex-direction: column; gap: 0.375rem; }
    .alja-order-doc__order-num { font-size: 1.375rem; }

    /* Info row: single column on very small screens */
    .alja-order-doc__info-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Table: on very small screens hide the unit price column to avoid overflow */
    .alja-order-table th.alja-order-table__price,
    .alja-order-table td.alja-order-table__price {
        display: none;
    }
    /* Adjust product column to stretch more when price col is hidden */
    .alja-order-table {
        min-width: 0;
        width: 100%;
    }
    .alja-order-table__product-wrap {
        gap: 0.625rem;
    }
    .alja-order-table__img {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
    }
    /* Total rows: right-align the label cell */
    .alja-order-table tfoot .alja-order-table__total-label {
        text-align: right;
    }

    /* Top bar: stack on very small screens */
    .alja-order-detail__bar {
        flex-direction: column;
        align-items: stretch;
    }
    .alja-order-detail__bar .alja-btn {
        width: 100%;
        justify-content: center;
    }

    /* Email in footer: ensure it wraps */
    .alja-order-doc__footer a {
        display: inline-block;
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: break-all;
    }

    /* Thank you page: stack buttons */
    .alja-thankyou__actions {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ─────────────────────────────────────────
   7. @media print — PDF propre
───────────────────────────────────────── */
@media print {
    /* Cache tout sauf le document */
    .alja-no-print,
    .alja-header,
    .alja-footer,
    .alja-profile-sidebar,
    .alja-order-detail__bar,
    .alja-order-detail__actions,
    .alja-thankyou__hero,
    .alja-thankyou__confetti,
    .alja-thankyou__actions,
    .alja-float,
    #alja-go-top,
    .alja-hamburger,
    nav,
    footer { display: none !important; }

    body, html {
        background: #fff !important;
        color: #000 !important;
        font-size: 10pt !important;
    }

    .alja-profile-wrap,
    .alja-dashboard,
    .alja-dashboard__main { display: block !important; padding: 0 !important; margin: 0 !important; }

    .alja-order-doc {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        border-radius: 0 !important;
        break-inside: avoid;
    }

    .alja-order-doc__header { padding: 1.25rem 1.5rem !important; }
    .alja-order-doc__table-wrap { padding: 0 1.5rem 1.25rem !important; }
    .alja-order-doc__info-row { padding: 1rem 1.5rem !important; }
    .alja-order-doc__divider { margin: 0 1.5rem !important; }
    .alja-order-doc__footer { padding: 0.875rem 1.5rem !important; }

    .alja-order-table { font-size: 9pt; }
    .alja-order-table__img { width: 36px !important; height: 36px !important; }

    a { color: inherit !important; text-decoration: none !important; }

    @page {
        margin: 1.5cm;
        size: A4 portrait;
    }
}
