/* ════════════════════════════════════════════════════════════════
   GerenciaSuporte — Sistema de tema (claro/escuro) + acessibilidade
   ────────────────────────────────────────────────────────────────
   Otimizado para baixa visão (ceratocone, astigmatismo, miopia):

    • Fonte "Atkinson Hyperlegible" (Braille Institute) — desenhada
      para máxima legibilidade
    • Peso 450 no corpo — letras mais espessas reduzem esforço
    • Tamanho base 16.5px → ajustável A−/A+ (50%-160%)
    • Line-height 1.65 (respira mais)
    • Letter-spacing 0.005em — separa as letras
    • Contraste alto em ambos os temas
    • Sombras suaves — sombras fortes viram borrão duplo no astigmatismo
    • Foco 3px outline em primary — fácil rastrear
    • Mínimo 44×44 em clickables (alvo grande)
    • Underline visível em links
    • prefers-reduced-motion respeitado
   ════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* ──────────────── TIPOGRAFIA ACESSÍVEL ──────────────── */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  font-size: 16.5px;
}
body {
  font-family:
    "Atkinson Hyperlegible",
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-weight: 450;
  line-height: 1.65;
  letter-spacing: 0.005em;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-top: 0;
}
h1 { font-size: 2rem;    margin-bottom: 0.6em; }
h2 { font-size: 1.55rem; margin-bottom: 0.55em; }
h3 { font-size: 1.25rem; margin-bottom: 0.5em; }
h4 { font-size: 1.1rem;  margin-bottom: 0.4em; }
p  { margin-bottom: 1em; }

code, kbd, pre, samp, .num {
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  font-size: 0.95em;
  font-weight: 500;
}
td, th { font-variant-numeric: tabular-nums; }

/* Links com underline visível, exceto botões e nav */
a:not(.glow-button):not(.btn):not(.btn-secondary):not(.btn-primary):not(.modern-submit-btn):not(.send-btn):not(.respond-button):not(.view-conv-button):not(.view-image-button):not(.nav-item):not(.sidebar-link):not(.file-upload-btn):not(.pwd-toggle):not(.cred-copy-btn):not(.lb-close):not(.lb-prev):not(.lb-next):not(.attach-clear):not(.attach-remove):not(.scroll-bottom-btn):not(.gs-theme-toggle):not(.gs-fontsize-btn) {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: currentColor;
  text-decoration-skip-ink: auto;
}

/* ──────────────── TEMA ESCURO (default) ──────────────── */
:root,
:root[data-theme="dark"] {
  --primary:        #60a5fa;
  --primary-hover:  #3b82f6;
  --primary-light:  rgba(96,165,250,0.16);
  --primary-glow:   rgba(96,165,250,0.10);
  --primary-dark:   #2563eb;

  --secondary:       #34d399;
  --secondary-light: rgba(52,211,153,0.14);
  --danger:          #f87171;
  --danger-light:    rgba(248,113,113,0.16);
  --warning:         #fbbf24;
  --warning-light:   rgba(251,191,36,0.16);
  --info:            #22d3ee;
  --info-light:      rgba(34,211,238,0.14);

  --bg:              #0a0a0c;
  --bg-card:         #16161a;
  --bg-card-hover:   #1f1f24;
  --bg-elevated:     #25252b;
  --bg-input:        #111114;
  --bg-sidebar:      #0d0d10;

  --border:          rgba(255,255,255,0.14);
  --border-subtle:   rgba(255,255,255,0.08);
  --border-focus:    rgba(96,165,250,0.6);

  --text:            #fafafa;
  --text-secondary:  #d4d4d8;
  --text-muted:      #a1a1aa;
  --text-sidebar:    #f4f4f5;

  --shadow:        0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:     0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg:     0 4px 12px rgba(0,0,0,0.4);
  --shadow-glow:   0 0 0 3px rgba(96,165,250,0.18);

  color-scheme: dark;
}

/* ──────────────── TEMA CLARO ──────────────── */
:root[data-theme="light"] {
  --primary:        #1d4ed8;
  --primary-hover:  #1e40af;
  --primary-light:  rgba(29,78,216,0.10);
  --primary-glow:   rgba(29,78,216,0.06);
  --primary-dark:   #1e3a8a;

  --secondary:       #047857;
  --secondary-light: rgba(4,120,87,0.10);
  --danger:          #b91c1c;
  --danger-light:    rgba(185,28,28,0.10);
  --warning:         #b45309;
  --warning-light:   rgba(180,83,9,0.10);
  --info:            #0e7490;
  --info-light:      rgba(14,116,144,0.10);

  --bg:              #f5f5f4;
  --bg-card:         #ffffff;
  --bg-card-hover:   #fafafa;
  --bg-elevated:     #ffffff;
  --bg-input:        #ffffff;
  --bg-sidebar:      #ffffff;

  --border:          rgba(0,0,0,0.18);
  --border-subtle:   rgba(0,0,0,0.10);
  --border-focus:    rgba(29,78,216,0.5);

  --text:            #0a0a0a;
  --text-secondary:  #18181b;
  --text-muted:      #52525b;
  --text-sidebar:    #09090b;

  --shadow:        0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:     0 4px 12px rgba(0,0,0,0.08);
  --shadow-glow:   0 0 0 3px rgba(29,78,216,0.18);

  color-scheme: light;
}

:root.theme-transitioning,
:root.theme-transitioning *,
:root.theme-transitioning *::before,
:root.theme-transitioning *::after {
  transition: background-color 0.25s ease, color 0.25s ease,
              border-color 0.25s ease, box-shadow 0.25s ease !important;
  transition-delay: 0 !important;
}

/* ──────────────── ELEMENTOS CLICÁVEIS ──────────────── */
button,
.btn,
.glow-button,
.btn-secondary,
.btn-primary,
.modern-submit-btn,
.respond-button,
.view-conv-button,
.view-image-button,
input[type="submit"],
input[type="button"] {
  min-height: 44px;
  padding: 11px 18px;
  font-size: 0.96rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 8px;
}

input:not([type=checkbox]):not([type=radio]):not([type=file]),
textarea,
select {
  font-size: 1rem;
  min-height: 44px;
  padding: 11px 14px;
  border-width: 1.5px;
}

*:focus-visible {
  outline: 3px solid var(--primary) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

::selection {
  background: var(--primary);
  color: #ffffff;
}

/* ──────────────── LAYOUT GERAL ──────────────── */
.card,
.gs-card,
.modern-form-container,
.produto-card,
.cliente-card,
.status-card,
.audit-table,
.check-list li {
  padding: 20px 24px;
  border-radius: 12px;
  border-width: 1px;
}

table th,
table td {
  padding: 14px;
  line-height: 1.55;
}
table th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ──────────────── AJUSTES TEMA CLARO ──────────────── */
:root[data-theme="light"] body {
  background: var(--bg);
  color: var(--text);
}
:root[data-theme="light"] .card,
:root[data-theme="light"] .gs-card,
:root[data-theme="light"] .modern-form-container,
:root[data-theme="light"] .status-card,
:root[data-theme="light"] .ticket-card,
:root[data-theme="light"] .quick-action-card,
:root[data-theme="light"] .produto-card,
:root[data-theme="light"] .cliente-card,
:root[data-theme="light"] .check-list li,
:root[data-theme="light"] .audit-table {
  box-shadow: var(--shadow);
}
:root[data-theme="light"] .sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}
:root[data-theme="light"] .sidebar-link { color: var(--text-sidebar); }
:root[data-theme="light"] .sidebar-link:hover { background: var(--bg-card-hover); }
:root[data-theme="light"] .sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
:root[data-theme="light"] .topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea,
:root[data-theme="light"] .modern-input,
:root[data-theme="light"] .modern-select,
:root[data-theme="light"] .modern-textarea {
  background: var(--bg-input);
  border-color: var(--border);
  color: var(--text);
}
:root[data-theme="light"] input:focus,
:root[data-theme="light"] select:focus,
:root[data-theme="light"] textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
:root[data-theme="light"] .btn-secondary,
:root[data-theme="light"] .glow-button {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
}
:root[data-theme="light"] .glow-button:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}
:root[data-theme="light"] table,
:root[data-theme="light"] .data-table,
:root[data-theme="light"] .audit-table { background: var(--bg-card); }
:root[data-theme="light"] th {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
:root[data-theme="light"] tr { border-bottom: 1px solid var(--border-subtle); }
:root[data-theme="light"] tr:hover { background: var(--bg-card-hover); }
:root[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 600px 600px at 10% 20%, rgba(29,78,216,0.03) 0%, transparent 70%),
    radial-gradient(ellipse 500px 500px at 90% 80%, rgba(4,120,87,0.02) 0%, transparent 70%) !important;
}
:root[data-theme="light"] .chat-history .chat-message {
  background: var(--bg-card);
  border-color: var(--border);
}
:root[data-theme="light"] .chat-history .chat-message.bubble-owner  { background: rgba(168,85,247,0.06); border-color: rgba(168,85,247,0.30); }
:root[data-theme="light"] .chat-history .chat-message.bubble-admin  { background: rgba(29,78,216,0.06);  border-color: rgba(29,78,216,0.30); }
:root[data-theme="light"] .chat-history .chat-message.bubble-user   { background: rgba(4,120,87,0.06);   border-color: rgba(4,120,87,0.30); }
:root[data-theme="light"] .chat-history .chat-message.bubble-system { background: rgba(180,83,9,0.08);   border-color: rgba(180,83,9,0.30); }
:root[data-theme="light"] .msg-avatar {
  background: var(--bg-card-hover);
  color: var(--text);
}

.gs-lightbox { background: rgba(0,0,0,0.94) !important; }

:root[data-theme="light"] ::-webkit-scrollbar { width: 14px; height: 14px; }
:root[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.20);
  border-radius: 7px;
  border: 3px solid var(--bg);
}
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); }

/* ──────────────── BOTÕES FLUTUANTES (tema + tamanho fonte) ──────────────── */
.gs-fab-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 998;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.gs-theme-toggle,
.gs-fontsize-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
  line-height: 1;
}
.gs-theme-toggle:hover,
.gs-fontsize-btn:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  border-color: var(--primary);
}
.gs-theme-toggle:active, .gs-fontsize-btn:active { transform: translateY(0); }

.gs-fontsize-group {
  display: flex;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.gs-fontsize-group .gs-fontsize-btn {
  width: 40px;
  height: 40px;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}
.gs-fontsize-group .gs-fontsize-btn:not(:last-child) {
  border-right: 1px solid var(--border-subtle);
}
.gs-fontsize-group .gs-fontsize-btn:hover {
  background: var(--bg-card-hover);
  transform: none;
}

.gs-theme-toggle .gs-theme-icon { display: block; line-height: 1; font-size: 1.4rem; }
:root[data-theme="dark"]  .gs-theme-toggle .gs-icon-sun  { display: block; }
:root[data-theme="dark"]  .gs-theme-toggle .gs-icon-moon { display: none; }
:root[data-theme="light"] .gs-theme-toggle .gs-icon-sun  { display: none; }
:root[data-theme="light"] .gs-theme-toggle .gs-icon-moon { display: block; }
:root:not([data-theme="light"]) .gs-theme-toggle .gs-icon-sun  { display: block; }
:root:not([data-theme="light"]) .gs-theme-toggle .gs-icon-moon { display: none; }

@media (max-width: 640px) {
  .gs-fab-stack { bottom: 16px; right: 16px; gap: 8px; }
  .gs-theme-toggle, .gs-fontsize-btn { width: 44px; height: 44px; }
  .gs-fontsize-group .gs-fontsize-btn { width: 38px; height: 38px; }
}

/* ──────────────── PREFERS-REDUCED-MOTION ──────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
