/* ============================================================================
   InvoicePlus Plugin Styles
   ============================================================================ */

/* Settings Page Layout Override - Sicherstellen dass Settings-Menü sichtbar bleibt */
.settings-page .page-wrapper {
    margin-left: 0 !important;
}

/* Settings-Navigation nicht verbergen wenn auf InvoicePlus-Settings */
body.settings-page .setting-sidebar {
    display: block !important;
}

/* Settings-Tabs */
.invoiceplus-settings-tabs {
    margin-bottom: 20px;
}

.invoiceplus-settings-tabs .nav-tabs {
    border-bottom: 2px solid #e3e3e3;
}

.invoiceplus-settings-tab-content {
    padding: 20px 0;
}

/* Field Selection Checkboxen */
.invoiceplus-field-selection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.invoiceplus-field-selection .form-check {
    padding: 10px;
    border: 1px solid #e3e3e3;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.invoiceplus-field-selection .form-check:hover {
    background-color: #f8f9fa;
}

.invoiceplus-field-selection .form-check-label {
    font-weight: 500;
}

/* Units-Tabelle */
.invoiceplus-units-table {
    width: 100%;
}

/* PDF-Template-Auswahl */
.invoiceplus-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.invoiceplus-template-card {
    border: 2px solid #e3e3e3;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.invoiceplus-template-card:hover {
    border-color: #007bff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.invoiceplus-template-card.active {
    border-color: #28a745;
    background-color: #f0fff4;
}

.invoiceplus-template-preview {
    width: 100%;
    height: 150px;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: #6c757d;
}

.invoiceplus-template-name {
    font-weight: 600;
    margin-bottom: 5px;
}

/* Invoice-Formular */
.invoiceplus-invoice-form {
    padding: 20px;
}

.invoiceplus-form-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    background-color: #ffffff;
}

.invoiceplus-form-section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007bff;
}

/* Positions-Tabelle */
.invoiceplus-items-table {
    width: 100%;
    margin-bottom: 20px;
}

.invoiceplus-items-table thead {
    background-color: #f8f9fa;
}

.invoiceplus-items-table th {
    padding: 12px 8px;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

.invoiceplus-items-table td {
    padding: 10px 8px;
    vertical-align: middle;
}

.invoiceplus-items-table .form-control,
.invoiceplus-items-table .form-select {
    font-size: 14px;
}

.invoiceplus-item-actions {
    text-align: center;
}

.invoiceplus-add-item-btn {
    margin-top: 10px;
}

/* Summen-Bereich */
.invoiceplus-totals {
    max-width: 400px;
    margin-left: auto;
    margin-top: 20px;
}

.invoiceplus-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e3e3e3;
}

.invoiceplus-totals-row.total {
    font-weight: 700;
    font-size: 18px;
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    margin-top: 10px;
    padding-top: 12px;
}

.invoiceplus-totals-label {
    font-weight: 500;
}

.invoiceplus-totals-value {
    font-weight: 600;
}

/* Tax Breakdown */
.invoiceplus-tax-breakdown {
    margin-top: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.invoiceplus-tax-breakdown-title {
    font-weight: 600;
    margin-bottom: 10px;
}

.invoiceplus-tax-breakdown-table {
    width: 100%;
    font-size: 14px;
}

.invoiceplus-tax-breakdown-table th {
    padding: 8px;
    text-align: left;
    font-weight: 600;
    background-color: #e9ecef;
}

.invoiceplus-tax-breakdown-table td {
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
}

/* ============================================================================
   Batch-Rechnungen
   ============================================================================ */

/* Schritt-Indikator */
.invoiceplus-batch-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.invoiceplus-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.invoiceplus-step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #dee2e6;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s;
}

.invoiceplus-step.active .invoiceplus-step-number {
    background-color: #0d6efd;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.2);
}

.invoiceplus-step.completed .invoiceplus-step-number {
    background-color: #198754;
    color: #fff;
}

.invoiceplus-step-label {
    font-size: 12px;
    font-weight: 500;
    color: #6c757d;
    white-space: nowrap;
}

.invoiceplus-step.active .invoiceplus-step-label {
    color: #0d6efd;
    font-weight: 700;
}

.invoiceplus-step.completed .invoiceplus-step-label {
    color: #198754;
}

.invoiceplus-step-connector {
    flex: 1;
    height: 2px;
    background-color: #dee2e6;
    margin: 0 10px;
    margin-bottom: 22px; /* Ausrichten mit Nummern */
    min-width: 60px;
    max-width: 120px;
    transition: background-color 0.3s;
}

/* Batch-Section */
.invoiceplus-batch-section {
    margin-bottom: 24px;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}

.invoiceplus-batch-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #0d6efd;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Ausgewählte Kunden Box */
.invoiceplus-selected-clients-box {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px 16px;
}

.invoiceplus-client-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.invoiceplus-client-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background-color: #e7f3ff;
    border: 1px solid #b8d9f7;
    border-radius: 20px;
    font-size: 13px;
    color: #0d6efd;
}

.invoiceplus-client-tag-remove {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    line-height: 1;
    margin-left: 2px;
}

.invoiceplus-client-tag-remove:hover {
    color: #dc3545;
}

/* Batch Vorschau Statistiken */
.invoiceplus-preview-stat {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.invoiceplus-preview-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #0d6efd;
}

.invoiceplus-preview-stat-label {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

/* Batch Log */
.invoiceplus-batch-log {
    background-color: #1e1e1e;
    border-radius: 6px;
    overflow: hidden;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    max-height: 280px;
    overflow-y: auto;
}

.invoiceplus-batch-log-header {
    background-color: #2d2d2d;
    color: #e0e0e0;
    padding: 8px 14px;
    font-family: inherit;
}

.invoiceplus-batch-log-entry {
    padding: 4px 14px;
    border-bottom: 1px solid #2d2d2d;
    line-height: 1.6;
}

.invoiceplus-batch-log-entry.text-success { color: #4ec94e !important; }
.invoiceplus-batch-log-entry.text-danger  { color: #ff6b6b !important; }
.invoiceplus-batch-log-entry.text-muted   { color: #9e9e9e !important; }

.invoiceplus-batch-log-time {
    color: #888;
    font-size: 11px;
    margin-right: 6px;
}

/* Fortschrittsbalken */
.progress {
    border-radius: 10px;
    overflow: hidden;
}

/* Batch Count Badge */
.invoiceplus-batch-count {
    font-weight: 700;
    color: #0d6efd;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .invoiceplus-batch-steps {
        padding: 10px 0;
    }
    .invoiceplus-step-connector {
        min-width: 30px;
    }
    .invoiceplus-step-label {
        font-size: 10px;
    }
}

/* Item-Modal erweitert */
.invoiceplus-item-tabs {
    margin-bottom: 20px;
}

.invoiceplus-item-form-group {
    margin-bottom: 15px;
}

.invoiceplus-price-mode-toggle {
    margin: 15px 0;
    padding: 15px;
    background-color: #e7f3ff;
    border-radius: 4px;
}

.invoiceplus-price-mode-toggle .form-check {
    margin-bottom: 0;
}

/* Utility Classes */
.invoiceplus-text-muted {
    color: #6c757d;
    font-size: 14px;
}

.invoiceplus-help-text {
    font-size: 13px;
    color: #6c757d;
    margin-top: 5px;
}

.invoiceplus-required::after {
    content: " *";
    color: #dc3545;
}

.invoiceplus-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.invoiceplus-badge-success {
    background-color: #d4edda;
    color: #155724;
}

.invoiceplus-badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.invoiceplus-badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* ============================================================================
   Positions-Tabelle: Spaltenbreiten & 2-Zeilen-Layout
   ============================================================================ */

/* Tabelle volle Breite - kein table-layout:fixed, damit Spalten flexibel bleiben */
.invoiceplus-items-edit-table {
    width: 100%;
}

/* Spaltenbreiten in Prozent (damit Tabelle nie schmaler wird als nötig) */
.invoiceplus-items-edit-table th.invoiceplus-col-nr { width: 3%; }
.invoiceplus-items-edit-table th.invoiceplus-col-title { width: 22%; }
.invoiceplus-items-edit-table th.invoiceplus-col-qty { width: 7%; }
.invoiceplus-items-edit-table th.invoiceplus-col-unit { width: 8%; }
.invoiceplus-items-edit-table th.invoiceplus-col-rate { width: 9%; }
.invoiceplus-items-edit-table th.invoiceplus-col-tax { width: 14%; }
.invoiceplus-items-edit-table th.invoiceplus-col-taxamt { width: 8%; }
.invoiceplus-items-edit-table th.invoiceplus-col-disc { width: 7%; }
.invoiceplus-items-edit-table th.invoiceplus-col-total { width: 9%; }
.invoiceplus-items-edit-table th.invoiceplus-col-del { width: 3%; white-space: nowrap; }

/* Haupt-Zeile: kein unterer Border (gehört zum Paar mit Beschreibungs-Zeile) */
.invoiceplus-items-edit-table tr.invoice-item-main-row td {
    border-bottom: none !important;
    padding-bottom: 4px;
}

/* Beschreibungs-Zeile: kein oberer Abstand, dezenter Trenner nach unten */
.invoiceplus-items-edit-table tr.invoice-item-desc-row td {
    border-top: none !important;
    padding-top: 0;
}

/* Beschreibungs-Input: schmalere Höhe, grauer Placeholder */
.invoiceplus-desc-input {
    font-size: 0.8rem !important;
    color: #6c757d;
    background-color: #fafafa;
    border-color: #e9ecef !important;
}

.invoiceplus-desc-input::placeholder {
    color: #adb5bd;
    font-style: italic;
}

.invoiceplus-desc-input:focus {
    background-color: #fff;
    border-color: #86b7fe !important;
    color: #212529;
}

/* Beschreibungs-Zelle einrücken */
.invoiceplus-desc-cell {
    padding-left: 4px !important;
}

/* Kompakte Inputs in der Tabelle */
.invoiceplus-items-edit-table .form-control,
.invoiceplus-items-edit-table .form-select {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
}

/* ============================================================================
   Artikel-Autocomplete (select2 in Positions-Tabelle)
   ============================================================================ */

/* select2-Container in der Tabelle korrekt dimensionieren */
.invoiceplus-item-title-cell .select2-container {
    width: 100% !important;
    min-width: 160px;
}

.invoiceplus-item-title-cell .select2-container--default .select2-selection--single {
    height: 31px;    /* Gleich wie form-control-sm */
    font-size: 0.875rem;
    border-radius: 0.2rem;
    border-color: #ced4da;
}

.invoiceplus-item-title-cell .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 29px;
    padding-left: 8px;
    padding-right: 28px;
    color: #495057;
}

.invoiceplus-item-title-cell .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 29px;
    top: 1px;
}

/* Dropdown-Liste korrekt zindexen (über Bootstrap-Modals) */
.select2-dropdown {
    z-index: 99999;
}

/* "Neu erstellen"-Text in der Dropdown-Liste hervorheben */
.select2-results__option--created {
    color: #28a745;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .invoiceplus-field-selection {
        grid-template-columns: 1fr;
    }
    
    .invoiceplus-template-grid {
        grid-template-columns: 1fr;
    }
    
    .invoiceplus-totals {
        max-width: 100%;
    }
}

/* Loading-Spinner */
.invoiceplus-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: #007bff;
    border-radius: 50%;
    animation: invoiceplus-spin 1s linear infinite;
}

@keyframes invoiceplus-spin {
    to {
        transform: rotate(360deg);
    }
}
