/* Super App: cores, layout, menu lateral/gaveta, grupos e cartões (SUPER-1, SUPER-2).
   Cores da marca Climoo. Toda cor tem a versão escura. */

:root {
  --primary: #210856;
  --primary-hover: #2b0a70;
  --on-primary: #ffffff;
  --cyan: #5ce1e6;
  --sidebar-bg: #210856;
  --sidebar-fg: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-muted: rgba(255, 255, 255, 0.7);
  --focus: #9354e0;
  --text-1: #1f2937;
  --text-2: #374151;
  --text-3: #6b7280;
  --border: #e5e7eb;
  --bg-layout: #f4f7fe;
  --surface: #ffffff;
  --icon-bg: #f3ecfd;
  --icon-fg: #6b3fc1;
  --backdrop: rgba(15, 16, 18, 0.5);
  --error-bg: #fef2f2;
  --error-fg: #991b1b;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
  --sidebar-w: 240px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --primary: #c6a6f5;
  --primary-hover: #d9c4f9;
  --on-primary: #1c0d42;
  --sidebar-bg: #1c0d42;
  --sidebar-fg: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-muted: rgba(255, 255, 255, 0.64);
  --focus: #5ce1e6;
  --text-1: #ececee;
  --text-2: #c9cad0;
  --text-3: #9b9da7;
  --border: #2f3137;
  --bg-layout: #0f1012;
  --surface: #17181b;
  --icon-bg: rgba(147, 84, 224, 0.2);
  --icon-fg: #c6a6f5;
  --backdrop: rgba(0, 0, 0, 0.6);
  --error-bg: rgba(239, 68, 68, 0.15);
  --error-fg: #fca5a5;
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: hidden;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-layout);
  color: var(--text-1);
  line-height: 1.5;
}

svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 50;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--text-1);
  border-radius: 8px;
}
.skip-link:focus {
  top: 8px;
}

/* Botões só de ícone: alvo de toque de 44px. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-fg);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--sidebar-hover);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
  color: var(--sidebar-fg);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}
.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cabeçalho: só no celular (< 768px). */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--sidebar-bg);
}
.topbar .brand {
  flex: 1;
}

/* Menu lateral; no celular vira gaveta. */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(var(--sidebar-w), 85vw);
  padding: 8px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  overflow-y: auto;
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0.2s;
}
.drawer-open .sidebar {
  transform: none;
  visibility: visible;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 8px;
}
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--backdrop);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-fg);
  font: inherit;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover {
  background: var(--sidebar-hover);
}
.nav-item[aria-current='page'] {
  background: var(--sidebar-hover);
  box-shadow: inset 3px 0 0 var(--cyan);
}
/* Título do grupo no menu: texto pequeno, sem alvo de toque (não é link). */
.nav-group {
  padding: 16px 12px 4px;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-group span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  padding: 20px 16px 32px;
  outline: none;
}
.main h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}
.lead {
  margin: 0 0 20px;
  color: var(--text-3);
}

/* Grupos da página inicial: título e grade de cartões. */
.group + .group {
  margin-top: 28px;
}
.group-title {
  margin: 0 0 12px;
  color: var(--text-3);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.load-error {
  margin: 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-fg);
}

/* Cartões dos apps. */
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.card-head h3 {
  margin: 0;
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--icon-bg);
  color: var(--icon-fg);
  flex: none;
}
.card p {
  margin: 0;
  flex: 1;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  text-decoration: none;
}
.btn:hover {
  background: var(--primary-hover);
}

/* Botão de tema do menu: no celular, o cabeçalho já tem o botão. */
.theme-side {
  display: none;
}

/* Tablet e desktop: menu lateral fixo, sem cabeçalho e sem gaveta. */
@media (min-width: 768px) {
  .topbar,
  .menu-close,
  .backdrop {
    display: none;
  }
  .sidebar {
    transform: none;
    visibility: visible;
    transition: none;
  }
  .theme-side {
    display: flex;
  }
  .main {
    margin-left: var(--sidebar-w);
    padding: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
