/**
 * ERP dark mode – Bootstrap 5.3 data-bs-theme kiegészítő felülírások.
 */

[data-bs-theme="dark"] {
    color-scheme: dark;

    /* Alap paletta */
    --bs-body-bg: #212529;
    --bs-body-color: #f8f9fa;
    --bs-emphasis-color: #f8f9fa;
    --bs-secondary-color: #adb5bd;
    --bs-tertiary-color: #adb5bd;
    --bs-secondary-bg: #343a40;
    --bs-tertiary-bg: #2b3035;
    --bs-border-color: #495057;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.12);
    --bs-link-color: #6ea8fe;
    --bs-link-hover-color: #9ec5fe;

    /* Űrlapmezők */
    --bs-form-control-bg: #2b3035;
    --bs-form-control-color: #f8f9fa;
    --bs-form-control-border-color: #495057;
    --bs-form-control-disabled-bg: #343a40;
    --bs-form-control-disabled-color: #adb5bd;
    --bs-form-select-bg: #2b3035;
    --bs-form-select-color: #f8f9fa;
    --bs-form-select-border-color: #495057;
    --bs-form-select-disabled-bg: #343a40;
    --bs-form-select-disabled-color: #adb5bd;
    --bs-form-select-indicator-color: #f8f9fa;
    --bs-input-group-addon-bg: #343a40;
    --bs-input-group-addon-color: #f8f9fa;
    --bs-input-group-addon-border-color: #495057;

    /* Kártyák */
    --bs-card-bg: #2b3035;
    --bs-card-cap-bg: #343a40;
    --bs-card-border-color: #495057;
    --bs-card-color: #f8f9fa;

    /* Táblázat */
    --bs-table-bg: transparent;
    --bs-table-color: #f8f9fa;
    --bs-table-border-color: #495057;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.07);
    --bs-table-active-bg: rgba(255, 255, 255, 0.09);

    /* Modal */
    --bs-modal-bg: #2b3035;
    --bs-modal-color: #f8f9fa;
    --bs-modal-border-color: #495057;
    --bs-modal-header-border-color: #495057;
    --bs-modal-footer-border-color: #495057;

    /* Legördülő */
    --bs-dropdown-bg: #2b3035;
    --bs-dropdown-color: #f8f9fa;
    --bs-dropdown-border-color: #495057;
    --bs-dropdown-link-color: #f8f9fa;
    --bs-dropdown-link-hover-color: #f8f9fa;
    --bs-dropdown-link-hover-bg: #343a40;
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-link-active-bg: #0d6efd;
    --bs-dropdown-divider-bg: #495057;

    /* bg-light / bg-white Bootstrap remap – ne maradjon világos */
    --bs-light-bg-subtle: #343a40;
    --bs-light-border-subtle: #495057;
    --bs-light-text-emphasis: #f8f9fa;

    /* Űrlapmező állapotok (FFS) – sötét, de megkülönböztethető */
    --ffs-required-bg: #3d2a32;
    --ffs-required-bg-focus: #4a333c;
    --ffs-optional-bg: #2a3542;
    --ffs-optional-bg-focus: #323f4e;
    --ffs-readonly-bg: #343a40;
    --ffs-readonly-border: #495057;
}

/* Űrlapmezők – explicit kontraszt (FFS !important mellett is) */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] textarea.form-control {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #495057;
}

[data-bs-theme="dark"] .form-select {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #495057;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23f8f9fa' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] textarea.form-control::placeholder {
    color: #adb5bd;
    opacity: 1;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] textarea.form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #6ea8fe;
    box-shadow: 0 0 0 0.25rem rgba(110, 168, 254, 0.2);
}

[data-bs-theme="dark"] .form-select option {
    background-color: #2b3035;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly]:not(.readonly-field),
[data-bs-theme="dark"] .form-select:disabled {
    background-color: #343a40;
    color: #adb5bd;
    border-color: #495057;
}

[data-bs-theme="dark"] .form-control.readonly-field,
[data-bs-theme="dark"] .form-select.readonly-field,
[data-bs-theme="dark"] input.readonly-field,
[data-bs-theme="dark"] select.readonly-field,
[data-bs-theme="dark"] textarea.readonly-field {
    color: #ced4da;
}

[data-bs-theme="dark"] .form-control.bg-light,
[data-bs-theme="dark"] .bg-light.form-control {
    background-color: #343a40 !important;
    color: #ced4da !important;
    border-color: #495057;
}

[data-bs-theme="dark"] .form-text {
    color: #adb5bd;
}

[data-bs-theme="dark"] .input-group-text {
    background-color: #343a40;
    color: #f8f9fa;
    border-color: #495057;
}

/* Kártyák */
[data-bs-theme="dark"] .card {
    background-color: #2b3035;
    border-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .card-header {
    background-color: #343a40;
    border-bottom-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #343a40;
    border-top-color: #495057;
}

/* Táblázat */
[data-bs-theme="dark"] .table {
    --bs-table-color: #f8f9fa;
    --bs-table-border-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: #343a40;
    --bs-table-color: #f8f9fa;
    --bs-table-border-color: #495057;
}

/* Modal */
[data-bs-theme="dark"] .modal-content {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #495057;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: #495057;
}

/* Legördülő / keresési találatok */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #495057;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #343a40;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #495057;
}

[data-bs-theme="dark"] .list-group-item-action:hover,
[data-bs-theme="dark"] .list-group-item-action:focus {
    background-color: #343a40;
    color: #f8f9fa;
}

/* Világos Bootstrap utility felülírások */
[data-bs-theme="dark"] .bg-light {
    background-color: #343a40 !important;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .bg-white {
    background-color: #2b3035 !important;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .text-bg-light {
    background-color: #495057 !important;
    color: #f8f9fa !important;
}

[data-bs-theme="dark"] .badge.bg-light {
    background-color: #495057 !important;
    color: #f8f9fa !important;
    border-color: #6c757d !important;
}

[data-bs-theme="dark"] .btn-light {
    --bs-btn-bg: #343a40;
    --bs-btn-border-color: #495057;
    --bs-btn-color: #f8f9fa;
    --bs-btn-hover-bg: #3d444b;
    --bs-btn-hover-border-color: #6c757d;
    --bs-btn-hover-color: #fff;
    --bs-btn-disabled-bg: #343a40;
    --bs-btn-disabled-border-color: #495057;
    --bs-btn-disabled-color: #adb5bd;
}

/* Naptár rács */
[data-bs-theme="dark"] .calendar-grid-table .grid-day-cell.today {
    background: #1a3a5c;
}
[data-bs-theme="dark"] .calendar-grid-table .grid-day-cell.out-of-range {
    background: #2b3035;
}
[data-bs-theme="dark"] .calendar-grid-table .grid-day-cell.past-day {
    background: #343a40;
}
[data-bs-theme="dark"] .calendar-grid-table .grid-day-cell.empty-cell {
    background: #2b3035;
}
[data-bs-theme="dark"] .calendar-grid-table .grid-day-cell.drag-over {
    background: #1a3a5c !important;
}
[data-bs-theme="dark"] .bg-purple-subtle {
    background-color: #2d1f42 !important;
}

/* Ütemező rács */
[data-bs-theme="dark"] .schedule-grid .tech-col {
    background: #343a40;
}
[data-bs-theme="dark"] .schedule-grid .day-col-head.today {
    background: #1a3a5c;
}
[data-bs-theme="dark"] .schedule-grid .drop-cell {
    background: #212529;
}
[data-bs-theme="dark"] .schedule-grid .drop-cell.drag-over {
    background: #1a3a5c !important;
}
[data-bs-theme="dark"] .schedule-grid tr.row-unassigned .tech-col {
    background: #3d3418;
    color: #ffc107;
}

/* Munkafelvétel / megrendelő naptár */
[data-bs-theme="dark"] .prepared-order-chip {
    background: #343a40;
    color: #f8f9fa;
}
[data-bs-theme="dark"] .prepared-job-card {
    background: #343a40;
    border-color: #6c757d;
    color: #f8f9fa;
}
[data-bs-theme="dark"] .prepared-job-card.ready {
    background: #1e3d2a;
    border-color: #198754;
}
[data-bs-theme="dark"] .dispatcher-work-type-tile {
    box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
[data-bs-theme="dark"] .dispatcher-work-type-tile.active {
    border-color: #fff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .2), 0 4px 14px rgba(0, 0, 0, .5);
}
[data-bs-theme="dark"] .grid-day-cell.slot-selected {
    background: #1e3d2a !important;
}
[data-bs-theme="dark"] #intakeCustomerResults.customer-results,
[data-bs-theme="dark"] #orderCustomerResults,
[data-bs-theme="dark"] #orderClimateResults,
[data-bs-theme="dark"] #orderExtraProductResults,
[data-bs-theme="dark"] .customer-results,
[data-bs-theme="dark"] .product-results {
    background: #2b3035;
    border-color: #495057;
    color: #f8f9fa;
}

/* Megrendelő űrlap */
[data-bs-theme="dark"] .prepared-order-card {
    background: #343a40;
    border-color: #6c757d;
    color: #f8f9fa;
}
[data-bs-theme="dark"] .order-item-row {
    background: #343a40;
    border-color: #495057;
    color: #f8f9fa;
}
[data-bs-theme="dark"] .order-item-row.is-primary {
    background: #1e3d2a;
    border-color: #198754;
}

/* Árajánlat űrlap */
[data-bs-theme="dark"] #quoteItemsBody tr.quote-item-surcharge {
    background-color: #343a40;
}
[data-bs-theme="dark"] .quote-ac-specs {
    color: #adb5bd;
}

/* Kivételek: aláírás, PDF előnézet – maradjon világos felület */
[data-bs-theme="dark"] .ord-signature-canvas-wrap,
[data-bs-theme="dark"] .ord-signature-canvas-wrap .bg-white,
[data-bs-theme="dark"] .ws-signature-canvas-wrap,
[data-bs-theme="dark"] .ws-signature-canvas-wrap .bg-white,
[data-bs-theme="dark"] #orderPdfPreviewModal .modal-body,
[data-bs-theme="dark"] #orderPdfPreviewFrame {
    background-color: #fff !important;
}

/* Űrlap-diktálás lebegő panel */
[data-bs-theme="dark"] .virrend-form-dictation {
    background: var(--bs-card-bg);
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color);
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.45);
}
[data-bs-theme="dark"] .virrend-form-dictation-handle {
    background: rgba(255, 255, 255, 0.04);
    border-bottom-color: var(--bs-border-color);
}
[data-bs-theme="dark"] .virrend-form-dictation-handle-label {
    color: var(--bs-secondary-color);
}
[data-bs-theme="dark"] .virrend-form-dictation .virrend-form-dictation-status.text-muted {
    color: var(--bs-secondary-color) !important;
}
