/**
 * Kundenmenü „Bestellungen" — Styling für das Plugin-Template
 * templates/myaccount/orders.php (Karten-Tabelle, Status-Badges,
 * nummerierte Pagination). Eingebunden über Assets::frontend() nur
 * auf My-Account-Seiten.
 *
 * Farbwerte = GeneratePress-Global-Colors der Site, mit Fallbacks:
 * accent #57991D, accent-2 #74B238, dark-2 #585857, dark-3 #777777,
 * light-2 #FBFBFA, light-3 #EAEAE9, light-4 #D6D6D5.
 */

/* --- Konto-Layout: schmalere Navigation, mehr Platz für den Inhalt ---
   (WC-Core: Navigation 30% / Inhalt 68%; unterhalb 769px stapelt WCs
   Smallscreen-CSS beides auf 100% — deshalb nur ab Tablet-Breite) */
@media (min-width: 769px) {
    body.woocommerce-account .woocommerce-MyAccount-navigation {
        width: 20%;
    }

    body.woocommerce-account .woocommerce-MyAccount-content {
        width: 78%;
    }
}

/* --- Buttons im Konto-Inhalt (Detailansichten, Hinweise, WC-Unterseiten):
       einheitlich grün statt Theme-Textblock. Bewusst VOR den Tabellen-Regeln,
       damit deren Feinheiten (Margins) bei gleicher Spezifität gewinnen. --- */
.woocommerce-account .woocommerce-MyAccount-content a.button,
.woocommerce-account .woocommerce-MyAccount-content button.button {
    display: inline-block;
    white-space: nowrap;
    margin: 2px 6px 2px 0;
    padding: 7px 14px;
    background: var(--accent-2, #74B238);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
}

.woocommerce-account .woocommerce-MyAccount-content a.button:hover,
.woocommerce-account .woocommerce-MyAccount-content button.button:hover {
    background: var(--accent, #57991D);
    color: #fff;
}

/* --- Abschnitte: Überschriften und Hinweise zwischen den Karten --- */
.woocommerce-MyAccount-content h3 {
    margin: 28px 0 12px;
    font-size: 20px;
    color: var(--dark-2, #585857);
}

.woocommerce-MyAccount-content h3:first-child {
    margin-top: 0;
}

.b1-list-hint {
    margin: -6px 0 12px;
    font-size: 14px;
    color: var(--dark-3, #777);
}

/* --- Karten-Container um die Tabelle --- */
.b1-orders {
    background: #fff;
    border: 1px solid var(--light-3, #EAEAE9);
    border-radius: 10px;
    box-shadow: 0 0 10px #f1f2f3;
    overflow-x: auto; /* schmale Layouts: scrollen statt abschneiden */
    margin-bottom: 24px;
}

.woocommerce table.shop_table.b1-orders-table,
table.b1-orders-table {
    width: 100%;
    margin: 0;
    border: 0;
    border-collapse: collapse;
    border-radius: 0;
}

/* --- Kopfzeile --- */
.b1-orders-table thead th {
    background: var(--light-2, #FBFBFA);
    border: 0;
    border-bottom: 1px solid var(--light-3, #EAEAE9);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dark-3, #777);
    text-align: left;
}

/* --- Zeilen & Zellen --- */
.b1-orders-table tbody th,
.b1-orders-table tbody td,
.woocommerce table.shop_table.b1-orders-table tbody th,
.woocommerce table.shop_table.b1-orders-table tbody td {
    border: 0;
    border-bottom: 1px solid var(--light-3, #EAEAE9);
    padding: 14px;
    vertical-align: middle;
    font-size: 15px;
    color: var(--dark-2, #585857);
    text-align: left;
    font-weight: 400;
    white-space: normal; /* WC setzt nowrap → Tabelle sprengt sonst schmale Layouts */
}

/* Datum nicht mitten im Wort/Datum umbrechen lassen */
.b1-orders-table .woocommerce-orders-table__cell-order-date time {
    white-space: nowrap;
}

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

.b1-orders-table tbody tr:hover th,
.b1-orders-table tbody tr:hover td {
    background: var(--light-2, #FBFBFA);
}

/* Auftragsnummer + Projektname darunter */
.b1-orders-table .woocommerce-orders-table__cell-order-number a {
    font-weight: 600;
    color: var(--accent, #57991D);
    text-decoration: none;
}

.b1-orders-table .woocommerce-orders-table__cell-order-number a:hover {
    text-decoration: underline;
}

.b1-orders-table .b1-order-titel {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 400;
    color: var(--dark-3, #777);
}

/* Erste Spalte der übrigen Listen (Angebote, Konfigurationen, Archiv):
   Nummer/Titel wie der Bestellnummern-Link — als Link grün, sonst dunkel */
.b1-orders-table a.b1-title-link {
    font-weight: 600;
    color: var(--accent, #57991D);
    text-decoration: none;
}

.b1-orders-table a.b1-title-link:hover {
    text-decoration: underline;
}

.b1-orders-table span.b1-title-link {
    font-weight: 600;
    color: var(--dark-2, #585857);
}

/* Betragsspalte analog zur Gesamtsumme */
.b1-orders-table .b1-amount {
    font-weight: 600;
    color: var(--dark-2, #585857);
    white-space: nowrap;
}

/* Gesamtsumme: Betrag hervorheben, Exemplarzahl als eigene Zeile darunter */
.b1-orders-table .woocommerce-orders-table__cell-order-total .woocommerce-Price-amount {
    font-weight: 600;
    color: var(--dark-2, #585857);
    white-space: nowrap;
}

.b1-orders-table .b1-order-exemplare {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 400;
    color: var(--dark-3, #777);
    white-space: nowrap;
}

/* --- Status-Badges --- */
.b1-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

/* wartet auf etwas (Zahlung, Upload, Bestätigung, Preflight, …) */
.b1-badge--open {
    background: #FBF3E0;
    color: #8A6100;
}

/* in Arbeit / unterwegs (Produktion, Abholung, Versendet) */
.b1-badge--active {
    background: #EDF5E5;
    color: var(--accent, #57991D);
}

/* abgeschlossen */
.b1-badge--done {
    background: var(--accent, #57991D);
    color: #fff;
}

/* storniert / fehlgeschlagen / erstattet */
.b1-badge--cancelled {
    background: #F7E9E9;
    color: #A94442;
}

/* Altbestand aus dem alten Shop-System (read-only) */
.b1-badge--archive {
    background: var(--light-3, #EAEAE9);
    color: var(--dark-3, #777);
}

/* Bestellstatus-Farben aus der Palette des alten Shop-Systems: gleicher Stil
   wie die Gruppen oben (heller Ton + farbige Schrift, „abgeschlossen" als
   Vollfläche), aber je Status über die WC-Zeilenklasse
   woocommerce-orders-table__row--status-<slug> — ohne Markup-Änderung.
   Helle Legacy-Töne werden für die Schrift abgedunkelt. */
.woocommerce-orders-table__row--status-invoice-auth .b1-badge    { background: color-mix(in srgb, #AA2331 12%, #fff); color: #AA2331; }
.woocommerce-orders-table__row--status-pending .b1-badge,
.woocommerce-orders-table__row--status-pending-payment .b1-badge,
.woocommerce-orders-table__row--status-on-hold .b1-badge         { background: color-mix(in srgb, #AF6329 14%, #fff); color: #AF6329; }
.woocommerce-orders-table__row--status-pending-upload .b1-badge  { background: color-mix(in srgb, #90C244 22%, #fff); color: color-mix(in srgb, #90C244 55%, #000); }
.woocommerce-orders-table__row--status-pending-confirm .b1-badge { background: color-mix(in srgb, #560930 10%, #fff); color: #560930; }
.woocommerce-orders-table__row--status-preflight .b1-badge       { background: color-mix(in srgb, #2A1443 10%, #fff); color: #2A1443; }
.woocommerce-orders-table__row--status-processing .b1-badge      { background: color-mix(in srgb, #255157 12%, #fff); color: #255157; }
.woocommerce-orders-table__row--status-pending-pickup .b1-badge  { background: color-mix(in srgb, #8EA36F 24%, #fff); color: color-mix(in srgb, #8EA36F 50%, #000); }
.woocommerce-orders-table__row--status-shipping .b1-badge        { background: color-mix(in srgb, #EFA216 20%, #fff); color: color-mix(in srgb, #EFA216 55%, #000); }
.woocommerce-orders-table__row--status-completed .b1-badge       { background: #E5440E; color: #fff; }
.woocommerce-orders-table__row--status-cancelled .b1-badge,
.woocommerce-orders-table__row--status-failed .b1-badge,
.woocommerce-orders-table__row--status-refunded .b1-badge        { background: color-mix(in srgb, #9B1F18 12%, #fff); color: #9B1F18; }

/* --- Aktions-Buttons --- */
.b1-orders-table .woocommerce-orders-table__cell-order-actions,
.b1-orders-table .b1-cell-actions {
    text-align: right;
}

.woocommerce .b1-orders-table a.button,
.woocommerce .b1-orders-table button.button,
.b1-orders-table a.button,
.b1-orders-table button.button {
    display: inline-block;
    white-space: nowrap; /* Buttons brechen als Ganzes um, nie im Label */
    margin: 2px 0 2px 6px;
    padding: 7px 14px;
    background: var(--accent-2, #74B238);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
}

.woocommerce .b1-orders-table a.button:hover,
.woocommerce .b1-orders-table button.button:hover,
.b1-orders-table a.button:hover,
.b1-orders-table button.button:hover {
    background: var(--accent, #57991D);
    color: #fff;
}

/* Inline-Formulare (z. B. Löschen-Button) reihen sich zwischen die Links ein */
.b1-orders-table .b1-cell-actions form,
.b1-orders-table .b1-inline-form {
    display: inline-block;
    margin: 0;
}

/* --- Nummerierte Pagination --- */
.b1-orders-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 24px;
    border: 0;
}

.b1-orders-pagination .b1-orders-pagination__link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--light-4, #D6D6D5);
    border-radius: 8px;
    background: #fff;
    color: var(--dark-2, #585857);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
}

.b1-orders-pagination a.b1-orders-pagination__link:hover {
    border-color: var(--accent-2, #74B238);
    color: var(--accent, #57991D);
}

.b1-orders-pagination .b1-orders-pagination__link--current {
    background: var(--accent, #57991D);
    border-color: var(--accent, #57991D);
    color: #fff;
}

.b1-orders-pagination .b1-orders-pagination__link--arrow {
    font-size: 20px;
    padding-bottom: 3px;
}

.b1-orders-pagination .b1-orders-pagination__gap {
    padding: 0 4px;
    color: var(--dark-3, #777);
}

/* --- Detail-Gruppen (Konfigurations-/Archiv-Detailansichten):
       Karte mit Titelbalken und Key/Value-Tabelle --- */
.b1-detail-group .b1-detail-title {
    margin: 0;
    padding: 12px 16px;
    background: var(--light-2, #FBFBFA);
    border-bottom: 1px solid var(--light-3, #EAEAE9);
    font-size: 15px;
    font-weight: 600;
    color: var(--dark-2, #585857);
}

.woocommerce table.shop_table.b1-detail-table,
table.b1-detail-table {
    width: 100%;
    margin: 0;
    border: 0;
    border-collapse: collapse;
    border-radius: 0;
}

.b1-detail-table td {
    border: 0;
    border-bottom: 1px solid var(--light-3, #EAEAE9);
    padding: 10px 16px;
    font-size: 14.5px;
    color: var(--dark-2, #585857);
    text-align: left;
}

.b1-detail-table tr:last-child td {
    border-bottom: 0;
}

.b1-detail-table .b1-detail-label {
    width: 40%;
    color: var(--dark-3, #777);
}

/* --- Leerzustand --- */
.b1-orders--empty {
    padding: 40px 24px;
    text-align: center;
}

.b1-orders--empty p {
    margin-bottom: 16px;
    color: var(--dark-3, #777);
}

.woocommerce .b1-orders--empty a.button,
.b1-orders--empty a.button {
    background: var(--accent-2, #74B238);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 10px 20px;
    font-weight: 600;
    text-decoration: none;
}

.woocommerce .b1-orders--empty a.button:hover,
.b1-orders--empty a.button:hover {
    background: var(--accent, #57991D);
}

/* --- Mobil: gestapelte Karten (baut auf WCs shop_table_responsive auf, das
       thead versteckt, Zellen als Blöcke rendert und data-title voranstellt) --- */
@media only screen and (max-width: 768px) {
    .b1-orders {
        background: transparent;
        border: 0;
        box-shadow: none;
        overflow: visible;
    }

    .b1-orders-table,
    .b1-orders-table tbody,
    .b1-orders-table tbody tr {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    .b1-orders-table .woocommerce-orders-table__cell-order-actions {
        white-space: normal;
    }

    .b1-orders-table thead {
        display: none;
    }

    .b1-orders-table tbody tr {
        display: block;
        margin-bottom: 14px;
        background: #fff;
        border: 1px solid var(--light-3, #EAEAE9);
        border-radius: 10px;
        box-shadow: 0 0 10px #f1f2f3;
        overflow: hidden;
    }

    .b1-orders-table tbody th,
    .b1-orders-table tbody td,
    .woocommerce table.shop_table_responsive.b1-orders-table tr td {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 4px 10px;
        border: 0;
        border-bottom: 1px solid var(--light-3, #EAEAE9);
        padding: 11px 16px;
        background: none;
        text-align: right;
    }

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

    /* Zeilen-Label aus data-title links, Inhalt rechts (überschreibt WCs
       Smallscreen-Float-Variante) */
    .woocommerce table.shop_table_responsive.b1-orders-table tr td::before,
    .b1-orders-table tbody th[data-title]::before,
    .b1-orders-table tbody td[data-title]::before {
        content: attr(data-title);
        float: none;
        font-weight: 600;
        font-size: 12px;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--dark-3, #777);
        margin-right: auto;
        text-align: left;
    }

    .b1-orders-table .woocommerce-orders-table__cell-order-number a,
    .b1-orders-table .b1-title-link {
        font-size: 16px;
    }

    /* Projektname in eigener Zeile unter der Nummer */
    .b1-orders-table .b1-order-titel {
        flex-basis: 100%;
        margin-top: 0;
        text-align: right;
    }

    .woocommerce table.shop_table_responsive.b1-orders-table tr td.woocommerce-orders-table__cell-order-actions::before,
    .woocommerce table.shop_table_responsive.b1-orders-table tr td.b1-cell-actions::before,
    .b1-orders-table tbody td.b1-cell-actions[data-title]::before {
        display: none; /* Label „Aktionen" vor den Buttons wäre doppelt gemoppelt */
    }

    .woocommerce .b1-orders-table a.button,
    .woocommerce .b1-orders-table button.button,
    .b1-orders-table a.button,
    .b1-orders-table button.button {
        margin: 2px 0 2px 6px;
    }
}
