/* =========================================
   1. VARIÁVEIS & TOKENS (Design System)
   ========================================= */
:root {
  /* Cores - Modo Claro (Padrão) */
  --bg-color: #f8fafc;
  --bg-gradient: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
  --surface: rgba(255, 255, 255, 0.7);
  --surface-border: rgba(255, 255, 255, 0.5);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  
  /* Cores Semânticas (Quadrantes) */
  --q1-color: rgba(239, 68, 68, 0.1); /* Importante & Urgente */
  --q2-color: rgba(59, 130, 246, 0.1); /* Importante & Não Urgente */
  --q3-color: rgba(245, 158, 11, 0.1); /* Não Importante & Urgente */
  --q4-color: rgba(100, 116, 139, 0.1); /* Não Importante & Não Urgente */

  /* Tipografia Fluida (Min - Val - Max) */
  --text-xs: clamp(0.75rem, 0.7vw + 0.6rem, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8vw + 0.7rem, 1rem);
  --text-md: clamp(1rem, 1vw + 0.8rem, 1.125rem);
  --text-lg: clamp(1.25rem, 1.5vw + 1rem, 1.5rem);
  --text-xl: clamp(1.5rem, 2vw + 1.2rem, 2rem);

  /* Efeitos */
  --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Escuro (Ativado via JS no body ou data-theme) */
/* No seu seletor de modo escuro, adicione a mudança de background-image */
[data-theme="dark"] {
  --bg-color: #0f172a;
  --surface: rgba(30, 41, 59, 0.7);
  --surface-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Garanta que o body use a variável --bg-color corretamente */
[data-theme="dark"] body {
  background-color: var(--bg-color);
  /* Remove ou altera o gradiente claro para um mais escuro */
  background-image: 
    radial-gradient(at 80% 0%, hsla(239, 40%, 10%, 0.5) 0px, transparent 50%),
    radial-gradient(at 0% 50%, hsla(333, 40%, 10%, 0.5) 0px, transparent 50%);
}

/* =========================================
   2. RESET & BASE
   ========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background-color: var(--bg-color);
  /* Mesh gradient suave para o fundo */
  background-image: 
    radial-gradient(at 80% 0%, hsla(239, 84%, 87%, 0.5) 0px, transparent 50%),
    radial-gradient(at 0% 50%, hsla(333, 100%, 95%, 0.5) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  transition: var(--transition);
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
  
  &:hover {
    color: var(--primary-hover);
    text-decoration: underline;
  }
}

/* =========================================
   3. COMPONENTES GLOBAIS (Glassmorphism)
   ========================================= */
.quadrant, .login-container {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 2rem;
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
  
  & h2, & h1 {
    font-size: var(--text-xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

/* =========================================
   4. TELAS DE AUTENTICAÇÃO (Login, Register...)
   ========================================= */
.login-container {
  width: 100%;
  max-width: 420px;
  margin: auto;
  animation: fadeIn 0.5s ease-out;

  & .login-header {
    text-align: center;
    margin-bottom: 2rem;

    & h2 {
      font-size: var(--text-lg);
      margin-bottom: 0.5rem;
    }

    & .subtitle {
      color: var(--text-muted);
      font-size: var(--text-sm);
    }
  }
}

/* Formulários & Inputs */
.login-form, .input-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.input-group-vertical {
  gap: 0.5rem;

  & label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-main);
  }
}

.task-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: var(--transition);
  outline: none;

  [data-theme="dark"] & {
    background: rgba(0, 0, 0, 0.2);
  }

  &:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: var(--bg-color);
  }
}

/* Botões */
.login-btn, .add-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.875rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;

  &:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  }

  &:active {
    transform: translateY(0);
  }

  &.full-width {
    width: 100%;
  }

  & a {
    color: white;
    text-decoration: none;
    display: block;
    width: 100%;
  }
}

.login-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* =========================================
   5. APLICAÇÃO (Matriz de Eisenhower)
   ========================================= */
.site-header {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;

  & .logo h2 {
    font-size: var(--text-lg);
    margin: 0;
  }
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  border: 1px solid var(--surface-border);

  & .user-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
  }

  & .logout-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    font-weight: 600;
    cursor: pointer;
    font-size: var(--text-sm);
    
    &:hover {
      text-decoration: underline;
    }
  }
}

.matrix-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  
  & h2 {
    font-size: var(--text-lg);
  }

  & #theme-toggle {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 600;
    transition: var(--transition);

    &:hover {
      background: var(--surface-border);
    }
  }
}

/* BENTO GRID - O Coração da Matriz */
.eisenhower-matrix {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr; /* Mobile-first */

  /* Breakpoint para Tablets e Desktop */
  @media (min-width: 768px) {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Quadrantes Específicos */
.quadrant {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  min-height: 300px;
  
  & h3 {
    font-size: var(--text-md);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  & .subtitle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
  }

  /* Cores de Fundo Suaves para Identificação Visual */
  &.q1 { background-color: var(--q1-color); }
  &.q2 { background-color: var(--q2-color); }
  &.q3 { background-color: var(--q3-color); }
  &.q4 { background-color: var(--q4-color); }
}

/* Input Inline da Matriz */
.input-group {
  display: flex;
  gap: 0.5rem;

  & .task-input {
    flex: 1;
  }

  & .add-btn {
    padding: 0 1rem;
    font-size: 1.5rem;
    line-height: 1;
  }
}

/* Lista de Tarefas (Micro-interações) */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 250px;

  & li {
    background: var(--bg-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--surface-border);
    font-size: var(--text-sm);
    transition: var(--transition);
    cursor: grab;

    &:hover {
      transform: translateX(4px);
      box-shadow: var(--shadow-glass);
    }
  }
}

/* =========================================
   6. UTILITÁRIOS & ANIMAÇÕES
   ========================================= */
.hidden {
  display: none !important;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--surface-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

/* Toast Notification (Acessível e animado) */
#toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-main);
  color: var(--bg-color);
  padding: 1rem 2rem;
  border-radius: 50px;
  font-weight: 500;
  font-size: var(--text-sm);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
  pointer-events: none;

  &.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}