﻿/* =========================================
   TABLE.CSS
   Einheitliche Tabellen + Mobile Cards
   ========================================= */

/* ===============================
   PAGE LAYOUT HELPERS
================================= */

.page-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    color: #243243;
}

.page-subtitle {
    margin: 0.25rem 0 0;
    color: #5f7288;
    font-size: 0.95rem;
}

/* ===============================
   TABLE SHELL
================================= */

.table-shell {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.table-responsive-modern {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-modern {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 920px;
    vertical-align: middle;
    background: transparent;
}

    .table-modern.table-modern-narrow {
        min-width: 0;
    }

    .table-modern thead th {
        background: rgba(255, 255, 255, 0.65);
        color: #243243;
        font-size: 0.95rem;
        font-weight: 800;
        white-space: nowrap;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
        padding: 14px 16px;
    }

    .table-modern tbody td,
    .table-modern tfoot td {
        padding: 14px 16px;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
        color: #243243;
        background: transparent;
        vertical-align: top;
    }

    .table-modern tbody tr:last-child td {
        border-bottom: none;
    }

    .table-modern .btn.btn-light.btn-sm {
        font-weight: 700;
        border-radius: 10px;
    }

    .table-modern tbody tr.inventar-low-stock-row > td {
        background: #fff3cd !important;
        color: #2f2500 !important;
        border-top: 2px solid #f59e0b !important;
        border-bottom: 2px solid #f59e0b !important;
        box-shadow: none !important;
    }

    .table-modern tbody tr.inventar-low-stock-row > td:first-child {
        border-left: 6px solid #f59e0b !important;
    }

    .table-modern tbody tr.inventar-low-stock-row > td:last-child {
        border-right: 2px solid #f59e0b !important;
    }

.inventar-low-stock-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    background: #f59e0b;
    color: #2f2500;
}

.mobile-record-card.inventar-low-stock-card {
    border: 2px solid #f59e0b;
    background: #fff7df;
}

    .mobile-record-card.inventar-low-stock-card .mobile-record-type {
        background: #f59e0b;
        color: #2f2500;
    }

.inventory-name-cell {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.inventory-thumb {
    display: block;
    width: 38px !important;
    height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    min-width: 38px;
    min-height: 38px;
    flex: 0 0 38px;
    border-radius: 6px;
    object-fit: contain;
    border: 1px solid #d7dee8;
    background: #f8fafc;
}

.inventory-image-editor {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #f8fafc;
}

.inventory-image-preview {
    width: 88px;
    height: 88px;
    flex: 0 0 88px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #d7dee8;
    background: #fff;
}

.inventory-image-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.inventory-mapping-box {
    padding: 12px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #f8fafc;
}

.inventory-mapping-amount {
    max-width: 160px;
}

.inventory-label-with-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.inventory-info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 3px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
}

.inventory-info-button:hover,
.inventory-info-button:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.14);
    outline: none;
}

.inventory-info-button img {
    display: block;
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    object-fit: contain;
}

.inventory-movement-info {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 0.88rem;
}

.inventory-movement-info-row {
    display: grid;
    grid-template-columns: minmax(130px, 0.42fr) 1fr;
    gap: 10px;
}

.inventory-movement-info-row strong {
    color: #1f2937;
}

.inventory-movement-info-row span {
    color: #4b5563;
}

/* ===============================
   TABLE ACTIONS / BADGES / STACKS
================================= */

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

    .table-actions .btn,
    .table-actions a.btn {
        white-space: nowrap;
    }

.table-badge-muted {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.08);
    color: #4b5d73;
}

.table-list-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.table-empty {
    color: #6b7a8d;
    font-style: italic;
}

/* ===============================
   MOBILE RECORD CARDS
================================= */

.mobile-record-list {
    display: none;
}

.mobile-record-card {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    margin-bottom: 12px;
}

    .mobile-record-card:last-child {
        margin-bottom: 0;
    }

.mobile-record-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.mobile-record-title {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.25;
    color: #243243;
}

.mobile-record-type {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
    background: rgba(22, 119, 255, 0.10);
    color: #0f62d6;
}

.mobile-record-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.mobile-record-field {
    min-width: 0;
}

.mobile-record-field--full {
    grid-column: 1 / -1;
}

.mobile-record-label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6b7a8d;
}

.mobile-record-value {
    color: #243243;
    word-break: break-word;
}

.mobile-record-media {
    margin-top: 10px;
    margin-bottom: 12px;
}

    .mobile-record-media img {
        width: 100%;
        max-height: 180px;
        object-fit: cover;
        border-radius: 12px;
        display: block;
    }

/* ===============================
   FORM / MODAL HELPERS
================================= */

.table-form-card {
    border-radius: 20px;
    border: 1px solid rgba(15, 23, 42, 0.10);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.10);
    background: rgba(255, 255, 255, 0.86);
}

.table-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.table-preview-image {
    max-width: min(360px, 100%);
    max-height: 240px;
    border-radius: 12px;
    display: block;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
}

/* ===============================
   DETAILS / SUMMARY
================================= */

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.detail-label {
    font-weight: 700;
    color: #4b5d73;
    min-width: 110px;
    display: inline-block;
}

.detail-value {
    color: #243243;
}

.rechnungs-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.rechnungs-summary-label {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6b7a8d;
}

.rechnungs-summary-card--total {
    background: rgba(22, 119, 255, 0.08);
    border-color: rgba(22, 119, 255, 0.16);
}

/* ===============================
   STATISTIK CHARTS
================================= */

.stat-chart,
.stat-product-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-chart--daily {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.stat-bar-row {
    display: grid;
    grid-template-columns: minmax(72px, 112px) minmax(120px, 1fr) minmax(88px, auto);
    gap: 0.75rem;
    align-items: center;
}

.stat-bar-label,
.stat-product-name {
    min-width: 0;
    color: #243243;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-bar-value,
.stat-product-meta {
    color: #4b5d73;
    font-size: 0.9rem;
    text-align: right;
    white-space: nowrap;
}

.stat-bar-track,
.stat-product-bar {
    min-width: 0;
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
}

.stat-bar-fill,
.stat-product-fill {
    min-width: 3px;
    height: 100%;
    border-radius: inherit;
}

.stat-bar-fill--revenue {
    background: #1677ff;
}

.stat-bar-fill--payment {
    background: #16a34a;
}

.stat-product-row {
    display: grid;
    grid-template-columns: minmax(160px, 260px) minmax(160px, 1fr) minmax(110px, auto);
    gap: 0.75rem;
    align-items: center;
}

.stat-product-fill {
    background: #f59e0b;
}

.stat-product-meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* ===============================
   ORTE & TISCHE COMBINED VIEW
================================= */

.ort-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.ort-card {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 20px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.ort-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.55);
}

.ort-card-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.ort-card-title {
    margin: 0;
    font-size: 1.15rem;
    color: #243243;
}

.ort-card-meta {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.ort-card-count {
    color: #5f7288;
    font-size: 0.9rem;
    font-weight: 600;
}

.ort-card-body {
    padding: 1rem;
}

.ort-layout-preview {
    position: relative;
    width: 100%;
    min-height: 260px;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(0,0,0,.08);
    background: rgba(0,0,0,.03);
}

.ort-layout-preview-svg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

    .ort-layout-preview-svg svg {
        width: 100%;
        height: 100%;
        display: block;
    }

.ort-layout-preview-empty {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    background: linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px), linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px);
    background-size: 32px 32px;
}

.ort-layout-preview-table {
    position: absolute;
    z-index: 2;
    transform: translate(-50%, -50%);
    border-radius: 14px;
    border: 1px solid rgba(25,135,84,.35);
    background: rgba(25,135,84,.16);
    color: #14532d;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px;
}

    .ort-layout-preview-table.round {
        border-radius: 999px;
    }

    .ort-layout-preview-table.draggable {
        cursor: grab;
        user-select: none;
        touch-action: none;
    }

        .ort-layout-preview-table.draggable:active {
            cursor: grabbing;
            transform: translate(-50%, -50%) scale(1.04);
        }

/* ===============================
   SCROLLBAR
================================= */

.table-responsive-modern::-webkit-scrollbar {
    height: 8px;
}

.table-responsive-modern::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.18);
    border-radius: 999px;
}

.table-responsive-modern::-webkit-scrollbar-track {
    background: transparent;
}

/* ===============================
   Rollen & Berechtigungen
================================= */

.role-permission-checkbox {
    transform: scale(1.1);
    cursor: pointer;
}

    .role-permission-checkbox:disabled {
        cursor: not-allowed;
        opacity: 0.6;
    }

/* ===============================
   Berichte
================================= */

.report-type-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
/* ===============================
   MOBILE
================================= */

@media (max-width: 900px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

        .page-header .btn {
            width: 100%;
        }

    .table-shell.mobile-cards .table-responsive-modern {
        display: none;
    }

    .table-shell.mobile-cards .mobile-record-list {
        display: block;
        padding: 12px;
    }

    .mobile-record-grid {
        grid-template-columns: 1fr;
    }

    .table-form-card {
        padding: 16px !important;
    }

    .table-form-actions .btn {
        flex: 1 1 auto;
        min-width: 140px;
    }

    .table-actions {
        flex-direction: column;
    }

        .table-actions .btn,
        .table-actions a.btn {
            width: 100%;
        }

    .detail-label {
        display: block;
        margin-bottom: 0.15rem;
    }

    .ort-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .report-type-bar .btn {
        width: 100%;
    }

    .stat-bar-row,
    .stat-product-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .stat-bar-value,
    .stat-product-meta {
        text-align: left;
    }

    .stat-product-meta {
        flex-direction: row;
        justify-content: space-between;
    }
}
