/**
 * ERP Module Styles
 * VoiceOne ERP System
 *
 * Uses Bootstrap 5 classes for consistency with other modules.
 */

/* ============================================================================
   ERP CONTAINER
   ============================================================================ */

.erp-container {
    padding: 0;
}

/* ============================================================================
   CONTACT SEARCH DROPDOWN - Must be above all other elements
   ============================================================================ */

#contact-search-results {
    z-index: 9999 !important;
    position: absolute !important;
    background-color: #fff !important;
}

/* The parent card needs higher z-index than sibling cards */
.erp-contact-search-card {
    position: relative !important;
    z-index: 100 !important;
    overflow: visible !important;
}

/* Allow overflow for all child elements */
.erp-contact-search-card .card-body,
.erp-contact-search-card .mb-3,
.erp-contact-search-card .position-relative {
    overflow: visible !important;
}

/* ============================================================================
   PRODUCT SEARCH DROPDOWN - For invoice item product selection
   ============================================================================ */

.product-search-cell {
    overflow: visible !important;
}

.product-search-results {
    z-index: 9999 !important;
}

.product-search-item:hover {
    background-color: #f8f9fa !important;
}

[data-theme="dark"] .product-search-results {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
}

[data-theme="dark"] .product-search-item:hover {
    background-color: #3d3d3d !important;
}

[data-theme="dark"] .product-search-item {
    border-bottom-color: #444 !important;
}

/* ============================================================================
   MODULE CARD ITEMS - Hover effects for module navigation cards
   ============================================================================ */

.module-card-item {
    transition: all 0.2s ease;
    border: 1px solid rgba(0,0,0,0.1);
}

.module-card-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #98b8cc;
}

/* ============================================================================
   SUMMARY CARDS - Stats cards at top of modules
   ============================================================================ */

#inventory-summary .card,
#dunning-summary .card {
    border-radius: 8px;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Ensure Bootstrap background colors are applied - override gradient from styles.css */
#inventory-summary .card.bg-primary,
#dunning-summary .card.bg-primary {
    background: #0d6efd !important;
}

#inventory-summary .card.bg-danger,
#dunning-summary .card.bg-danger {
    background: #dc3545 !important;
}

#inventory-summary .card.bg-warning,
#dunning-summary .card.bg-warning {
    background: #ffc107 !important;
}

#inventory-summary .card.bg-success,
#dunning-summary .card.bg-success {
    background: #198754 !important;
}

#inventory-summary .card.bg-info,
#dunning-summary .card.bg-info {
    background: #0dcaf0 !important;
}

#inventory-summary .card.bg-secondary,
#dunning-summary .card.bg-secondary {
    background: #6c757d !important;
}

#inventory-summary .card h3,
#dunning-summary .card h3 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* Force white text on colored cards - high specificity */
#inventory-summary .card.bg-primary h3,
#inventory-summary .card.bg-primary small,
#inventory-summary .card.bg-danger h3,
#inventory-summary .card.bg-danger small,
#inventory-summary .card.bg-success h3,
#inventory-summary .card.bg-success small,
#inventory-summary .card.bg-info h3,
#inventory-summary .card.bg-info small,
#inventory-summary .card.bg-secondary h3,
#inventory-summary .card.bg-secondary small,
#dunning-summary .card.bg-primary h3,
#dunning-summary .card.bg-primary small,
#dunning-summary .card.bg-danger h3,
#dunning-summary .card.bg-danger small,
#dunning-summary .card.bg-success h3,
#dunning-summary .card.bg-success small,
#dunning-summary .card.bg-info h3,
#dunning-summary .card.bg-info small,
#dunning-summary .card.bg-secondary h3,
#dunning-summary .card.bg-secondary small {
    color: #ffffff !important;
}

/* Dark text for warning cards */
#inventory-summary .card.bg-warning h3,
#inventory-summary .card.bg-warning small,
#dunning-summary .card.bg-warning h3,
#dunning-summary .card.bg-warning small {
    color: #212529 !important;
}

#inventory-summary .card small,
#dunning-summary .card small {
    font-size: 0.8rem;
    opacity: 0.9;
}

#inventory-summary .card-body,
#dunning-summary .card-body {
    padding: 1rem;
    background: transparent !important;
    border-radius: 8px;
}

/* Ensure text colors inherit properly */
#inventory-summary .card.bg-primary,
#inventory-summary .card.bg-danger,
#inventory-summary .card.bg-success,
#inventory-summary .card.bg-info,
#inventory-summary .card.bg-secondary,
#dunning-summary .card.bg-primary,
#dunning-summary .card.bg-danger,
#dunning-summary .card.bg-success,
#dunning-summary .card.bg-info,
#dunning-summary .card.bg-secondary {
    color: #ffffff !important;
}

#inventory-summary .card.bg-warning,
#dunning-summary .card.bg-warning {
    color: #212529 !important;
}

/* ============================================================================
   HEADER STYLING
   ============================================================================ */

.erp-container > .d-flex {
    flex-wrap: wrap;
    gap: 1rem;
}

.erp-container > .d-flex h4 {
    font-weight: 600;
    color: #333;
}

.erp-container > .d-flex .btn-group {
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* ============================================================================
   TABLE STYLING
   ============================================================================ */

/* Table container for horizontal scroll on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#inventory-table,
#dunning-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

#inventory-table th,
#dunning-table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #666;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    padding: 0.5rem 0.4rem;
}

#inventory-table td,
#dunning-table td {
    vertical-align: middle;
    padding: 0.5rem 0.4rem;
    font-size: 0.9rem;
}

/* Column width hints */
#inventory-table th:nth-child(1),
#inventory-table td:nth-child(1) { width: 80px; } /* SKU */

#inventory-table th:nth-child(2),
#inventory-table td:nth-child(2) { min-width: 150px; } /* Produkt */

#inventory-table th:nth-child(3),
#inventory-table td:nth-child(3) { width: 100px; } /* Kategorie */

#inventory-table th:nth-child(4),
#inventory-table th:nth-child(5),
#inventory-table th:nth-child(6),
#inventory-table td:nth-child(4),
#inventory-table td:nth-child(5),
#inventory-table td:nth-child(6) { width: 60px; text-align: right; } /* Bestand, Min, Max */

#inventory-table th:nth-child(7),
#inventory-table td:nth-child(7) { width: 100px; } /* Lagerort */

#inventory-table th:nth-child(8),
#inventory-table td:nth-child(8) { width: 90px; } /* Status */

#inventory-table th:nth-child(9),
#inventory-table td:nth-child(9) { width: 120px; white-space: nowrap; } /* Aktionen */

#inventory-table .btn-group-sm .btn,
#dunning-table .btn-group-sm .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}

/* Invoice LIST table specific column widths (not invoice-items-table) */
#invoices-list .table th:nth-child(1),
#invoices-list .table td:nth-child(1) { width: 100px; } /* Nummer */

#invoices-list .table th:nth-child(2),
#invoices-list .table td:nth-child(2) { min-width: 200px; } /* Kunde */

#invoices-list .table th:nth-child(3),
#invoices-list .table td:nth-child(3) { width: 80px; text-align: right; } /* Betrag */

#invoices-list .table th:nth-child(4),
#invoices-list .table td:nth-child(4) { width: 90px; } /* Status */

#invoices-list .table th:nth-child(5),
#invoices-list .table td:nth-child(5) { width: 100px; } /* Fällig */

/* Actions column in invoice list - ensure all 6 buttons are visible */
#invoices-list .table th:nth-child(6),
#invoices-list .table td:nth-child(6) {
    min-width: 240px;
    width: 240px;
    white-space: nowrap;
}

/* Header action buttons - normal size */
.erp-container > .d-flex .btn-group .btn,
.erp-container .card-header .btn-group .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Table action buttons - compact size */
.erp-container .table .btn-group {
    flex-wrap: nowrap;
    display: inline-flex;
    gap: 1px;
}

.erp-container .table .btn-group .btn {
    padding: 0.15rem 0.3rem;
    font-size: 0.7rem;
}

.erp-container .table .btn-group-sm {
    flex-wrap: nowrap !important;
}

/* ============================================================================
   STATUS BADGES
   ============================================================================ */

.badge {
    font-weight: 500;
    padding: 0.4em 0.6em;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    #inventory-summary .col-md-3,
    #dunning-summary .col-md-3,
    #dunning-summary .col-md-2 {
        margin-bottom: 0.5rem;
    }

    #inventory-summary .card h3,
    #dunning-summary .card h3 {
        font-size: 1.25rem;
    }

    .erp-container > .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .erp-container > .d-flex .btn-group {
        width: 100%;
        justify-content: flex-start;
    }

    .erp-container > .d-flex .btn-group .btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.5rem;
    }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

[data-theme="dark"] .module-card-item {
    border-color: rgba(255,255,255,0.1);
    background: #2d2d2d;
}

[data-theme="dark"] .module-card-item:hover {
    border-color: #98b8cc;
}

[data-theme="dark"] .erp-container > .d-flex h4 {
    color: #e0e0e0;
}

[data-theme="dark"] #inventory-summary .card,
[data-theme="dark"] #dunning-summary .card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="dark"] #inventory-table th,
[data-theme="dark"] #dunning-table th {
    color: #aaa;
    border-bottom-color: #444;
}

[data-theme="dark"] #inventory-table,
[data-theme="dark"] #dunning-table {
    color: #e0e0e0;
}

[data-theme="dark"] .table-warning {
    background-color: rgba(255, 193, 7, 0.15) !important;
}

[data-theme="dark"] .table-danger {
    background-color: rgba(220, 53, 69, 0.15) !important;
}

/* ============================================================================
   MOVEMENT TYPE BADGES
   ============================================================================ */

.badge.bg-success {
    background-color: #198754 !important;
}

.badge.bg-danger {
    background-color: #dc3545 !important;
}

.badge.bg-info {
    background-color: #0dcaf0 !important;
    color: #000;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000;
}

/* ============================================================================
   CARD IMPROVEMENTS
   ============================================================================ */

.card {
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    font-weight: 600;
}

[data-theme="dark"] .card {
    background-color: #2d2d2d;
    border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .card-header {
    background-color: #333;
    border-bottom-color: rgba(255,255,255,0.1);
}
