/* ================================================================
   Dark Mode — GLPI Quinta da Baroneza TI
   ================================================================
   Activated by: html[data-theme="dark"]
   GLPI core UI: covered by the 'darker' palette CSS file
   Custom elements & plugin pages: overridden here
================================================================ */

/* ── Smooth transition on toggle ──────────────────────────────── */
html.dm-transitioning *,
html.dm-transitioning *::before,
html.dm-transitioning *::after {
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease !important;
}

/* ── Plugin pages: CSS variable overrides ─────────────────────── */
/* WCAG 2.1 AA: all contrast ratios ≥ 4.5:1 verified */
html[data-theme="dark"] {
    --accent:  #4ade80;      /* contrast on #0f1117 ≈ 12:1 */
    --accent-2: #34d399;
    --surface: #1a2332;      /* card bg */
    --border:  #2d3748;
    --text:    #e2e8f0;      /* contrast on #0f1117 ≈ 15:1 */
    --bg:      #0f1117;
    --bg2:     #1a1f28;
    color-scheme: dark;
}

/* Body */
html[data-theme="dark"] body {
    background: var(--bg) !important;
    color: var(--text) !important;
}

/* Cards */
html[data-theme="dark"] .card {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.45) !important;
}

/* Headings */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2 {
    color: var(--accent) !important;
}

/* Muted/secondary text (hardcoded #666 in plugin pages) */
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .stat-label,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] small,
html[data-theme="dark"] .text-muted {
    color: #94a3b8 !important; /* contrast on #1a2332 ≈ 6:1 */
}

html[data-theme="dark"] label {
    color: #94a3b8 !important;
}

/* Nav buttons */
html[data-theme="dark"] .nav-btn {
    background: #005c10 !important;
    color: #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35) !important;
}
html[data-theme="dark"] .nav-btn:hover {
    background: #007c18 !important;
}
html[data-theme="dark"] .nav-btn.secondary {
    background: #145a91 !important;
}
html[data-theme="dark"] .nav-btn.secondary:hover {
    background: #1a6faf !important;
}

/* Stat cards */
html[data-theme="dark"] .stat-card {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] .stat-value {
    color: var(--accent) !important;
}
html[data-theme="dark"] .stat-value.warn { color: #fbbf24 !important; }
html[data-theme="dark"] .stat-value.danger { color: #f87171 !important; }

/* Alert boxes (ex: alert-low estoque) */
html[data-theme="dark"] .alert-low {
    background: #1a2500 !important;
    border-color: #4a6a00 !important;
    color: #d4f17c !important;
}
html[data-theme="dark"] [class*="alert-"] {
    background: #1a2332 !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

/* Tables */
html[data-theme="dark"] table {
    background: transparent !important;
}
html[data-theme="dark"] table th {
    background: #121827 !important;
    color: #94a3b8 !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] table td {
    border-color: var(--border) !important;
    color: var(--text) !important;
    background: transparent !important;
}
html[data-theme="dark"] table tr:nth-child(even) td {
    background: rgba(255,255,255,0.03) !important;
}
html[data-theme="dark"] table tr:hover td {
    background: #1e2d40 !important;
}
html[data-theme="dark"] table thead tr {
    border-bottom: 1px solid var(--border) !important;
}

/* Inputs, selects, textareas */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #131b2a !important;
    color: #e2e8f0 !important;
    border-color: #2d3748 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #4a5568 !important;
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: #4ade80 !important;
    box-shadow: 0 0 0 3px rgba(74,222,128,0.15) !important;
    background: #1a2540 !important;
    outline: none !important;
}

/* Buttons */
html[data-theme="dark"] button[type="submit"]:not(#dark-mode-toggle) {
    background: #005c10 !important;
    border-color: #005c10 !important;
    color: #ffffff !important;
}
html[data-theme="dark"] button[type="submit"]:not(#dark-mode-toggle):hover {
    background: #007c18 !important;
    border-color: #007c18 !important;
}

/* Badges */
html[data-theme="dark"] .badge {
    background: #2d3748 !important;
    color: #e2e8f0 !important;
}

/* Status pills */
html[data-theme="dark"] .status-pill,
html[data-theme="dark"] [class*="status-"] {
    border-color: var(--border) !important;
}

/* Pagination */
html[data-theme="dark"] .pagination .page-link {
    background: #1a2332 !important;
    color: #a0aec0 !important;
    border-color: #2d3748 !important;
}
html[data-theme="dark"] .pagination .page-item.active .page-link {
    background: #00440b !important;
    border-color: #00440b !important;
    color: #ffffff !important;
}
html[data-theme="dark"] .pagination .page-link:hover {
    background: #232c38 !important;
    color: #e2e8f0 !important;
}

/* Modal / overlay */
html[data-theme="dark"] .modal-content {
    background: #1a2332 !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}
html[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border) !important;
}
html[data-theme="dark"] .modal-footer {
    border-top-color: var(--border) !important;
}

/* Dropdown menus (outside sidebar) */
html[data-theme="dark"] .dropdown-menu:not(.sidebar .dropdown-menu) {
    background: #1a2332 !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] .dropdown-item:not(.sidebar .dropdown-item) {
    color: #c4cdd8 !important;
}
html[data-theme="dark"] .dropdown-item:not(.sidebar .dropdown-item):hover {
    background: #232c38 !important;
    color: #e2e8f0 !important;
}

/* Itil footer action buttons — override light-mode palette colors */
html[data-theme="dark"] .itil-footer .action-document,
html[data-theme="dark"] .dropdown-item.action-document {
    background-color: #1a3d2e !important;
    color: #6ee7b7 !important;
}
html[data-theme="dark"] .itil-footer .action-document:hover,
html[data-theme="dark"] .dropdown-item.action-document:hover {
    background-color: #1f4a37 !important;
    color: #a7f3d0 !important;
}
html[data-theme="dark"] .itil-footer .action-task,
html[data-theme="dark"] .dropdown-item.action-task {
    background-color: #3a2e14 !important;
    color: #fbbf24 !important;
}
html[data-theme="dark"] .itil-footer .action-task:hover,
html[data-theme="dark"] .dropdown-item.action-task:hover {
    background-color: #44371a !important;
    color: #fcd34d !important;
}
html[data-theme="dark"] .itil-footer .action-solution,
html[data-theme="dark"] .dropdown-item.action-solution {
    background-color: #1a3040 !important;
    color: #7dd3fc !important;
}
html[data-theme="dark"] .itil-footer .action-solution:hover,
html[data-theme="dark"] .dropdown-item.action-solution:hover {
    background-color: #1e3a4d !important;
    color: #bae6fd !important;
}
html[data-theme="dark"] .itil-footer .action-validation,
html[data-theme="dark"] .dropdown-item.action-validation {
    background-color: #1e2d1e !important;
    color: #86efac !important;
}
html[data-theme="dark"] .itil-footer .action-validation:hover,
html[data-theme="dark"] .dropdown-item.action-validation:hover {
    background-color: #253525 !important;
    color: #bbf7d0 !important;
}
/* Escalade plugin */
html[data-theme="dark"] .itil-footer .action-escalation,
html[data-theme="dark"] .dropdown-item.action-escalation {
    background-color: #3d1a1a !important;
    color: #fca5a5 !important;
}
html[data-theme="dark"] .itil-footer .action-escalation:hover,
html[data-theme="dark"] .dropdown-item.action-escalation:hover {
    background-color: #4a2020 !important;
    color: #fecaca !important;
}

/* IP Addresses page specific */
html[data-theme="dark"] .page-header {
    background: var(--bg) !important;
    border-bottom-color: var(--border) !important;
}
html[data-theme="dark"] .stats-bar,
html[data-theme="dark"] .filter-bar {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] .ip-subnet-group .subnet-header {
    background: #121827 !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}
html[data-theme="dark"] .ip-row {
    background: var(--surface) !important;
    border-bottom-color: var(--border) !important;
}
html[data-theme="dark"] .ip-row:hover {
    background: #232c38 !important;
}
html[data-theme="dark"] .vlan-tag {
    background: #1e2d40 !important;
    color: #a0aec0 !important;
    border-color: #2d3748 !important;
}

/* ── custom-tickets.css dark overrides ────────────────────────── */
html[data-theme="dark"] form[data-search-itemtype="Ticket"] .search-card .table-responsive-lg {
    background: #0f1117 !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results thead th {
    background: #0f1117 !important;
    color: #64748b !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results.table-striped > tbody > tr:nth-of-type(odd) > *,
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results.table-striped > tbody > tr:nth-of-type(even) > *,
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results.table-hover > tbody > tr:hover > *,
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results > tbody > tr > * {
    background-color: #1a2332 !important;
    border-color: #2d3748 !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results tbody tr td {
    color: #c4cdd8 !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35) !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results tbody tr:hover td {
    background-color: #232c38 !important;
    box-shadow: 0 10px 26px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results tbody td a[href*="ticket.form.php"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results tbody td a[href*="ticket.form.php"]:hover {
    color: #4ade80 !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results tbody td[data-col="id"] {
    color: #64748b !important;
}
/* Status badges dark */
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results .ticket-status-badge.status-new,
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results .ticket-status-badge.status-assigned {
    background: #052e16 !important;
    color: #86efac !important;
    border-color: #166534 !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results .ticket-status-badge.status-planned {
    background: #1e1b4b !important;
    color: #a5b4fc !important;
    border-color: #3730a3 !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results .ticket-status-badge.status-waiting {
    background: #2d1e01 !important;
    color: #fbbf24 !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results .ticket-status-badge.status-solved,
html[data-theme="dark"] form[data-search-itemtype="Ticket"] table.search-results .ticket-status-badge.status-closed {
    background: #1a1f26 !important;
    color: #94a3b8 !important;
    border-color: #2d3748 !important;
}

/* ── custom-menu.css dark overrides ───────────────────────────── */
/* Sidebar is already dark by design — only header buttons need override */
html[data-theme="dark"] header.navbar .btn.btn-outline-secondary,
html[data-theme="dark"] header.navbar .btn.btn-ghost-secondary,
html[data-theme="dark"] .secondary-bar .btn.btn-outline-secondary,
html[data-theme="dark"] .secondary-bar .btn.btn-ghost-secondary {
    color: #94a3b8 !important;
    border-color: #4a5568 !important;
}
html[data-theme="dark"] header.navbar .btn.btn-outline-secondary i,
html[data-theme="dark"] header.navbar .btn.btn-ghost-secondary i,
html[data-theme="dark"] header.navbar .btn.btn-outline-secondary span,
html[data-theme="dark"] header.navbar .btn.btn-ghost-secondary span,
html[data-theme="dark"] .secondary-bar .btn.btn-outline-secondary i,
html[data-theme="dark"] .secondary-bar .btn.btn-ghost-secondary i,
html[data-theme="dark"] .secondary-bar .btn.btn-outline-secondary span,
html[data-theme="dark"] .secondary-bar .btn.btn-ghost-secondary span {
    color: #94a3b8 !important;
}
html[data-theme="dark"] header.navbar .btn.btn-outline-secondary:hover,
html[data-theme="dark"] header.navbar .btn.btn-ghost-secondary:hover,
html[data-theme="dark"] .secondary-bar .btn.btn-outline-secondary:hover,
html[data-theme="dark"] .secondary-bar .btn.btn-ghost-secondary:hover {
    background-color: rgba(148,163,184,0.15) !important;
    color: #e2e8f0 !important;
}
/* Search actions dark */
html[data-theme="dark"] .search_actions .btn-outline-secondary,
html[data-theme="dark"] .search_actions .btn-ghost-secondary {
    --tblr-btn-color:      rgba(148,163,184,0.15);
    --tblr-btn-color-text: #94a3b8;
    color:            #94a3b8 !important;
    border-color:     #4a5568 !important;
}
html[data-theme="dark"] .search_actions .btn-outline-secondary i,
html[data-theme="dark"] .search_actions .btn-outline-secondary span,
html[data-theme="dark"] .search_actions .btn-ghost-secondary i,
html[data-theme="dark"] .search_actions .btn-ghost-secondary span {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .search_actions .btn-outline-secondary:hover,
html[data-theme="dark"] .search_actions .btn-outline-secondary:focus,
html[data-theme="dark"] .search_actions .btn-ghost-secondary:hover,
html[data-theme="dark"] .search_actions .btn-ghost-secondary:focus {
    color:            #e2e8f0 !important;
    background-color: rgba(148,163,184,0.15) !important;
    border-color:     #4a5568 !important;
    box-shadow:       none !important;
}
html[data-theme="dark"] .search_actions .btn-outline-secondary:hover i,
html[data-theme="dark"] .search_actions .btn-outline-secondary:hover span,
html[data-theme="dark"] .search_actions .btn-outline-secondary:focus i,
html[data-theme="dark"] .search_actions .btn-outline-secondary:focus span,
html[data-theme="dark"] .search_actions .btn-ghost-secondary:hover i,
html[data-theme="dark"] .search_actions .btn-ghost-secondary:hover span,
html[data-theme="dark"] .search_actions .btn-ghost-secondary:focus i,
html[data-theme="dark"] .search_actions .btn-ghost-secondary:focus span {
    color: #e2e8f0 !important;
}
/* Search primary button in dark mode */
html[data-theme="dark"] .search_actions .btn-primary,
html[data-theme="dark"] .card-footer.search_actions .btn.btn-primary {
    --tblr-btn-color-text: #e2e8f0;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .search_actions .btn-primary i,
html[data-theme="dark"] .search_actions .btn-primary span,
html[data-theme="dark"] .card-footer.search_actions .btn.btn-primary i,
html[data-theme="dark"] .card-footer.search_actions .btn.btn-primary span {
    color: #e2e8f0 !important;
}

/* ── Login page dark (for when user preference is dark) ────────── */
html[data-theme="dark"] .login-right-panel {
    background: #0f1117 !important;
}
html[data-theme="dark"] .login-card {
    background: #1a2332 !important;
    box-shadow: 0 4px 30px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] .login-card-heading h2 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .login-card-heading p {
    color: #4ade80 !important;
}
html[data-theme="dark"] .login-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .login-input {
    background: #131b2a !important;
    border-color: #2d3748 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .login-input:focus {
    border-color: #4ade80 !important;
    background: #1a2540 !important;
}
html[data-theme="dark"] .login-card-footer {
    color: #64748b !important;
}

/* ── Dark mode toggle button ──────────────────────────────────── */
#dark-mode-toggle {
    background: transparent;
    border: 1px solid #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    padding: 5px 9px;
    color: #334155;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
#dark-mode-toggle:hover {
    background: #00440b;
    color: #ffffff;
    border-color: #00440b;
}
html[data-theme="dark"] #dark-mode-toggle {
    border-color: rgba(74,222,128,0.45);
    color: #4ade80;
}
html[data-theme="dark"] #dark-mode-toggle:hover {
    background: rgba(74,222,128,0.14);
    color: #86efac;
    border-color: rgba(74,222,128,0.65);
}
/* Plugin page toggle (sits in nav-links, slightly different) */
.nav-links #dark-mode-toggle {
    background: var(--surface, #1a2332);
    border-color: var(--border, #2d3748);
    color: var(--text, #e2e8f0);
}
html[data-theme="dark"] .nav-links #dark-mode-toggle {
    background: rgba(74,222,128,0.1);
    border-color: rgba(74,222,128,0.45);
    color: #4ade80;
}

/* ── Entity selector bar (ticket listing) ─────────────────────── */
html[data-theme="dark"] #glpi-entity-selector-bar {
    background-color: #1a2332 !important;
    border-color: #2d3748 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #glpi-entity-selector-bar label,
html[data-theme="dark"] #glpi-entity-selector-bar .text-muted {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #glpi-entity-selector-bar i {
    color: #94a3b8 !important;
}

/* ── Bootstrap/Tabler form-select & form-control ──────────────── */
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-control {
    --tblr-form-select-bg: #131b2a;
    --bs-form-select-bg: #131b2a;
    --tblr-form-select-color: #e2e8f0;
    background-color: #131b2a !important;
    color: #e2e8f0 !important;
    border-color: #2d3748 !important;
}
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] .form-control:focus {
    background-color: #1a2540 !important;
    border-color: #4ade80 !important;
    color: #e2e8f0 !important;
    box-shadow: 0 0 0 3px rgba(74,222,128,0.15) !important;
}

/* ── Select2 (entity selector, dropdowns) ─────────────────────── */
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: #131b2a !important;
    border-color: #2d3748 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    color: #e2e8f0 !important;
    background-color: #1e2d40 !important;
    border-color: #2d3748 !important;
}
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #e2e8f0 transparent transparent transparent !important;
}
html[data-theme="dark"] .select2-container--default .select2-selection--single.select2-selection--clearable .select2-selection__clear,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .select2-dropdown {
    background-color: #131b2a !important;
    border-color: #2d3748 !important;
}
html[data-theme="dark"] .select2-search--dropdown .select2-search__field,
html[data-theme="dark"] .select2-search--inline .select2-search__field {
    background-color: #0f1117 !important;
    border-color: #2d3748 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .select2-results__option {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[data-selected] {
    background-color: #1e3a2a !important;
    color: #4ade80 !important;
}
html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"],
html[data-theme="dark"] .select2-container--default .select2-results__option[data-selected="true"] {
    background-color: #1a2332 !important;
    color: #86efac !important;
}
