/**
 * tecsys_tasks — estilos.
 *
 * ⚠️ LIÇÃO HERDADA DO tecsys_calendar (e repetida por mim na 1ª versão deste
 * plugin): o Elastic usa variáveis **LESS** (@color-main), compiladas em build
 * — NÃO variáveis CSS. Escrever `var(--color-border)` não resolve nada: cai
 * sempre no fallback hexadecimal, ignora o tema da skin e quebra o dark mode.
 *
 * Regras desta folha:
 *   1. Não inventar cor de texto nem de fundo — herdar do tema.
 *   2. Separação visual com rgba() neutro, que funciona sobre claro e escuro.
 *   3. Realce: `currentColor`, que segue a cor do tema ativo.
 *   4. Dark mode: regra explícita sob `html.dark-mode`.
 */

/* ==========================================================================
   COLUNA DE FILTROS
   ========================================================================== */

#tt-filters { margin: 0; padding: .35rem 0; }

#tt-filters a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .9rem;
}

.tt-f-label { flex: 1 1 auto; min-width: 0; }

.tt-count {
    flex: 0 0 auto;
    min-width: 1.4rem;
    padding: 0 .4rem;
    border-radius: 10px;
    font-size: .72rem;
    line-height: 1.35rem;
    text-align: center;
    opacity: .75;
    background-color: rgba(128, 128, 128, .18);
}
#tt-filters a.selected .tt-count { opacity: 1; }
html.dark-mode .tt-count { background-color: rgba(255, 255, 255, .14); }

/* ==========================================================================
   TOOLBAR — filtro ativo à esquerda, "nova tarefa" à direita
   Mesmo lugar do "+ Novo evento" do calendário: abaixo do cabeçalho.
   ========================================================================== */

.tt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .35rem .75rem;
    border-bottom: 1px solid rgba(128, 128, 128, .2);
}
html.dark-mode .tt-toolbar { border-bottom-color: rgba(255, 255, 255, .12); }

.tt-current-filter {
    font-weight: 600;
    font-size: .95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-toolbar #tt-new {
    flex: 0 0 auto;
    margin-left: auto;
    padding: .25rem .8rem;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}
.tt-toolbar #tt-new:hover { background-color: rgba(128, 128, 128, .2); }
html.dark-mode .tt-toolbar #tt-new:hover { background-color: rgba(255, 255, 255, .14); }

/* ==========================================================================
   FILTRO SELECIONADO — precisa ser óbvio qual está ativo
   ========================================================================== */

#tt-filters li > a.selected {
    background-color: rgba(128, 128, 128, .16);
    font-weight: 600;
    box-shadow: inset 3px 0 0 0 currentColor;   /* faixa que segue a cor do tema */
}
html.dark-mode #tt-filters li > a.selected {
    background-color: rgba(255, 255, 255, .12);
}
#tt-filters li > a:hover { background-color: rgba(128, 128, 128, .1); }
html.dark-mode #tt-filters li > a:hover { background-color: rgba(255, 255, 255, .07); }

/* ==========================================================================
   LISTA
   ========================================================================== */

/* ---- ROLAGEM DA LISTA ----
 * Sem isto a lista não rola: com 40 tarefas, o `.scroller` vinha com
 * `overflow-y: visible` e crescia junto com o conteúdo — o que passa da tela
 * fica inalcançável (o Felipe não conseguia nem testar). Verificado no
 * navegador: altura_visivel == altura_conteudo == 623 e `rola: false`.
 *
 * Três peças, e todas as três são necessárias:
 *   1. o container vira flex column, para o scroller poder receber a sobra;
 *   2. `flex: 1 1 auto` faz o scroller ocupar só o espaço restante;
 *   3. `min-height: 0` é o pulo do gato — sem ele um item flex NÃO encolhe
 *      abaixo do tamanho do próprio conteúdo, então nunca há overflow para
 *      rolar. É o erro clássico de flexbox com área rolável.
 * Rolagem nativa cobre qualquer volume; não precisa de paginação.
 */
#layout-content.tt-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#layout-content.tt-main > .header,
#layout-content.tt-main > .tt-toolbar {
    flex: 0 0 auto;
}
#layout-content.tt-main .scroller {
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;   /* rolagem com inércia no iOS */
}

#tt-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tt-item {
    display: flex;
    align-items: center;        /* uma linha só: checkbox, texto, prazo */
    gap: .75rem;
    padding: .55rem 1rem;
    border-bottom: 1px solid rgba(128, 128, 128, .18);
    cursor: pointer;
    transition: background-color .12s;
}
.tt-item:hover { background-color: rgba(128, 128, 128, .1); }
html.dark-mode .tt-item { border-bottom-color: rgba(255, 255, 255, .1); }
html.dark-mode .tt-item:hover { background-color: rgba(255, 255, 255, .07); }

/* Faixa de estado à esquerda: dá ritmo visual sem depender de cor de tema. */
.tt-item {
    border-left: 3px solid transparent;
}
.tt-item.tt-overdue { border-left-color: #e05252; }
.tt-item.tt-today   { border-left-color: #e0a800; }

.tt-check {
    flex: 0 0 auto;
    margin: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.tt-check input { margin: 0; cursor: pointer; }

.tt-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: .6rem;
}

/* Título não encolhe até desaparecer: ele é o que importa. Só cede espaço
   depois que a descrição já encolheu (ver flex-shrink dos dois). */
.tt-title {
    flex: 0 1 auto;
    min-width: 4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- descrição ao lado do título ----
 * Separador "·" vem do ::before, não do texto: assim ele não entra na seleção
 * quando alguém copia a linha, e some junto com a descrição quando não há uma.
 * Mais apagado que o título de propósito — é contexto, não conteúdo principal.
 */
.tt-desc {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .6;
    font-size: .9em;
}
.tt-desc::before {
    content: "·";
    display: inline-block;
    margin: 0 .45rem;
    opacity: .75;
}
/* Concluída já está apagada no item inteiro; apagar a descrição de novo a
   deixaria ilegível. */
.tt-item.tt-done .tt-desc { opacity: .85; }

/* Prazo alinhado à direita, discreto — não compete com o título. */
.tt-due {
    flex: 0 0 auto;
    font-size: .8rem;
    opacity: .65;
    font-variant-numeric: tabular-nums;
}

.tt-item.tt-overdue .tt-due { color: #e05252; opacity: 1; font-weight: 600; }
.tt-item.tt-today   .tt-due { opacity: 1; font-weight: 600; }

/* Concluída: risca e apaga, sem sumir. */
.tt-item.tt-done .tt-title { text-decoration: line-through; }
.tt-item.tt-done { opacity: .55; }
.tt-item.tt-done .tt-due { color: inherit; font-weight: normal; }

.tt-empty {
    padding: 3rem 1rem;
    text-align: center;
    opacity: .6;
    font-size: .95rem;
}

/* ==========================================================================
   DIÁLOGO
   Mesma estrutura do tecsys_calendar: a cadeia de largura inteira a 100%.
   Um único `auto` no meio faz o conteúdo encolher e sobrar espaço à direita.
   !important porque o show_popup_dialog recalcula e escreve style inline.
   ========================================================================== */

.ui-dialog.tt-dialog {
    width: 520px !important;
    max-width: 92vw !important;
    height: auto !important;
    max-height: 90vh !important;
    box-sizing: border-box;
}

.ui-dialog.tt-dialog .ui-dialog-content,
.ui-dialog.tt-dialog .ui-dialog-content > .popup,
.ui-dialog.tt-dialog .tt-dialog-body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.ui-dialog.tt-dialog .ui-dialog-content {
    height: auto !important;
    max-height: calc(90vh - 8.5rem) !important;
    overflow-y: auto;
    padding: .9rem 1rem !important;
}
.ui-dialog.tt-dialog .ui-dialog-content > .popup { padding: 0 !important; }
.ui-dialog.tt-dialog .tt-dialog-body { padding: 0 !important; }

/* -- Campos */
.tt-dialog .tt-field { width: 100%; box-sizing: border-box; margin-bottom: .85rem; }
.tt-dialog .tt-field:last-child { margin-bottom: 0; }

.tt-dialog .tt-field > label {
    display: block;
    margin-bottom: .25rem;
    font-size: .8rem;
    font-weight: 600;
    opacity: 1;
    color: inherit;
}
html.dark-mode .tt-dialog .tt-field > label { color: rgba(255, 255, 255, .82); }

.tt-dialog .tt-field > input,
.tt-dialog .tt-field > textarea {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: .42rem .55rem;
    border: 1px solid rgba(128, 128, 128, .4);
    border-radius: 4px;
    background-color: rgba(128, 128, 128, .08);
    color: inherit;
    font-size: .92rem;
    font-family: inherit;
}
.tt-dialog .tt-field > textarea { resize: vertical; min-height: 5rem; }

html.dark-mode .tt-dialog .tt-field > input,
html.dark-mode .tt-dialog .tt-field > textarea {
    border-color: rgba(255, 255, 255, .25);
    background-color: rgba(255, 255, 255, .06);
    color: #fff;
}

/* -- Cabeçalho: título + só o X, sem card */
.ui-dialog.tt-dialog .ui-dialog-titlebar {
    position: relative;
    padding: .55rem 2.6rem .55rem .9rem;
    min-height: 0;
    height: auto;
}
.ui-dialog.tt-dialog .ui-dialog-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
    padding: 0;
    width: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ui-dialog.tt-dialog .ui-dialog-titlebar [class*="close"] {
    position: absolute !important;
    right: .7rem;
    top: 50%;
    transform: translateY(-50%);
    margin: 0 !important;
    width: 1.6rem;
    height: 1.6rem;
    line-height: 1.6rem;
    padding: 0;
    text-align: center;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 3px;
    opacity: .7;
}
.ui-dialog.tt-dialog .ui-dialog-titlebar [class*="close"]:hover {
    opacity: 1;
    background-color: rgba(128, 128, 128, .2) !important;
}
html.dark-mode .ui-dialog.tt-dialog .ui-dialog-titlebar [class*="close"]:hover {
    background-color: rgba(255, 255, 255, .16) !important;
}

.ui-dialog.tt-dialog .ui-dialog-buttonpane { padding: .6rem .9rem; margin-top: 0; }

@media screen and (max-width: 600px) {
    .ui-dialog.tt-dialog { width: 94vw !important; }
    .tt-item { padding: .55rem .75rem; }
    .tt-body { flex-wrap: wrap; gap: .15rem; }
    .tt-title { white-space: normal; }
}
