:root {
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --text-main: #334155;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.5;
    overflow-x: hidden;
}

.container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

/* Dashboard Grid */
.order-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.order-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.order-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.order-id {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--accent);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-info {
    background: #e0f2fe;
    color: #0369a1;
}

.status-success {
    background: #dcfce7;
    color: #15803d;
}

.status-produktion {
    background: #fef9c3;
    color: #a16207;
}

.status-urgent {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

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

.order-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* Detail Panel (Slide-over) */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.detail-overlay.active {
    opacity: 1;
    visibility: visible;
}

.detail-panel {
    position: fixed;
    top: 0;
    right: -750px;
    width: 100%;
    max-width: 750px;
    height: 100vh;
    background: var(--bg-color);
    border-left: 1px solid var(--border);
    z-index: 101;
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.detail-panel.active {
    right: 0;
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.address-box {
    background: rgba(0, 0, 0, 0.02);
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
}

.item-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.item-qty {
    color: var(--accent);
    font-weight: 700;
    margin-right: 1rem;
}

/* Role Selection Landing Page */
.role-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 4rem;
}

.role-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    width: 250px;
}

.role-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
    background: #f8fafc;
}

.role-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.role-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Blocker Styling */
.blocker-banner {
    background: repeating-linear-gradient(45deg,
            rgba(239, 68, 68, 0.1),
            rgba(239, 68, 68, 0.1) 10px,
            rgba(239, 68, 68, 0.2) 10px,
            rgba(239, 68, 68, 0.2) 20px);
    border: 1px solid var(--danger);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    color: #f87171;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.order-card.blocked {
    border-color: var(--danger);
    opacity: 0.8;
}

.order-card.finished {
    opacity: 0.5;
    background: #f8fafc;
}

.order-card.finished:hover {
    opacity: 0.8;
}

.hidden {
    display: none !important;
}

/* Input styles for packaging */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 0.25rem;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
    font-family: inherit;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
/* History / Verlauf Styling */
.history-item {
    border-left: 1px solid var(--border);
    padding-left: 1.25rem;
    padding-bottom: 1.5rem;
    position: relative;
}

.history-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.history-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.history-event {
    font-size: 0.875rem;
    color: var(--text-main);
    line-height: 1.4;
}

/* Kanal Badges */
.kanal-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

.kanal-shopify { background: #95bf47; color: #fff; }
.kanal-ebay { background: #0064d2; color: #fff; }
.kanal-kleinanzeigen { background: #86b817; color: #fff; }
.kanal-unknown { background: var(--border); color: var(--text-muted); }


/* Laufzeit Indikator */
.runtime-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

.age-green { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.age-yellow { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
.age-red { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.age-darkred { background: #fef2f2; color: #991b1b; border: 1px solid #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.2); }

/* Help Modal */
.help-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 95%;
    max-width: 700px;
    max-height: 90vh;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    z-index: 101;
    padding: 2.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.help-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.flowchart-container {
    background: rgba(0, 0, 0, 0.03);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.flowchart-container svg {
    max-width: 100%;
    height: auto;
}

/* SVG Flowchart Elements */
.node {
    fill: #ffffff;
    stroke: var(--border);
    stroke-width: 1px;
}

.highlight-shipping {
    stroke: var(--accent);
    fill: rgba(249, 115, 22, 0.1);
}

.highlight-pickup {
    stroke: #a855f7;
    fill: rgba(168, 85, 247, 0.1);
}

.text {
    fill: var(--text-main);
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
}

.arrow {
    stroke: var(--border);
    stroke-width: 1.5px;
    fill: none;
    marker-end: url(#arrowhead);
}

/* Indicators */
.comment-badge-inline {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(4px);
}

/* Blocker Dot remains absolute as a red flag */
.blocker-dot {
    position: absolute;
    top: 1rem;
    right: 1.5rem; /* Slightly shifted left so it's not on the very edge */
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    z-index: 10;
}

/* --- Print Styles --- */
@media print {
    @page {
        size: auto;
        margin: 15mm 10mm 15mm 10mm;
    }

    /* Hide ALL top-level elements except the detail panel when not in accounting view */
    body:not(.in-accounting-view) > *:not(#detailPanel) {
        display: none !important;
    }

    /* Hide ALL top-level elements except the accounting screen when in accounting view */
    body.in-accounting-view > *:not(#accountingScreen) {
        display: none !important;
    }

    /* Reset body and html for clean print */
    html, body {
        height: auto !important;
        overflow: visible !important;
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Format the detail panel for paper */
    #detailPanel {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 20px !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        transform: none !important;
        border: none !important;
        transition: none !important;
    }

    /* Format the accounting screen for paper */
    body.in-accounting-view #accountingScreen {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 20px !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Wrapper card for the table - prevent scrolling/truncating */
    body.in-accounting-view .card {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        position: static !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* Visual cleanup for paper (High contrast, no shadows) */
    .detail-section {
        background: none !important;
        border: 1px solid #eee !important;
        padding: 1.5rem !important;
        margin-bottom: 2rem !important;
        page-break-inside: avoid;
    }

    .address-box, .item-row {
        background: none !important;
        border-color: #f0f0f0 !important;
        color: black !important;
    }

    h1, h2, h3, div, span, strong, p {
        color: black !important;
    }

    .status-badge {
        border: 1px solid black !important;
        background: none !important;
        color: black !important;
        font-weight: bold !important;
    }

    /* Print header for accounting screen */
    body.in-accounting-view .print-only-header {
        display: block !important;
    }

    /* Hide specific UI buttons, toggles, controls, and headers from print */
    .no-print,
    .close-btn, 
    .btn, 
    .form-group, 
    hr, 
    #overlay,
    .kanal-badge,
    #orderHistorySection,
    img:not(.qr-code-img),
    input,
    select,
    textarea,
    #accountingScreen header,
    #accountingScreen div[style*="display: flex; gap: 1rem; align-items: center; justify-content: space-between;"],
    #accountingScreen div[style*="display: flex; background: rgba"] {
        display: none !important;
    }

    /* Hide the checkbox column from the accounting table printout */
    body.in-accounting-view #accountingTable .checkbox-col {
        display: none !important;
    }

    /* Hide the original article name column in summary print view */
    body.in-accounting-view #accountingTable .summary-article-col {
        display: none !important;
    }

    /* High contrast table styling for accounting - optimized for portrait A4 */
    body.in-accounting-view #accountingTable {
        width: 100% !important;
        border-collapse: collapse !important;
        color: black !important;
        margin-top: 1rem !important;
        font-size: 11px !important;
    }

    body.in-accounting-view #accountingTable tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    body.in-accounting-view #accountingTable th,
    body.in-accounting-view #accountingTable td {
        border-bottom: 1px solid #cbd5e1 !important;
        padding: 6px 5px !important;
        color: black !important;
        background: transparent !important;
        text-align: left !important;
    }

    body.in-accounting-view #accountingTable th {
        font-weight: bold !important;
        border-bottom: 2px solid #000 !important;
    }

    /* Preserve text alignments */
    body.in-accounting-view #accountingTable td[style*="text-align: right"],
    body.in-accounting-view #accountingTable th[style*="text-align: right"] {
        text-align: right !important;
    }

    /* Ensure comments are visible and clean */
    #commentList {
        display: block !important;
    }
    
    .comment-item {
        border-left: 2px solid #ccc !important;
        margin-bottom: 10px !important;
        padding-left: 10px !important;
    }

    /* Fix QR Code visibility and layout in browser print/PDF views */
    .qr-code-container {
        display: block !important;
        text-align: center !important;
        background: #ffffff !important;
        border: 1px solid #e5e5e5 !important;
        padding: 8px !important;
        border-radius: 8px !important;
        width: 110px !important;
        margin-top: 10px !important;
        float: right !important;
        page-break-inside: avoid !important;
    }
    
    .qr-code-img {
        display: block !important;
        width: 80px !important;
        height: 80px !important;
        margin: 0 auto 4px auto !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}
