﻿/* ==========================================================================
   TO-DO DIAMANTE — DESIGN SYSTEM & BASE STYLES
   Inspirado na usabilidade ágil do Todoist com elegância e sofisticação
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root, [data-theme="light"] {
  /* Paleta Padrão To-Do Diamante — Layout Claro & Moderno (Conforme Captura) */
  --bg-app: #f8fafc;              /* Fundo suave moderno cinza-azulado */
  --bg-sidebar: #ffffff;          /* Barra lateral branca limpa e cristalina */
  --bg-surface: #ffffff;          /* Cartões brancos nítidos e modais */
  --bg-surface-elevated: #f1f5f9; /* Áreas elevadas, chips e inputs */
  --bg-surface-hover: #e2e8f0;    /* Hover suave */
  --bg-glass: rgba(255, 255, 255, 0.95);

  --border-color: #e2e8f0;        /* Linhas e bordas limpas e elegantes */
  --border-subtle: #f1f5f9;
  --border-focus: #4f46e5;        /* Azul Índigo vibrante */

  --text-primary: #0f172a;        /* Grafite profundo com alta legibilidade */
  --text-secondary: #475569;      /* Texto de apoio refinado */
  --text-muted: #94a3b8;          /* Texto suave para metadados */
  --text-on-accent: #ffffff;

  /* Cores de Acento Diamante */
  --accent-primary: #4f46e5;       /* Azul Índigo vibrante do botão e destaques */
  --accent-primary-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.22);

  --accent-cyan: #0284c7;          /* Azul ciano para tags e recorrência */
  --accent-emerald: #10b981;       /* Verde esmeralda para Hoje e conclusão */
  --accent-amber: #f59e0b;         /* Âmbar */
  --accent-rose: #ef4444;          /* Vermelho alerta */

  /* Prioridades */
  --p1-color: #ef4444; /* P1 Vermelho */
  --p2-color: #f97316; /* P2 Laranja */
  --p3-color: #3b82f6; /* P3 Azul */
  --p4-color: #94a3b8; /* P4 Cinza */

  /* Sombras sutis e modernas */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Dimensões */
  --sidebar-width: 280px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema Livro Antigo (Opcional) */
[data-theme="book"] {
  --bg-app: #f4eedb;
  --bg-sidebar: #eae0cd;
  --bg-surface: #fdfbf7;
  --bg-surface-elevated: #e7dac5;
  --bg-surface-hover: #ded1bb;
  --bg-glass: rgba(244, 238, 219, 0.92);

  --border-color: #d6c7b0;
  --border-subtle: rgba(160, 130, 90, 0.2);
  --border-focus: #92400e;

  --text-primary: #292017;
  --text-secondary: #574a3c;
  --text-muted: #837463;
  --text-on-accent: #ffffff;

  --accent-primary: #92400e;
  --accent-primary-hover: #78350f;
  --accent-glow: rgba(146, 64, 14, 0.22);

  --accent-cyan: #0f766e;
  --accent-emerald: #15803d;
  --accent-amber: #b45309;
  --accent-rose: #be123c;

  --p1-color: #b91c1c;
  --p2-color: #c2410c;
  --p3-color: #0369a1;
  --p4-color: #837463;

  --shadow-sm: 0 1px 3px rgba(60, 45, 30, 0.08);
  --shadow-md: 0 4px 10px rgba(60, 45, 30, 0.1);
  --shadow-lg: 0 10px 22px -5px rgba(60, 45, 30, 0.14);
  --shadow-modal: 0 25px 50px -12px rgba(45, 30, 15, 0.25);
}

/* Tema Escuro Noturno (Opcional) */
[data-theme="dark"] {
  --bg-app: #0d1117;
  --bg-sidebar: #131822;
  --bg-surface: #1a202c;
  --bg-surface-elevated: #242c3d;
  --bg-surface-hover: #2b3447;
  --bg-glass: rgba(26, 32, 44, 0.85);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-on-accent: #ffffff;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);

  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --p1-color: #ef4444;
  --p2-color: #f97316;
  --p3-color: #3b82f6;
  --p4-color: #64748b;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* Reset Global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Layout App Container — oculto até a autenticação ser confirmada */
.app-layout {
  display: none;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

body.authenticated .app-layout {
  display: flex;
}

body.authenticated .login-screen {
  display: none;
}

/* ==========================================================================
   TELA DE LOGIN
   ========================================================================== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-app);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 12px 32px rgba(31, 35, 51, 0.1);
  padding: 2rem 1.75rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-field input {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.login-error {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--p1-color, #ef4444);
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm, 6px);
  padding: 0.55rem 0.7rem;
}

/* ==========================================================================
   BARRA LATERAL (SIDEBAR)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-smooth);
  z-index: 50;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Estilização da Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

/* Itens de Navegação */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.nav-item:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--bg-surface-elevated);
  color: var(--accent-primary);
  font-weight: 600;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.badge-count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background-color: var(--border-color);
  color: var(--text-muted);
}

.badge-count.urgent {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--p1-color);
}

/* Árvore de Departamentos e Projetos */
.dept-group {
  margin-top: 0.25rem;
}

.dept-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dept-header:hover {
  color: var(--text-primary);
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem 0.45rem 1.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-item:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.project-item.active {
  background-color: var(--bg-surface-elevated);
  color: var(--accent-primary);
  font-weight: 600;
}

.project-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 0.5rem;
  display: inline-block;
  flex-shrink: 0;
}

/* Botão Nova Tarefa em Destaque no Sidebar */
.btn-sidebar-add {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #4f46e5 100%);
  color: white;
  border: none;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0.75rem;
  box-shadow: 0 4px 12px var(--accent-glow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  justify-content: center;
}

.btn-sidebar-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
}

/* ==========================================================================
   ÁREA PRINCIPAL (MAIN VIEWPORT)
   ========================================================================== */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-app);
}

/* Topbar Superior */
.topbar {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-toggle-sidebar {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.85rem;
  width: 260px;
  color: var(--text-secondary);
  transition: width var(--transition-smooth), border-color var(--transition-fast);
}

.search-box:focus-within {
  width: 320px;
  border-color: var(--border-focus);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 100%;
}

.kbd-shortcut {
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background-color: var(--border-color);
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-notifications {
  position: relative;
}

.notif-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--p1-color, #ef4444);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--bg-surface, #fff);
}

/* Seletor de Perfis (MASTER, Supervisor, Usuário) */
.user-switch-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.user-switch-badge:hover {
  background-color: var(--bg-surface-hover);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.user-role-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}
.user-role-tag.MASTER {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: white;
}
.user-role-tag.SUPERVISOR {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  color: white;
}
.user-role-tag.USER {
  background: #334155;
  color: #94a3b8;
}

/* Conteúdo da Página */
.page-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* Responsividade Mobile & Tablet */
@media (max-width: 900px) {
  .btn-toggle-sidebar {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 40;
  }
  .sidebar-backdrop.active {
    display: block;
  }
  .page-container {
    padding: 1.25rem;
  }
  .search-box {
    width: 160px;
  }
  .search-box:focus-within {
    width: 200px;
  }
}

/* Filtros rapidos: cabecalho que recolhe/expande a lista (comeca recolhido) */
.nav-header-toggle { width: 100%; color: var(--text-muted); background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; border-radius: 6px; }
.nav-header-toggle:hover { color: var(--text-primary); }
.nav-header-chevron { transition: transform .15s; transform: rotate(90deg); flex-shrink: 0; }
.nav-group.filters-collapsed .nav-header-chevron { transform: rotate(0deg); }
.nav-group.filters-collapsed #filters-list { display: none; }
.nav-group.filters-collapsed:has(#filters-list .nav-item.active) .nav-header-toggle span::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-primary); margin-left: 6px; vertical-align: middle; }
