/* ============================================================================
 * Handykasse POS — Konsolidierte Styles
 * ----------------------------------------------------------------------------
 * Ersetzt pos-buttons.css und pos-designer.css. Eine Datei, klare Sektionen.
 *
 * Sektionen:
 *   1. Variables
 *   2. POS Buttons (DxButton wrapped)
 *   3. Layout Helpers (Loading, Toolbar, Logins)
 *   4. Mengen-Buttons in Positionen-Tabelle
 *   5. Layout Grid (readonly)
 *   6. Designer (DnD, Resize, Palette)
 * ============================================================================ */


/* ============================================================================
 * 1. VARIABLES
 * ============================================================================ */

:root {
    --pos-btn-border: 3px solid white;
    --pos-btn-radius: 0;
    --pos-btn-font-size: 1.1rem;
    --pos-default-bg: #6f42c1; /* Standard-Violett wenn keine Farbe gesetzt */
    --pos-drop-highlight: #2e86ff; /* Blau für Drop-Target */
    --pos-active-glow: #ffd000; /* Gelb für "gerade ausgewählt" */
}


/* ============================================================================
 * 2. POS BUTTONS (DxButton Wrapper)
 * ----------------------------------------------------------------------------
 * DevExpress rendert DxButton als:
 *   <button class="dxbl-btn dxbl-btn-primary pos-btn ..."> <span class="dxbl-btn-caption">...</span> </button>
 * Wir überschreiben das Default-Styling, damit Farben/Radius passen.
 * ============================================================================ */

/* Grid-Zelle: Padding weg, damit Button die Zelle komplett ausfüllt */
dxbl-grid-layout-item.dxbl-gridlayout-item,
.dxbl-gridlayout-item {
    padding: 0 !important;
    margin: 0 !important;
}

/* Button-Basis */
.dxbl-btn.pos-btn {
    width: 100%;
    white-space: pre-wrap;
    border: var(--pos-btn-border) !important;
    border-radius: var(--pos-btn-radius) !important;
    font-size: var(--pos-btn-font-size) !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    color: white;
    background-color: var(--pos-default-bg);
    background-image: none !important;
    box-shadow: none !important;
}

    .dxbl-btn.pos-btn > .dxbl-btn-caption,
    .dxbl-btn.pos-btn .dxbl-btn-caption {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        margin: 0 !important;
        white-space: pre-wrap;
        text-align: center;
    }

    .dxbl-btn.pos-btn:hover,
    .dxbl-btn.pos-btn:focus,
    .dxbl-btn.pos-btn:active,
    .dxbl-btn.pos-btn:focus-visible {
        filter: brightness(0.92);
        background-image: none !important;
        box-shadow: none !important;
        outline: none !important;
    }

/* Höhen-Varianten */
.dxbl-btn.pos-btn--h50 {
    height: 50px;
}

.dxbl-btn.pos-btn--h70 {
    height: 70px;
}

.dxbl-btn.pos-btn--h100 {
    height: 100px;
}

.dxbl-btn.pos-btn--full {
    height: 100%;
}

/* Farb-Varianten */
.dxbl-btn.pos-btn--header {
    background-color: darkgrey !important;
    color: black !important;
    font-weight: bold;
}

.dxbl-btn.pos-btn--submit {
    background-color: green !important;
    color: white !important;
}

.dxbl-btn.pos-btn--danger {
    background-color: red !important;
    color: white !important;
}

.dxbl-btn.pos-btn--cancel {
    background-color: brown !important;
    color: white !important;
}

.dxbl-btn.pos-btn--warn {
    background-color: hotpink !important;
    color: black !important;
}

.dxbl-btn.pos-btn--ok {
    background-color: lawngreen !important;
    color: black !important;
}

.dxbl-btn.pos-btn--secondary {
    background-color: beige !important;
    color: black !important;
}

.dxbl-btn.pos-btn--split {
    background-color: yellowgreen !important;
    color: white !important;
}

.dxbl-btn.pos-btn--card {
    background-color: palevioletred !important;
    color: white !important;
}

.dxbl-btn.pos-btn--keep-open {
    background-color: springgreen !important;
    color: black !important;
}

.dxbl-btn.pos-btn--keep-open-customer {
    background-color: cadetblue !important;
    color: white !important;
}

.dxbl-btn.pos-btn--comment {
    background-color: blueviolet !important;
    color: white !important;
}

.dxbl-btn.pos-btn--print {
    background-color: lightseagreen !important;
    color: white !important;
}

.dxbl-btn.pos-btn--free {
    background-color: mediumvioletred !important;
    color: black !important;
    font-weight: bold;
}

.dxbl-btn.pos-btn--customer {
    background-color: lightpink !important;
    color: black !important;
    font-weight: bold;
}

.dxbl-btn.pos-btn--bestellwunsch {
    background-color: palevioletred !important;
    color: black !important;
}

/* Zustände */
.dxbl-btn.pos-btn--depleted {
    opacity: 0.4;
    font-style: italic;
}

.dxbl-btn.pos-tisch--offen {
    border: 5px dashed red !important;
}

.dxbl-btn.pos-tisch--offen-on-red {
    border: 5px dashed blue !important;
}

/* Gangsteuerung: Tisch mit noch nicht abgerufenem Gang (nach den Offen-Regeln,
   damit es bei Tischen mit offenen Positionen UND wartendem Gang gewinnt) */
.dxbl-btn.pos-tisch--gang {
    border: 5px dashed darkorange !important;
}

/* Gangsteuerung: Gang-Button unter –/+, so breit wie – Menge + zusammen (30 + 35 + 30) */
.pos-gang-cell {
    width: 95px;
    margin-top: 4px;
}

.dxbl-btn.pos-gang-btn {
    width: 100% !important;
    height: 26px;
    padding: 0 !important;
    border: 1px solid black !important;
    border-radius: 0 !important;
    background-color: lightyellow !important;
    color: black !important;
    font-weight: bold;
}

.dxbl-btn.pos-btn--gang {
    background-color: darkorange !important;
    color: black !important;
    font-weight: bold;
}

/* Durch N teilen: Hinweis auf bereits bezahlte Anteile */
.pos-teilen-info {
    padding: 8px 4px;
    font-size: larger;
}


/* ============================================================================
 * 3. LAYOUT HELPERS
 * ============================================================================ */

/* Toolbar oberhalb von Pages (TischeSettingsPage, ...) */
.pos-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
}

    .pos-toolbar > * {
        flex: 0 0 auto;
    }

/* Loading-Overlay
 * Vollflächig fixiert -> immer mittig im Viewport, unabhängig von Header,
 * Seitenbreite und Scrollposition. Kurze Einblend-Verzögerung, damit schnelle
 * Vorgänge (< 150 ms) nicht flackern. */
.pos-loading {
    position: fixed;
    inset: 0;
    /* Bewusst UNTER Bootstrap-Modals (1055), DevExpress-Popups (~1050) und
       #blazor-error-ui (1000): Fehlerdialoge, die während eines Vorgangs
       erscheinen ("konnte nicht gedruckt werden"), müssen bedienbar bleiben. */
    z-index: 990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    animation: pos-loading-in 200ms ease-out 150ms forwards;
}

.pos-loading__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 12rem;
    max-width: 20rem;
    padding: 1.75rem 2rem 1.5rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.pos-loading__spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(111, 66, 193, 0.18);
    border-top-color: var(--pos-default-bg);
    border-radius: 50%;
    animation: pos-spin 800ms linear infinite;
}

.pos-loading__text {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 500;
    color: #333;
    line-height: 1.3;
}

@keyframes pos-loading-in {
    to {
        opacity: 1;
    }
}

@keyframes pos-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pos-loading {
        animation: none;
        opacity: 1;
    }

    .pos-loading__spinner {
        animation-duration: 2s;
    }
}

/* Login-Form */
.pos-login-input {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.pos-login-error {
    color: red;
    margin-bottom: 0.5rem;
}


/* ============================================================================
 * 4. MENGEN-BUTTONS (in PositionenTable)
 * ============================================================================ */

.pos-qty-btn {
    width: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.dxbl-btn.pos-qty-btn__add,
.dxbl-btn.pos-qty-btn__remove,
.dxbl-btn.pos-qty-btn__preis {
    width: 30px !important;
    padding: 0 !important;
    background-color: aliceblue !important;
    border: 1px solid black !important;
    border-radius: 0 !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 60% !important;
    background-image: url(../images/preis.svg) !important;
    height: 30px;
}

.dxbl-btn.pos-qty-btn__add {
    background-image: url(../images/add.svg) !important;
}

.dxbl-btn.pos-qty-btn__remove {
    background-image: url(../images/remove.svg) !important;
}

.pos-qty-value {
    width: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.pos-preis-cell {
    display: flex;
    align-items: center;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    padding-right: 8px; /* haelt die Zahl von der Zellkante weg */
}

.pos-preis-value {
    margin-left: auto; /* schiebt die Zahl nach rechts, statt space-between */
    white-space: nowrap; /* nie abschneiden/umbrechen */
}

/* ============================================================================
 * 5. LAYOUT GRID (Read-Only Raster)
 * ============================================================================ */

.pos-layout-grid {
    user-select: none;
}

.pos-layout-readonly-item {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    background-color: var(--pos-default-bg);
    color: white;
    font-size: 1.1rem;
    white-space: pre-wrap;
    text-align: center;
}


/* ============================================================================
 * 6. DESIGNER (Drag-and-Drop Editor)
 * ============================================================================ */
/* ============================================================================
 * CSS — Phase 5a Fix 2
 * ============================================================================
 * Anhängen an pos.css oder Designer-Sektion ersetzen.
 * ============================================================================ */

.pos-designer {
    display: flex;
    gap: 1rem;
    user-select: none;
}

.pos-designer__palette {
    flex: 0 0 200px;
    padding: 0.5rem;
    border: 1px dashed #999;
    background: #fafafa;
    touch-action: none;
    min-height: 150px;
}

.pos-designer__palette-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: 2px dashed #666;
    background: white;
    cursor: grab;
    font-weight: bold;
    color: #333;
    touch-action: none;
    user-select: none;
}

    .pos-designer__palette-item:active {
        cursor: grabbing;
    }

.pos-designer__palette-item--row {
    background: linear-gradient(to bottom, white 0%, #e8f4ff 100%);
    border-color: #2e86ff;
    color: #2e86ff;
}

.pos-designer__palette-item--col {
    background: linear-gradient(to right, white 0%, #e8f4ff 100%);
    border-color: #2e86ff;
    color: #2e86ff;
}

.pos-designer__grid-wrapper {
    flex: 1 1 auto;
    min-width: 0;
    touch-action: none;
    position: relative;
}

.pos-designer__grid {
    touch-action: none;
}

.pos-designer__cell {
    width: 100%;
    height: 100%;
    border: 1px dashed rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    pointer-events: none;
}

/* Ghost-Preview */
.pos-designer__ghost {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    pointer-events: none;
    transition: background 80ms ease;
}

.pos-designer__ghost--valid {
    background: rgba(46, 134, 255, 0.25);
    border: 3px dashed var(--pos-drop-highlight);
}

.pos-designer__ghost--invalid {
    background: rgba(255, 0, 0, 0.15);
    border: 3px dashed red;
}

/* Item */
.pos-designer__item {
    position: relative;
    width: 100%;
    height: 100%;
    border: 3px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    font-size: 1.1rem;
    color: white;
    background: var(--pos-default-bg);
    touch-action: none;
    user-select: none;
    transition: opacity 120ms ease, box-shadow 120ms ease;
    box-sizing: border-box;
}

    .pos-designer__item:active {
        cursor: grabbing;
    }

.pos-designer__item--active {
    box-shadow: 0 0 0 3px var(--pos-active-glow), 0 4px 12px rgba(0,0,0,0.3);
    z-index: 2;
}

.pos-designer__item--dragging {
    opacity: 0.4;
    z-index: 1;
}

.pos-designer__item--inactive {
    opacity: 0.4;
    font-style: italic;
}

.pos-designer__item--rejected {
    animation: pos-reject-shimmer 500ms ease-out;
}

@keyframes pos-reject-shimmer {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }

    25% {
        box-shadow: 0 0 0 6px rgba(255, 0, 0, 0.7);
    }

    75% {
        box-shadow: 0 0 0 6px rgba(255, 0, 0, 0.4);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

.pos-designer__item-label {
    text-align: center;
    white-space: pre-wrap;
    padding: 0.25rem;
    pointer-events: none;
}

.pos-designer__resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    touch-action: none;
    z-index: 3;
    background: linear-gradient( 135deg, transparent 0%, transparent 40%, rgba(255,255,255,0.95) 40%, rgba(255,255,255,0.95) 50%, transparent 50%, transparent 65%, rgba(255,255,255,0.95) 65%, rgba(255,255,255,0.95) 75%, transparent 75% );
}

@media (pointer: coarse) {
    .pos-designer__resize-handle {
        width: 32px;
        height: 32px;
    }
}

/* ===== Hierarchie / Drilldown-Erweiterungen ===== */
/* Diese Klassen ergänzen das vorhandene Designer-Stylesheet — bitte einfach */
/* an das bestehende Designer-CSS anhängen (LayoutDesigner.razor.css oder    */
/* wwwroot/css/pos-designer.css, je nachdem wo dein Designer-CSS liegt).     */

/* Container-Tiles werden optisch abgesetzt — dickerer, gestrichelter Rand,  */
/* damit man auf einen Blick sieht: "das hier hat Inhalt".                   */
.pos-designer__item--container {
    border: 3px dashed rgba(0, 0, 0, 0.45);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* "→"-Button rechts oben auf Container-Tiles. Drilldown-Trigger.            */
.pos-designer__enter-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    z-index: 2;
}

    .pos-designer__enter-btn:hover {
        background: rgba(0, 0, 0, 0.75);
    }

/* Damit der Enter-Button absolut innerhalb des Items positioniert werden    */
/* kann, muss das Item selbst position:relative haben. Falls das in deinem   */
/* bestehenden Stylesheet noch nicht so ist, ergänzen:                       */
.pos-designer__item {
    position: relative;
}

/* ===== Breadcrumb über dem Designer/Grid ===== */
/* Wird in TischeSettingsPage/ArtikelSettingsPage (und Index.razor)          */
/* zwischen Toolbar und Designer gerendert.                                  */
.hierarchie-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 4px;
}

.hierarchie-pfad {
    font-weight: 600;
    font-size: 1.05em;
}

/* ------------------------------------------------------------------
   Desktop-Ansicht (Windows-Client): Artikel links, Bestellung rechts
   ------------------------------------------------------------------ */
.desktop-split {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.desktop-split__artikel {
    flex: 3 1 0;
    min-width: 0;
}

.desktop-split__bestellung {
    flex: 2 1 0;
    min-width: 0;
    /* bleibt beim Scrollen der Artikel stehen und scrollt bei Bedarf selbst */
    position: sticky;
    top: 0;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.desktop-split__leer {
    padding: 2rem 1rem;
    text-align: center;
    color: #888;
    border: 2px dashed #ccc;
    border-radius: 6px;
}

/* Trenner zwischen aktueller Bestellung und offenen Positionen */
.pos-trenner {
    margin: 0.75rem 0;
    border: 0;
    border-top: 3px solid #999;
    opacity: 1;
}

/* Belegübersicht */
.belege-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.belege-datum {
    width: 160px;
}

.belege-summe {
    margin-left: auto;
    font-weight: 600;
}

.belege-steuer td,
.belege-steuer th {
    text-align: right;
}

.belege-steuer td:first-child,
.belege-steuer th:first-child {
    text-align: left;
}

/* Rechnungslogo in den Mandanten-Einstellungen (halbe Druckbreite als Vorschau) */
.rechnung-logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.rechnung-logo img {
    max-width: 288px;
    border: 1px solid #ddd;
    background: white;
}

/* ============================================================================
 * Abrechnung (Kellnerabrechnung / Tagesabschluss)
 * ============================================================================ */
.abrechnung-leiste,
.abrechnung-aktionen {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

.abrechnung-kellner {
    min-width: 220px;
}

.abrechnung {
    max-width: 640px;
}

.abrechnung-zeitraum {
    margin-bottom: 8px;
    color: #555;
}

.abrechnung-tabelle td:last-child,
.abrechnung-tabelle th:last-child,
.abrechnung-tabelle td:nth-child(2),
.abrechnung-tabelle th:nth-child(2) {
    text-align: right;
}

.abrechnung-tabelle td:first-child,
.abrechnung-tabelle th:first-child {
    text-align: left;
}

.abrechnung-summe td {
    font-weight: bold;
}

.abrechnung-soll-zeile td,
.abrechnung-soll {
    font-weight: bold;
    font-size: 1.3em;
}

.abrechnung-warnung {
    margin: 8px 0;
    padding: 8px;
    border-left: 4px solid darkorange;
    background-color: #fff4e5;
}

.abrechnung-meldung {
    margin: 8px 0;
    padding: 8px;
    background-color: #eef6ff;
}

.abrechnung-diff {
    margin-top: 8px;
    font-weight: bold;
}

.abrechnung-diff--abweichung {
    color: red;
}

/* ============================================================================
 * Einstellungen
 * ============================================================================ */
.einstellungen-optionen {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Abhängige Optionen eingerückt unter ihrer Hauptoption */
.einstellungen-unteroptionen {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-left: 24px;
}

/* Vorschau/Fehler unter den Nummernformat-Feldern (Mandant) */
.nummernformat-hinweis {
    margin-top: 0.25rem;
    font-size: 0.9rem;
    line-height: 1.3;
}


/* RKSV-Reiter im Mandanten */
.rksv-zeile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.rksv-info,
.rksv-hinweis,
.rksv-warnung {
    margin-top: 6px;
}

.rksv-hinweis {
    font-size: 0.9em;
    opacity: 0.8;
}

.rksv-warnung {
    color: #b00020;
    font-weight: bold;
}

.rksv-pruefung {
    margin: 4px 0 0 0;
    padding-left: 20px;
    max-height: 240px;
    overflow-y: auto;
}

.rksv-meldedaten {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 8px;
    align-items: center;
    margin-top: 8px;
}

.einstellungen-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
