/**
 * BASE.CSS - Estilos base compartilhados
 * Inclui: Variáveis CSS, Reset, Componentes globais, Utilidades
 */

/* ============================================
   CSS VARIABLES (Dark Theme)
   ============================================ */
:root {
  /* Colors */
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --bg-tertiary: #151926;
  --card: #151926;
  --text: #e7ebf3;
  --text-secondary: #a7b0c0;
  --muted: #a7b0c0;
  --border: #233047;

  /* Brand Colors */
  --primary: #6aa2ff;
  --primary-2: #3a7bff;
  --primary-hover: #3a7bff;
  --secondary: #19c37d;
  --success: #19c37d;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Layout */
  --header-height: 15vh;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.24);

  /* Transitions */
  --transition: all 0.2s ease-in-out;
  --transition-fast: all 0.15s ease-in-out;

  /* Gradients */
  --gradient-app-header: linear-gradient(135deg, #0e1a33 0%, #0b1220 50%, #0e1a33 100%);
}

/* ============================================
   FOCUS VISIBLE (Accessibility)
   ============================================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-contrast: high) {
  button, input, select, textarea { border: 2px solid currentColor; }
}

/* ============================================
   CSS RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-padding-top: var(--header-height);
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  min-width: 375px;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #0e1117 100%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  margin: 24px 0 12px;
  font-weight: 600;
  color: var(--text);
}

h1 { font-size: 2.5rem; font-weight: 700; }
h2 { font-size: 1.875rem; color: #d7def0; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; color: var(--muted); }

p {
  margin: 0 0 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11,13,18,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

header .wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
}

header > div > a {
  display: contents;
}

.logo {
  width: 5%;
  min-width: 40px;
  height: auto;
  aspect-ratio: 1 / 1;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

nav a {
  padding: 8px 12px;
  border-radius: var(--border-radius);
  font-weight: 600;
  color: var(--muted);
  transition: var(--transition);
}

nav a.active,
nav a:hover {
  color: var(--text);
  background: rgba(106, 162, 255, 0.1);
  text-decoration: none;
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

.container div a {
  padding: 8px 12px;
  text-decoration: none;
}

.hero {
  padding: 48px 0 32px;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  margin: 0 0 16px;
  background: linear-gradient(135deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero h2 {
  font-size: 1.25rem;
  color: var(--muted);
  margin: 0 0 24px;
  font-weight: 400;
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.card h3 {
  margin-top: 0;
  color: var(--text);
  font-size: 1.2rem;
}

.card p {
  color: var(--muted);
  line-height: 1.6;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn,
button.btn,
input[type="button"],
input[type="submit"] {
  appearance: none;
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95em;
  color: var(--text);
  background: var(--bg-tertiary);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.btn:hover,
button.btn:hover {
  background: var(--bg-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-2), #2563eb);
  box-shadow: 0 8px 20px rgba(106, 162, 255, 0.3);
}

.btn.secondary {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn.ghost {
  background: transparent;
  border-color: var(--muted);
  color: var(--muted);
}

.btn.ghost:hover {
  background: rgba(167, 176, 192, 0.1);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   FORMS
   ============================================ */
input,
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  background: var(--bg-tertiary);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95em;
  transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(106, 162, 255, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

/* ============================================
   GRID SYSTEM
   ============================================ */
.grid {
  display: grid;
  gap: 24px;
}

.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(106, 162, 255, 0.2), transparent);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  to { left: 100%; }
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden { display: none; }
.visible { display: block; }
.none { display: none; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: 16px 20px;
  border-radius: 12px;
  margin: 20px 0;
  border-left: 4px solid;
}

.alert.success {
  background: rgba(25, 195, 125, 0.1);
  border-color: var(--success);
  color: #22c55e;
}

.alert.danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: #ef4444;
}

.alert.warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning);
  color: #f59e0b;
}

/* ============================================
   TOOLTIPS
   ============================================ */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border: 1px solid var(--border);
  z-index: 10;
}

.tooltip:hover::before {
  opacity: 1;
}

/* ============================================
   COOKIE BANNER
   ============================================ */
.cookie-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: linear-gradient(135deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  backdrop-filter: blur(12px);
  max-width: 600px;
  width: calc(100% - 40px);
}

.cookie-banner p {
  margin: 0 0 16px;
  color: var(--text);
  text-align: center;
  font-size: 0.9em;
  line-height: 1.5;
}

.cookie-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.cookie-actions .btn {
  padding: 10px 16px;
  font-size: 0.9em;
  min-width: 120px;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: 48px;
  text-align: center;
}

footer p {
  color: var(--muted);
  margin: 8px 0;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0;
  visibility: hidden;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-to-top:hover {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.6);
}

.back-to-top:active {
  transform: translateY(-2px) scale(1.02);
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
  animation: pulse 3s infinite;
}

/* Ícone SVG personalizado */
.back-to-top svg {
  width: 24px;
  height: 24px;
  fill: white;
  transition: transform 0.3s ease;
}

.back-to-top:hover svg {
  transform: translateY(-2px);
}

/* Efeito de pulso sutil */
@keyframes pulse {
  0% { box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.7); }
  100% { box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4); }
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notification-popup {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--success);
  color: white;
  padding: 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  max-width: 400px;
  animation: slideIn 0.3s ease-out;
}

.notification-content {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.notification-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.notification-close:hover {
  opacity: 1;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  :root {
    --border: #4a5568;
    --muted: #cbd5e0;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .hero h1 { font-size: 2.5rem; }
}

@media (max-width: 768px) {
  header .wrap {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .logo {
    display: none;
  }

  .container { padding: 16px; }
  .card { padding: 16px; }
  nav { justify-content: center; }
  .hero { padding: 32px 0 24px; }
  .hero h1 { font-size: 2rem; }

  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
  }

  .back-to-top svg {
    width: 20px;
    height: 20px;
  }

  .cookie-banner {
    bottom: 10px;
    padding: 16px;
    max-width: none;
    width: calc(100% - 20px);
  }

  .cookie-banner p {
    font-size: 0.85em;
  }

  .cookie-actions {
    flex-direction: column;
    gap: 8px;
  }

  .cookie-actions .btn {
    width: 100%;
    min-width: auto;
  }
}

@media (max-width: 480px) {
  nav a {
    padding: 6px 10px;
    font-size: 0.9em;
  }

  h1 { font-size: 1.75rem; }
  .btn { padding: 10px 16px; font-size: 0.9em; }
  .hero h1 { font-size: 1.75rem; }
  .hero h2 { font-size: 1rem; }
  .hero p { font-size: 1rem; }

  .cookie-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-actions .btn {
    width: 100%;
  }
}

/* Extra small devices handling */
@media (max-width: 425px) {
  .back-to-top {
    bottom: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 374px) {
  body {
    width: 375px;
    margin: 0 auto;
    overflow-x: auto;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  header, footer, .back-to-top, .notification-popup, .cookie-banner {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .card {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }

  a {
    color: black !important;
    text-decoration: underline !important;
  }
}
