/* ==========================================================================
   TELAS DE SOLICITACOES (TICKETS) - contraste e consistencia, tema claro e escuro
   Escopo: body.tickets / body.ticket (admin) e componentes compartilhados da tela
   (TinyMCE "tox", bootstrap-select com busca ajax, tag-it, jQuery UI autocomplete).
   Carregado por modern_dark_theme.php depois dos demais CSS do tema.

   Tokens do tema escuro reutilizados (mesmos valores de modern_theme.css e
   contrast_work_general.css): painel #151c2c, campo #0f172a, superficie #1e293b,
   hover #273449, borda #334155, texto #f1f5f9, texto secundario #cbd5e1/#94a3b8,
   foco #3b82f6, selecao #2563eb.

   O editor em si recebe o skin "oxide-dark" e o content_css escuro via
   assets/js/tinymce_dark.js; aqui so se ajusta o cromo do skin aos tokens do tema.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TINYMCE (tema escuro) - cromo do skin oxide-dark nos tokens do tema
   -------------------------------------------------------------------------- */
/* O tailwind.css do core fixa cores claras com !important (borda, area do iframe, menu
   ativo, fundo do dialogo); por isso estes overrides tambem usam !important. */
html.dark-theme .tox.tox-tinymce {
    border-color: #334155 !important;
    box-shadow: none;
}

html.dark-theme .tox.tox-tinymce:focus-within {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

html.dark-theme body.tickets .tox .tox-edit-area__iframe,
html.dark-theme body.ticket .tox .tox-edit-area__iframe {
    background-color: #0f172a !important;
}

html.dark-theme .tox .tox-dialog-wrap__backdrop,
html.dark-theme .tox .tox-dialog-wrap__backdrop--opaque {
    background-color: rgba(2, 6, 23, 0.72) !important;
}

html.dark-theme .tox:not(.tox-tinymce-inline) .tox-editor-header,
html.dark-theme .tox .tox-menubar,
html.dark-theme .tox .tox-toolbar,
html.dark-theme .tox .tox-toolbar__overflow,
html.dark-theme .tox .tox-toolbar__primary,
html.dark-theme .tox .tox-toolbar-overlord {
    background-color: #1e293b;
}

html.dark-theme .tox:not(.tox-tinymce-inline) .tox-editor-header {
    border-color: #334155 !important;
}

html.dark-theme .tox .tox-mbtn,
html.dark-theme .tox .tox-mbtn__select-label,
html.dark-theme .tox .tox-tbtn,
html.dark-theme .tox .tox-tbtn__select-label {
    color: #e2e8f0;
}

html.dark-theme .tox .tox-tbtn svg,
html.dark-theme .tox .tox-mbtn svg {
    fill: #e2e8f0;
}

html.dark-theme .tox .tox-mbtn:hover:not(:disabled):not(.tox-mbtn--active),
html.dark-theme .tox .tox-mbtn--active {
    background-color: #273449 !important;
    color: #ffffff;
}

html.dark-theme .tox .tox-tbtn:hover,
html.dark-theme .tox .tox-tbtn:focus {
    background-color: #273449;
    color: #ffffff;
}

html.dark-theme .tox .tox-tbtn--enabled,
html.dark-theme .tox .tox-tbtn--enabled:hover,
html.dark-theme .tox .tox-tbtn--enabled:focus {
    background-color: #1d4ed8;
    color: #ffffff;
}

html.dark-theme .tox .tox-tbtn--enabled svg {
    fill: #ffffff;
}

html.dark-theme .tox .tox-tbtn:focus-visible,
html.dark-theme .tox .tox-mbtn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

html.dark-theme .tox .tox-tbtn--disabled,
html.dark-theme .tox .tox-tbtn:disabled,
html.dark-theme .tox .tox-mbtn--disabled,
html.dark-theme .tox .tox-mbtn:disabled {
    color: #94a3b8;
    opacity: 0.7;
}

/* Seletores "Fonte" e "Tamanho" da barra */
html.dark-theme .tox .tox-tbtn--select {
    background-color: #0f172a;
    border: 1px solid #334155;
    color: #f1f5f9;
}

html.dark-theme .tox .tox-tbtn--select:hover,
html.dark-theme .tox .tox-tbtn--select:focus {
    background-color: #273449;
    border-color: #475569;
}

html.dark-theme .tox .tox-tbtn--select .tox-tbtn__select-label {
    color: #f1f5f9;
}

html.dark-theme .tox .tox-toolbar__group:not(:last-of-type) {
    border-right: 1px solid #334155;
}

/* Menus, listas e popups do editor (ficam no <body>, fora do .tox-tinymce) */
html.dark-theme .tox .tox-menu,
html.dark-theme .tox .tox-collection--list,
html.dark-theme .tox .tox-swatches-menu,
html.dark-theme .tox .tox-pop__dialog {
    background-color: #1e293b;
    border: 1px solid #334155;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

html.dark-theme .tox .tox-collection__item,
html.dark-theme .tox .tox-collection__item-label,
html.dark-theme .tox .tox-collection__item-accessory {
    color: #f1f5f9;
}

html.dark-theme .tox .tox-collection__item-icon svg,
html.dark-theme .tox .tox-collection__item-checkmark svg,
html.dark-theme .tox .tox-collection__item-caret svg {
    fill: #e2e8f0;
}

html.dark-theme .tox .tox-collection--list .tox-collection__item--active,
html.dark-theme .tox .tox-collection--list .tox-collection__item:hover {
    background-color: #2563eb;
    color: #ffffff;
}

html.dark-theme .tox .tox-collection__item--active .tox-collection__item-label,
html.dark-theme .tox .tox-collection__item--active .tox-collection__item-accessory,
html.dark-theme .tox .tox-collection__item--active .tox-collection__item-icon svg,
html.dark-theme .tox .tox-collection__item--active .tox-collection__item-checkmark svg,
html.dark-theme .tox .tox-collection__item--active .tox-collection__item-caret svg {
    color: #ffffff;
    fill: #ffffff;
}

html.dark-theme .tox .tox-collection__group-heading {
    background-color: #151c2c;
    color: #cbd5e1;
}

html.dark-theme .tox .tox-collection--list .tox-collection__group {
    border-color: #334155;
}

/* Dialogos (link, imagem, tabela, codigo...) */
html.dark-theme .tox .tox-dialog {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #f1f5f9;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}

html.dark-theme .tox .tox-dialog__header,
html.dark-theme .tox .tox-dialog__footer {
    background-color: #1e293b;
    border-color: #334155;
}

html.dark-theme .tox .tox-dialog__title,
html.dark-theme .tox .tox-label,
html.dark-theme .tox .tox-form__group > label,
html.dark-theme .tox .tox-checkbox__label,
html.dark-theme .tox .tox-dialog__body-content {
    color: #f1f5f9;
}

html.dark-theme .tox .tox-dialog__body-nav-item {
    color: #cbd5e1;
}

html.dark-theme .tox .tox-dialog__body-nav-item--active {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

html.dark-theme .tox .tox-textfield,
html.dark-theme .tox .tox-textarea,
html.dark-theme .tox .tox-selectfield select,
html.dark-theme .tox .tox-listboxfield .tox-listbox--select {
    background-color: #0f172a;
    border: 1px solid #334155;
    color: #f8fafc;
}

html.dark-theme .tox .tox-textfield:focus,
html.dark-theme .tox .tox-textarea:focus,
html.dark-theme .tox .tox-selectfield select:focus,
html.dark-theme .tox .tox-listboxfield .tox-listbox--select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

html.dark-theme .tox .tox-button {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

html.dark-theme .tox .tox-button:hover:not(:disabled) {
    background-color: #1e40af;
    border-color: #1e40af;
}

html.dark-theme .tox .tox-button--secondary {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
}

html.dark-theme .tox .tox-button--secondary:hover:not(:disabled) {
    background-color: #273449;
    border-color: #475569;
    color: #ffffff;
}

html.dark-theme .tox .tox-button--naked {
    color: #e2e8f0;
}

html.dark-theme .tox .tox-button:focus-visible,
html.dark-theme .tox .tox-button--secondary:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   2. BOOTSTRAP-SELECT COM BUSCA AJAX (Associado/Contato, Projeto) nas telas de tickets
   -------------------------------------------------------------------------- */

/* Linha em branco do <option value=""> que a busca ajax preserva: aparecia como barra
   azul vazia e como grupo "Selecionado atualmente" sem conteudo. O "x" do campo limpa. */
body.tickets .bootstrap-select.ajax-search .dropdown-menu li:has(> a > span.text:empty),
body.ticket .bootstrap-select.ajax-search .dropdown-menu li:has(> a > span.text:empty),
body.tickets .bootstrap-select.ajax-search .dropdown-menu li.dropdown-header:has(+ li > a > span.text:empty),
body.ticket .bootstrap-select.ajax-search .dropdown-menu li.dropdown-header:has(+ li > a > span.text:empty),
body.tickets .bootstrap-select.ajax-search .dropdown-menu li.divider:has(+ li.dropdown-header + li > a > span.text:empty),
body.ticket .bootstrap-select.ajax-search .dropdown-menu li.divider:has(+ li.dropdown-header + li > a > span.text:empty) {
    display: none;
}

/* Texto secundario da opcao (nome da empresa): #6b7280 sobre o item ativo #f3f4f6 dava 4,39:1;
   #4b5563 sobre #f3f4f6 = 7,0:1 (tema claro). */
body.tickets .bootstrap-select .dropdown-menu li a span.text small.text-muted,
body.ticket .bootstrap-select .dropdown-menu li a span.text small.text-muted {
    color: #4b5563 !important;
}

/* Tema escuro: texto secundario da opcao (nome da empresa) */
html.dark-theme body.tickets .bootstrap-select .dropdown-menu li a span.text small.text-muted,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu li a span.text small.text-muted {
    color: #94a3b8 !important;
    font-size: 11px;
    margin-left: 6px;
}

html.dark-theme body.tickets .bootstrap-select .dropdown-menu li.active a span.text small.text-muted,
html.dark-theme body.tickets .bootstrap-select .dropdown-menu li.selected a span.text small.text-muted,
html.dark-theme body.tickets .bootstrap-select .dropdown-menu li a:hover span.text small.text-muted,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu li.active a span.text small.text-muted,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu li.selected a span.text small.text-muted,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu li a:hover span.text small.text-muted {
    color: #ffffff !important;
}

/* Barra de status ("Comece a digitar, para pesquisar", "Buscando...") e "sem resultados" */
html.dark-theme body.tickets .bootstrap-select .dropdown-menu .status,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu .status {
    background-color: #1e293b !important;
    border-top: 1px solid #334155;
    color: #94a3b8 !important;
}

html.dark-theme body.tickets .bootstrap-select .dropdown-menu li.no-results,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu li.no-results {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
}

/* Cabecalho de grupo (ex.: "Selecionado atualmente"): #93c5fd sobre #1e293b = 8.1:1 */
html.dark-theme body.tickets .bootstrap-select .dropdown-menu li.dropdown-header,
html.dark-theme body.ticket .bootstrap-select .dropdown-menu li.dropdown-header {
    color: #93c5fd !important;
    letter-spacing: 0.04em;
    padding: 6px 12px 4px;
}

/* --------------------------------------------------------------------------
   3. TAGS (tag-it) - campo com a mesma moldura dos demais campos do formulario
   -------------------------------------------------------------------------- */
body.tickets ul.tagit,
body.ticket ul.tagit {
    background-color: #ffffff;
    border: 1px solid #cbd5e1 !important; /* o tailwind.css do core zera a borda do ul.tagit */
    border-radius: 6px;
    box-shadow: none;
    min-height: 34px;
    padding: 1px 6px;
}

body.tickets ul.tagit:focus-within,
body.ticket ul.tagit:focus-within {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

body.tickets ul.tagit li.tagit-new input,
body.ticket ul.tagit li.tagit-new input {
    color: #0f172a;
    background: transparent;
}

html.dark-theme body.tickets ul.tagit,
html.dark-theme body.ticket ul.tagit {
    background-color: #0f172a;
    border-color: #334155 !important;
}

html.dark-theme body.tickets ul.tagit:focus-within,
html.dark-theme body.ticket ul.tagit:focus-within {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

html.dark-theme body.tickets ul.tagit li.tagit-new input,
html.dark-theme body.ticket ul.tagit li.tagit-new input {
    color: #f8fafc;
}

/* Sugestoes de tags (jQuery UI autocomplete) */
html.dark-theme ul.ui-autocomplete.ui-menu {
    background-color: #1e293b;
    border: 1px solid #334155;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

html.dark-theme ul.ui-autocomplete .ui-menu-item-wrapper {
    background: transparent;
    border: 0;
    color: #f1f5f9;
}

html.dark-theme ul.ui-autocomplete .ui-menu-item-wrapper.ui-state-active,
html.dark-theme ul.ui-autocomplete .ui-menu-item-wrapper.ui-state-focus {
    background-color: #2563eb;
    border: 0;
    color: #ffffff;
    margin: 0;
}

/* --------------------------------------------------------------------------
   4. STATUS DA SOLICITACAO (pills com cor vinda do banco)
   O core grava color/background inline (cor do status e a mesma cor clareada em 96%) e o
   tema escuro forca span{color:#cbd5e1!important}: texto claro sobre fundo claro (1,4:1).
   No tema escuro a pill vira chip escuro com texto #f1f5f9 (13,3:1 sobre #1e293b); o matiz
   do status continua na borda inline (cor do status clareada), que o core ja define.
   -------------------------------------------------------------------------- */
html.dark-theme body.tickets .label[style*="color"],
html.dark-theme body.ticket .label[style*="color"] {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

/* Ponto com o matiz do status: herda a cor da borda inline (cor do status clareada). */
html.dark-theme body.tickets .label[style*="color"]::before,
html.dark-theme body.ticket .label[style*="color"]::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 5px;
    border: 3.5px solid;
    border-color: inherit;
    border-radius: 50%;
    vertical-align: 1px;
}
