/* GG Call — temas coloridos e personalizados, página "Tema", tema do perfil e acessibilidade.
   Carregado depois de theme-gg.css e antes de motion.css. As cores dos temas coloridos são calculadas
   em js/themes.js (variáveis --cw-* e --bg-*, aplicadas no <html> com a classe .colorway). */

/* ================================================================ temas coloridos */
/* O gradiente fica no fundo; barras e painéis recebem véus translúcidos (mais escuros no modo escuro,
   mais claros no claro), mantendo a hierarquia entre as camadas e o contraste do texto. */
:root.colorway body,
.colorway #app { background: var(--cw-gradient) fixed; }
.colorway .titlebar,
.colorway .rail { background: var(--cw-rail); }
.colorway .sidebar,
.colorway .side-panel { background: var(--cw-sidebar); }
.colorway .side-head { background: transparent; backdrop-filter: blur(16px); }
.colorway .voice-panel,
.colorway .user-panel { background: var(--cw-account); }
.colorway .main { background: var(--cw-chat); }
.colorway .modal-backdrop:has(> .modal.settings) { background: var(--cw-gradient); }
.colorway .modal.settings { background: transparent; }
.colorway .settings-sidebar { background: var(--cw-sidebar); }
.colorway .settings-main { background: var(--cw-chat); }
/* Separador de data sem "caixa" de fundo sólido sobre o gradiente. */
.colorway .day-divider:not(.new) { border-top: 0; gap: 8px; }
.colorway .day-divider:not(.new)::before,
.colorway .day-divider:not(.new)::after { content: ''; flex: 1; border-top: 1px solid var(--bg-active); }
.colorway .day-divider:not(.new) span { background: none; }
.colorway .msg.mentioned { box-shadow: inset 2px 0 0 var(--brand); }

/* ================================================================ página Tema */
.theme-label { margin-top: 20px; }
.theme-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 20px; }
.theme-tile {
  position: relative; flex: none; width: 60px; height: 60px; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.theme-tile:hover { transform: translateY(-2px); }
.theme-tile.active { box-shadow: 0 0 0 2px var(--bg-chat), 0 0 0 4px var(--brand); }
.theme-tile:focus-visible,
.theme-tile:has(input:focus-visible) { outline: 2px solid var(--link); outline-offset: 4px; }
.theme-tile.std.gg { background: linear-gradient(135deg, #101218 0 56%, #caf26d 56% 100%); }
.theme-tile.std.dark { background: linear-gradient(135deg, #36393e 0 50%, #2e3136 50% 100%); }
.theme-tile.std.amoled { background: #000; }
.theme-tile.std.light { background: linear-gradient(135deg, #fff 0 50%, #e9e9ea 50% 100%); }
.theme-tile.cycle { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-input); color: var(--text-channel); }
.theme-tile.cycle:hover { color: var(--text-strong); transform: rotate(-30deg); }
.theme-check {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--on-brand); box-shadow: 0 0 0 3px var(--bg-chat);
}
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, 72px); gap: 16px 14px; margin-bottom: 24px; }
.theme-cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.theme-cell .theme-tile { width: 72px; height: 72px; }
.theme-name { max-width: 100%; font-size: 0.75rem; line-height: 1rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-cell:has(.theme-tile.active) .theme-name { color: var(--text-strong); font-weight: 600; }
.theme-edit {
  position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); color: #fff; opacity: 0; transition: opacity 0.12s ease;
}
.theme-cell:hover .theme-edit,
.theme-edit:focus-visible { opacity: 1; }
.theme-edit:hover { background: rgba(0, 0, 0, 0.85); }
.theme-block > .field-label { margin-bottom: 12px; }
.theme-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.theme-section-head > span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.theme-section-head small { color: var(--text-muted); font-size: 0.8125rem; }
.theme-toggles { margin-bottom: 8px; border-top: 1px solid var(--bg-active); }

/* "Deixe do seu jeitinho" */
.theme-promo {
  display: flex; align-items: center; gap: 16px; padding: 16px; margin-bottom: 24px; border-radius: 10px;
  background: linear-gradient(115deg, rgba(202, 242, 109, 0.14), rgba(63, 109, 242, 0.12) 55%, rgba(255, 43, 214, 0.12)), var(--bg-sidebar);
  border: 1px solid var(--bg-active);
}
.theme-promo-art { width: 56px; height: 56px; flex: none; border-radius: 16px; background: conic-gradient(from 210deg, #caf26d, #2bd9a5, #3f6df2, #8a4ff0, #ff2bd6, #ff7a45, #caf26d); box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.18); }
.theme-promo-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.theme-promo-text strong { color: var(--text-strong); font-size: 1rem; }
.theme-promo-text span { color: var(--text-channel); font-size: 0.8125rem; line-height: 1.125rem; }

/* Criador de tema */
.theme-creator { padding: 16px; margin-bottom: 24px; border-radius: 10px; background: var(--bg-sidebar); border: 1px solid var(--bg-active); }
.theme-creator-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.theme-creator-head strong { color: var(--text-strong); font-size: 1rem; }
.theme-creator-head small { color: var(--text-muted); font-size: 0.8125rem; }
.theme-creator-body { display: flex; gap: 20px; align-items: flex-start; }
.theme-creator-fields { flex: 1; min-width: 0; }
.theme-creator .radio-group { margin: 0; }
.theme-creator .row-actions { margin: 4px 0 0; }
.ct-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ct-colors .color-input { width: 48px; height: 36px; }
.theme-sample { position: relative; width: 220px; flex: none; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), var(--shadow); }
.theme-sample i { position: absolute; top: 0; bottom: 0; }
.theme-sample i:nth-child(1) { left: 0; width: 13%; background: rgba(0, 0, 0, 0.55); }
.theme-sample i:nth-child(2) { left: 13%; width: 27%; background: rgba(0, 0, 0, 0.36); }
.theme-sample i:nth-child(3) { left: 46%; right: 8%; top: 22%; bottom: 30%; background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0 6px, transparent 6px 18px); border-radius: 3px; }
.theme-sample[data-mode='light'] i:nth-child(1) { background: rgba(255, 255, 255, 0.18); }
.theme-sample[data-mode='light'] i:nth-child(2) { background: rgba(255, 255, 255, 0.45); }
.theme-sample[data-mode='light'] i:nth-child(3) { background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.7) 0 6px, transparent 6px 18px); }

/* Configurações relacionadas */
.settings-pane > .related-row { padding: 12px 16px; margin-bottom: 8px; border: 1px solid var(--bg-active); border-radius: 8px; background: var(--bg-sidebar); color: var(--text-channel); }
.settings-pane > .related-row:hover { background: var(--bg-active); color: var(--text-strong); }

@media (max-width: 1100px) {
  .theme-creator-body { flex-direction: column-reverse; }
  .theme-sample { width: 100%; max-width: 280px; }
}

/* ================================================================ tema do perfil */
.pt-editor { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.pt-controls { flex: 1; min-width: 0; }
.pt-controls > .field-label { margin-bottom: 8px; }
.pt-colors { display: flex; gap: 16px; margin-bottom: 12px; }
.pt-colors label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-muted); cursor: pointer; }
.pt-preview { width: 250px; flex: none; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.pt-preview .card-avatar { display: inline-flex; margin-top: -40px; }
.pt-preview .card-name { font-size: 1.0625rem; font-weight: 700; color: var(--text-strong); }
.pt-preview .card-username { color: var(--text-channel); }
/* Cartão com tema do perfil (o real e a prévia): gradiente da pessoa, texto do modo calculado. */
.user-card.themed,
.pt-preview.themed { background: var(--pt-body); border-color: transparent; color: var(--text); }
.themed .card-banner { background: var(--pt-banner); }
.themed .card-avatar { background: var(--pt-ring); }
.themed .card-avatar .status-dot { border-color: var(--pt-ring); }
.themed .btn.secondary { background: var(--chip-bg); color: var(--text-strong); }
.themed .card-actions .icon-btn { color: var(--text-strong); }
@media (max-width: 1100px) { .pt-editor { flex-direction: column; } }

/* ================================================================ acessibilidade */
/* Saturação: filtro no documento inteiro (só ligado abaixo de 100%). */
:root.desaturated { filter: saturate(var(--saturation)); }

/* Alto contraste: texto mais forte, bordas e foco visíveis. !important para valer também sobre as
   variáveis dos temas coloridos (aplicadas direto no <html>). */
:root.high-contrast:not([data-theme='light']) {
  --text: #f6f4f1 !important;
  --text-channel: #ebe9e5 !important;
  --text-muted: #cfd2d8 !important;
  --bg-hover: rgba(255, 255, 255, 0.1) !important;
  --bg-active: rgba(255, 255, 255, 0.2) !important;
  --border: rgba(255, 255, 255, 0.3) !important;
  --float-border: rgba(255, 255, 255, 0.35) !important;
  --input-border: rgba(255, 255, 255, 0.5) !important;
}
:root.high-contrast[data-theme='light'] {
  --text: #000 !important;
  --text-channel: #111317 !important;
  --text-muted: #2a2d33 !important;
  --bg-hover: rgba(0, 0, 0, 0.08) !important;
  --bg-active: rgba(0, 0, 0, 0.16) !important;
  --border: rgba(0, 0, 0, 0.4) !important;
  --float-border: rgba(0, 0, 0, 0.45) !important;
  --input-border: rgba(0, 0, 0, 0.65) !important;
}
.high-contrast :focus-visible { outline: 3px solid var(--text-strong) !important; outline-offset: 2px; }
.high-contrast a, .high-contrast .link-btn { text-decoration: underline; }
.high-contrast .sidebar, .high-contrast .settings-sidebar { box-shadow: inset -1px 0 0 var(--border); }
.high-contrast .side-panel { box-shadow: inset 1px 0 0 var(--border); }
.high-contrast .composer-row, .high-contrast .btn.secondary { box-shadow: inset 0 0 0 1px var(--border); }
.high-contrast .nav-row.active, .high-contrast .settings-tab.active { box-shadow: inset 3px 0 0 var(--text-strong); }
/* Reduzir movimento: regras em styles.css (.reduce-motion e .allow-motion). */
