body { font-family: sans-serif; margin: 30px; background-color: #f9f9f9; color: #333; }
h2 { border-bottom: 2px solid #333; padding-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
h3 { margin-top: 20px; margin-bottom: 10px; color: #555; }

/* Obere Eingabefelder */
.meta-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}
.meta-field label { display: block; font-weight: bold; font-size: 12px; margin-bottom: 5px; text-transform: uppercase; color: #666; }
.meta-field input, .meta-field select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; }

input:disabled, select:disabled { background-color: #f1f1f1; color: #555; cursor: not-allowed; border-color: #ddd; }
.action-bar { margin-bottom: 30px; display: flex; gap: 10px; }

/* Buttons */
.btn { padding: 10px 20px; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; font-weight: bold; }
.btn-edit { background-color: #ffc107; color: #212529; }
.btn-add { background-color: #17a2b8; color: white; text-decoration: none; display: inline-block; text-align: center; line-height: 20px; }
.btn-submit { background-color: #28a745; color: white; font-size: 16px; padding: 12px 24px; }
.btn:hover { opacity: 0.9; }

/* Grid Tabelle */
.table-container { overflow-x: auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
table { border-collapse: collapse; width: 100%; }
th, td { border: 2px solid #555555; padding: 6px; text-align: center; }
th { background-color: #f2f2f2; font-size: 13px; font-weight: bold; }
.length-header { font-weight: bold; background-color: #f2f2f2; min-width: 40px; }

.grid-input {
    width: 40px;
    text-align: center;
    border: 1px solid #eee;
    padding: 4px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 4px;
    box-sizing: border-box;
    text-shadow: 0 0 3px rgba(255,255,255,0.8), 0 0 5px rgba(255,255,255,0.6);
}
.grid-input:focus { background-color: #e6f7ff; border-color: #1890ff; outline: none; }
.grid-input::-webkit-outer-spin-button, .grid-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.total-cell { background-color: #fcfcfc; font-weight: bold; color: #444; }

/* Kräftiges, gut sichtbares Königsblau für das Achsen-Highlight */
.grid-highlight-axis {
    background-color: #0056b3 !important;
    color: #ffffff !important;
}

.thumbnail-container {
    width: 60px;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f1f1;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
}
.table-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}
.table-thumb:hover {
    transform: scale(1.1);
}
.no-thumb {
    font-size: 20px;
    color: #888;
}

.hide-row { display: none !important; }
.hide-col { display: none !important; }

/* Schwebende Plus/Minus-Leiste */
.stepper-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    gap: 15px;
    z-index: 2000;
}
.stepper-info { font-size: 13px; font-weight: bold; min-width: 80px; text-align: center; }
.stepper-btn {
    width: 40px; height: 40px; border-radius: 50%; border: none; font-size: 20px; font-weight: bold;
    cursor: pointer; display: flex; align-items: center; justify-content: center; user-select: none;
}
.btn-minus { background-color: #dc3545; color: white; }
.btn-plus { background-color: #28a745; color: white; }
.stepper-btn:active { opacity: 0.8; transform: scale(0.95); }

summary::-webkit-details-marker { display: none; }
summary { display: block; }

/* Erzwingt tiefschwarzen Text auf iPads/iPhones bei gesperrten Feldern */
.meta-container input:disabled, 
.meta-container select:disabled {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    opacity: 1 !important;
    background-color: #f5f5f5 !important;
    border: 1px solid #888888 !important;
}

/* --- BOXEN-MANAGER --- */
.box-manager-container {
    background-color: #f8f9fa;
    border: 2px solid #555555;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.box-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
    align-items: center;
}

.box-card {
    display: flex;
    align-items: center;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    height: 32px;
}

.box-card.active {
    border-color: #1890ff !important;
    transform: scale(1.4);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

/* ============================================================
   IPAD/IPHONE FIX: Box-Input und Trash-Symbol sichtbar machen
   ============================================================ */
.box-number-input {
    border: none !important;
    padding: 0 2px;
    font-size: 16px;
    font-weight: bold;
    width: 35px;
    height: 100%;
    text-align: center;
    background: transparent !important;
    color: inherit !important;
    -webkit-text-fill-color: inherit !important;
    opacity: 1 !important;
}

/* Trash-Button – explizit farbig machen */
.delete-box-btn {
    color: inherit !important;
    opacity: 1 !important;
    -webkit-text-fill-color: inherit !important;
}

.box-counter {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 6px;
    font-size: 12px;
    font-weight: bold;
    user-select: none;
    background-color: transparent !important;
    color: inherit !important;
    white-space: nowrap;
}

.box-color-picker-fixed {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 100%;
    background-color: #444444 !important;
    color: #ffffff !important;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    border-left: 1px solid rgba(255,255,255,0.2);
}

.box-color-picker-fixed:hover {
    background-color: #555555 !important;
}

.box-color-picker-fixed input[type="color"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0 !important;
    cursor: pointer;
    padding: 0;
    border: none;
}

/* iPad-Fix: Verhindert Ausgrauen der Box-Nummern und des Trash-Symbols */
.box-card .box-number-input,
.box-card .box-number-input:disabled {
    color: inherit !important;
    -webkit-text-fill-color: inherit !important;
    background-color: transparent !important;
    opacity: 1 !important;
}

.box-card .box-counter {
    background-color: transparent !important;
    color: inherit !important;
}

/* Trash-Symbol explizit sichtbar machen */
.delete-box-btn {
    color: inherit !important;
    opacity: 1 !important;
    -webkit-text-fill-color: inherit !important;
}

.table-container td {
    position: relative;
}

.grid-split-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    pointer-events: none;
    z-index: 5;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    padding: 0 2px;
    line-height: 1;
}

.popover-qty-input {
    width: 50px;
    padding: 3px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}
.popover-qty-input:focus {
    border-color: #1890ff;
    outline: none;
}

#multi-box-popover {
    display: none;
    position: fixed;
    z-index: 9999;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    padding: 12px;
    min-width: 160px;
    box-sizing: border-box;
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #eeeeee;
    padding-bottom: 6px;
}

.popover-header h4 {
    margin: 0;
    font-size: 13px;
    color: #333333;
    font-weight: bold;
}

.close-popover-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #999999;
    padding: 0 4px;
    line-height: 1;
}
.close-popover-btn:hover {
    color: #333333;
}

.popover-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.popover-box-input {
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    text-align: center;
    outline: none;
}
.popover-box-input:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 4px rgba(74, 144, 226, 0.4);
}

.btn-save-popover {
    width: 100%;
    background-color: #2e7d32;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.2s;
}
.btn-save-popover:hover {
    background-color: #1b5e20;
}

/* ============================================================
   GLOBALER iOS/iPad FIX für alle ausgegrauten Elemente
   ============================================================ */
* {
    -webkit-text-fill-color: inherit !important;
    opacity: 1 !important;
}

/* Nur für Elemente, die wirklich ausgegraut sein sollen (disabled) */
input:disabled,
select:disabled,
button:disabled {
    opacity: 0.6 !important;
    -webkit-text-fill-color: #666666 !important;
}

/* Aber Box-Inputs und Lösch-Buttons sollen NICHT ausgegraut sein */
.box-card .box-number-input:disabled,
.box-card .delete-box-btn {
    opacity: 1 !important;
    -webkit-text-fill-color: inherit !important;
}

/* Split-Info-Popover */
#splitInfoPopover {
    font-family: sans-serif;
    pointer-events: auto;
}
#splitInfoPopover button {
    line-height: 1;
}

/* ============================================================
   BILDER-GALERIE
   ============================================================ */
.pictures-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    min-height: 60px;
    padding: 8px 0;
}

.picture-thumb {
    position: relative;
    width: 120px;
    height: 150px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #ddd;
    background: #f5f5f5;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    user-select: none;
}

.picture-thumb:hover {
    border-color: #1890ff;
    transform: scale(1.03);
}

.picture-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.preview-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: #1890ff;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

.no-pictures-hint {
    color: #999;
    font-style: italic;
    font-size: 13px;
    margin: 0;
}

.pictures-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.url-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 250px;
}

.url-input-group input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}

.url-spinner {
    font-size: 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.url-preview-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
    display: flex;
    gap: 15px;
    align-items: center;
}

.url-preview-box img {
    max-width: 120px;
    max-height: 150px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.url-preview-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================
   BILD-VIEWER
   ============================================================ */
.picture-viewer {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.picture-viewer img {
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.viewer-close {
    position: absolute;
    top: 20px; right: 20px;
    background: #ff4d4f;
    color: #fff;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    font-weight: bold;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.85);
    color: #333;
    border: none;
    width: 50px; height: 70px;
    font-size: 32px;
    cursor: pointer;
    border-radius: 6px;
    font-weight: bold;
    line-height: 1;
}
.viewer-nav:hover { background: #fff; }
.viewer-prev { left: 20px; }
.viewer-next { right: 20px; }

.viewer-counter {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 14px;
    border-radius: 20px;
}

/* ============================================================
   KONTEXTMENÜ
   ============================================================ */
.context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 4px 0;
    z-index: 10001;
    min-width: 160px;
}

.context-menu-item {
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.context-menu-item:hover {
    background: #f0f0f0;
}

/* Anzahl Bilder als Overlay auf dem Thumbnail */
.picture-count-overlay {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    line-height: 1.2;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
}

/* ============================================================
   INVENTORY OVERVIEW
   ============================================================ */
.warehouse-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}
.warehouse-image-wrapper {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    background: #f0f0f0;
}
.warehouse-image-wrapper img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}
.kpi-tile {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.kpi-value {
    font-size: 26px;
    font-weight: bold;
    color: #1890ff;
    margin-bottom: 6px;
}
.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    letter-spacing: 0.5px;
}

.overview-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}
@media (max-width: 700px) {
    .overview-columns { grid-template-columns: 1fr; }
    .warehouse-images { grid-template-columns: 1fr; }
}

.overview-box {
    background: #fff;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 15px;
}
.overview-box h3 {
    margin-top: 0;
    font-size: 15px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
    font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }

.featured-brands {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}
.featured-brand-card {
    background: #fff;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-top: 4px solid #1890ff;
}
.featured-brand-card h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #1890ff;
}
.featured-total {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
}
.featured-total span {
    font-size: 13px;
    font-weight: normal;
    color: #666;
}
.featured-detail {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #555;
    margin-bottom: 10px;
}
.featured-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.featured-table td {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}
.featured-table td:last-child {
    text-align: right;
    color: #1890ff;
    font-weight: bold;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 10px;
}
.mini-table td {
    padding: 3px 6px;
    border-bottom: 1px solid #f0f0f0;
}
.mini-table td:nth-child(2), .mini-table td:nth-child(3) {
    text-align: right;
}

.scroll-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.brand-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.brand-table th {
    background: #f5f5f5;
    padding: 8px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-size: 12px;
    text-transform: uppercase;
    color: #555;
}
.brand-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}
.brand-table tbody tr:hover {
    background: #fafafa;
}

/* Print-Ansicht */
@media print {
    .no-print, .action-bar, h2 .btn, .btn { display: none !important; }
    body { background: #fff !important; margin: 0; padding: 15px; }
    .kpi-tile, .overview-box, .featured-brand-card {
        box-shadow: none !important;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    .overview-columns, .featured-brands { gap: 10px; }
    h2 { border-bottom: 2px solid #000; }
}

.chart-donut-wrapper {
    max-width: 200px;
    margin: 10px auto 0;
}

/* ============================================================
   VIEWER-MODUS
   ============================================================ */
body.viewer-mode .admin-only {
    display: none !important;
}
body:not(.viewer-mode) .viewer-only {
    display: none !important;
}

body.viewer-mode .grid-input {
    pointer-events: none;
    background-color: #f5f5f5;
}

