/* Mistura da Semana - estilos complementares */

:root {
  --brand: #002870;
  --brand-hover: #001f5a;
  --accent: #d00010;
  --surface: #ffffff;
}

html {
  scroll-behavior: smooth;
}

html.dark {
  color-scheme: dark;
}

html:not(.dark) {
  color-scheme: light;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 0% -20%, rgba(0, 40, 112, 0.10), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(208, 0, 16, 0.06), transparent);
}

.dark body {
  background-image:
    radial-gradient(ellipse 70% 40% at 0% -10%, rgba(255, 255, 255, 0.03), transparent),
    radial-gradient(ellipse 50% 30% at 100% 0%, rgba(208, 0, 16, 0.05), transparent);
}

.card {
  @apply rounded-2xl border border-ink-200/80 dark:border-ink-800 bg-white dark:bg-ink-900 shadow-card;
}

html.dark .card {
  background-color: #171717 !important;
  border-color: #2e2e2e !important;
}

.btn-primary {
  @apply inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl
         bg-brand-700 text-white text-sm font-semibold
         hover:bg-brand-800 active:bg-brand-900
         focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2
         dark:focus-visible:ring-offset-ink-950 transition;
}

.btn-secondary {
  @apply inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl
         bg-white dark:bg-ink-900 text-ink-800 dark:text-ink-100 text-sm font-semibold
         border border-ink-200 dark:border-ink-700
         hover:border-brand-400 dark:hover:border-brand-500
         focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 transition;
}

.btn-ghost {
  @apply inline-flex items-center justify-center gap-2 px-3 py-2.5 rounded-xl
         text-sm font-medium text-ink-600 dark:text-ink-300
         hover:bg-ink-100 dark:hover:bg-ink-800
         focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 transition;
}

.btn-danger {
  @apply inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl
         bg-red-600 text-white text-sm font-semibold hover:bg-red-700
         focus:outline-none focus-visible:ring-2 focus-visible:ring-red-500 transition;
}

.btn-danger-ghost {
  @apply inline-flex items-center justify-center gap-2 px-3 py-2.5 rounded-xl
         text-sm font-medium text-red-600 dark:text-red-400
         hover:bg-red-50 dark:hover:bg-red-950/40
         focus:outline-none focus-visible:ring-2 focus-visible:ring-red-500 transition;
}

.input-field {
  @apply w-full px-3.5 py-2.5 rounded-xl text-sm
         bg-white dark:bg-ink-950
         border border-ink-200 dark:border-ink-700
         text-ink-900 dark:text-ink-100
         placeholder:text-ink-400
         focus:outline-none focus:ring-2 focus:ring-brand-500/40 focus:border-brand-500
         transition;
}

.label {
  @apply block text-sm font-medium text-ink-700 dark:text-ink-300 mb-1.5;
}

.help-text {
  @apply text-xs text-ink-400 mt-1.5;
}

.stat-label {
  @apply text-xs font-medium uppercase tracking-wide text-ink-400 mb-1;
}

.stat-value {
  @apply text-xl sm:text-2xl font-semibold tracking-tight;
}

.badge {
  @apply inline-flex items-center px-2 py-0.5 rounded-lg text-xs font-semibold;
}

.badge-brand {
  @apply bg-brand-100 text-brand-800 dark:bg-ink-800 dark:text-ink-200;
}

.badge-success {
  @apply bg-brand-100 text-brand-800 dark:bg-ink-800 dark:text-ink-200;
}

.badge-warning {
  @apply bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-200;
}

.badge-danger {
  @apply bg-red-100 text-red-800 dark:bg-red-950 dark:text-red-200;
}

.badge-neutral {
  @apply bg-ink-100 text-ink-600 dark:bg-ink-800 dark:text-ink-300;
}

.icon-btn {
  @apply inline-flex items-center justify-center p-2 rounded-lg
         text-ink-500 dark:text-neutral-300 hover:bg-ink-100 dark:hover:bg-ink-800
         focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 transition;
}

.fab {
  @apply fixed bottom-20 right-4 z-20 flex h-14 w-14 items-center justify-center
         rounded-full bg-accent-500 text-white shadow-lg
         hover:bg-accent-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-400;
}

.modal {
  @apply fixed inset-0 z-50 flex items-end sm:items-center justify-center p-0 sm:p-4;
}

.modal-backdrop {
  @apply absolute inset-0 bg-ink-950/50 backdrop-blur-sm;
}

.modal-panel {
  @apply relative w-full sm:max-w-md rounded-t-2xl sm:rounded-2xl
         bg-white dark:bg-ink-900 p-6 shadow-card
         border border-ink-200 dark:border-ink-800
         animate-slide-up;
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-slide-in {
  animation: slide-in 0.25s ease-out;
}

.animate-slide-up {
  animation: slide-up 0.25s ease-out;
}

/* Fallback sem @apply para ambientes onde CDN processa depois */
.card {
  border-radius: 1rem;
  border: 1px solid rgba(212, 212, 212, 0.9);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px -8px rgba(0, 0, 0, 0.12);
}

.dark .card {
  border-color: #2e2e2e;
  background: #171717;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  background: #002870;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-primary:hover { background: #001f5a; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  background: #fff;
  border: 1px solid #d4d4d4;
  font-size: 0.875rem;
  font-weight: 600;
}

.dark .btn-secondary {
  background: #171717;
  border-color: #2e2e2e;
  color: #ececec;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #404040;
}

.dark .btn-ghost {
  color: #e5e5e5;
}

.icon-btn {
  display: inline-flex;
  padding: 0.5rem;
  border-radius: 0.5rem;
  color: #737373;
}

.dark .icon-btn {
  color: #d4d4d4;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  background: #d00010;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-danger-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  color: #d00010;
  font-size: 0.875rem;
  font-weight: 500;
}

.input-field {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #d4d4d4;
  background: #fff;
  color: #171717;
}

.dark .input-field {
  background: #0a0a0a;
  border-color: #2e2e2e;
  color: #ececec;
}

.input-field:focus {
  outline: none;
  border-color: #002870;
  box-shadow: 0 0 0 3px rgba(0, 40, 112, 0.22);
}

/* Controles nativos no dark — NÃO usar filter invert junto com color-scheme
   (os dois juntos reescurecem o ícone do calendário) */
html.dark,
html.dark input,
html.dark select,
html.dark textarea {
  color-scheme: dark;
}

html.dark input[type="date"]::-webkit-calendar-picker-indicator,
html.dark input[type="month"]::-webkit-calendar-picker-indicator,
html.dark input[type="time"]::-webkit-calendar-picker-indicator,
html.dark input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
  /* Fallback se o navegador ignorar color-scheme */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e5e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-size: 1rem 1rem;
  background-repeat: no-repeat;
  background-position: center;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  margin-left: 0.25rem;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
}

/* Lucide: força cor clara no dark */
html.dark svg.lucide,
html.dark [data-lucide],
html.dark i[data-lucide] {
  color: #e5e5e5 !important;
  stroke: #e5e5e5 !important;
}

html.dark .btn-primary svg.lucide,
html.dark .btn-primary [data-lucide],
html.dark .btn-danger svg.lucide,
html.dark .btn-danger [data-lucide],
html.dark .fab svg.lucide,
html.dark .fab [data-lucide],
html.dark .toast svg.lucide,
html.dark .toast [data-lucide] {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

html.dark .text-accent-500,
html.dark .text-accent-500 svg.lucide,
html.dark .text-red-600,
html.dark .text-red-600 svg.lucide,
html.dark .text-red-400,
html.dark .text-red-400 svg.lucide,
html.dark .text-amber-400,
html.dark .text-amber-400 svg.lucide,
html.dark .text-brand-600,
html.dark .text-brand-600 svg.lucide {
  color: inherit !important;
  stroke: currentColor !important;
}

html.dark .btn-ghost,
html.dark .btn-secondary,
html.dark .icon-btn,
html.dark [data-sidebar-open],
html.dark [data-sidebar-close],
html.dark #theme-toggle {
  color: #e5e5e5;
}

html.dark .btn-ghost:hover,
html.dark .btn-secondary:hover,
html.dark .icon-btn:hover,
html.dark [data-sidebar-open]:hover,
html.dark [data-sidebar-close]:hover {
  color: #ffffff;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.help-text {
  font-size: 0.75rem;
  color: #737373;
  margin-top: 0.375rem;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #737373;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-brand { background: #d5e2f4; color: #001f5a; }
.dark .badge-brand { background: #262626; color: #d4d4d4; }
.badge-success { background: #d5e2f4; color: #001f5a; }
.dark .badge-success { background: #262626; color: #d4d4d4; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #ffdede; color: #96000c; }
.badge-neutral { background: #ececec; color: #404040; }
.dark .badge-neutral { background: #262626; color: #d4d4d4; }

.badge-accent { background: #ffdede; color: #96000c; }
.dark .badge-accent { background: #2e0005; color: #ffb3b3; }

.fab {
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  z-index: 20;
  display: flex;
  width: 3.5rem;
  height: 3.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: #d00010;
  color: #fff;
  box-shadow: 0 10px 25px rgba(208, 0, 16, 0.35);
}

.fab:hover {
  background: #b8000e;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal { align-items: center; padding: 1rem; }
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 28rem;
  border-radius: 1rem 1rem 0 0;
  background: #fff;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px -8px rgba(0, 0, 0, 0.2);
}

@media (min-width: 640px) {
  .modal-panel { border-radius: 1rem; }
}

.dark .modal-panel {
  background: #171717;
  border: 1px solid #2e2e2e;
}

/* Sidebar fixa */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar.open {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0) !important;
  }
}

/* ========== Auth screen ========== */
.auth-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.auth-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(0, 40, 112, 0.22), transparent 55%),
    radial-gradient(900px 500px at 95% 15%, rgba(208, 0, 16, 0.14), transparent 50%),
    radial-gradient(700px 400px at 50% 110%, rgba(26, 90, 168, 0.16), transparent 55%),
    linear-gradient(165deg, #eef3fa 0%, #f7f7f7 42%, #e8eef7 100%);
}

html.dark .auth-bg {
  background:
    radial-gradient(1000px 560px at 8% -8%, rgba(26, 90, 168, 0.35), transparent 55%),
    radial-gradient(800px 480px at 100% 10%, rgba(208, 0, 16, 0.22), transparent 50%),
    radial-gradient(700px 420px at 40% 100%, rgba(0, 40, 112, 0.45), transparent 55%),
    linear-gradient(165deg, #0a0a0a 0%, #171717 45%, #000d28 100%);
}

.auth-orb {
  position: absolute;
  border-radius: 9999px;
  filter: blur(48px);
  opacity: 0.55;
  pointer-events: none;
  will-change: transform;
}

.auth-orb--brand {
  width: min(42vw, 420px);
  height: min(42vw, 420px);
  left: -8%;
  top: 18%;
  background: rgba(0, 40, 112, 0.45);
  animation: auth-float-a 14s ease-in-out infinite;
}

.auth-orb--accent {
  width: min(34vw, 320px);
  height: min(34vw, 320px);
  right: -6%;
  top: 8%;
  background: rgba(208, 0, 16, 0.32);
  animation: auth-float-b 18s ease-in-out infinite;
}

.auth-orb--soft {
  width: min(48vw, 480px);
  height: min(48vw, 480px);
  left: 30%;
  bottom: -18%;
  background: rgba(26, 90, 168, 0.28);
  animation: auth-float-c 20s ease-in-out infinite;
}

html.dark .auth-orb--brand { background: rgba(26, 90, 168, 0.55); opacity: 0.45; }
html.dark .auth-orb--accent { background: rgba(208, 0, 16, 0.4); opacity: 0.4; }
html.dark .auth-orb--soft { background: rgba(0, 40, 112, 0.55); opacity: 0.4; }

.auth-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 40, 112, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 40, 112, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  opacity: 0.7;
}

html.dark .auth-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  opacity: 0.45;
}

.auth-shine {
  position: absolute;
  inset: -20% -10%;
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(255, 255, 255, 0.28) 48%,
    transparent 62%
  );
  transform: translateX(-30%);
  animation: auth-shine 9s ease-in-out infinite;
  pointer-events: none;
}

html.dark .auth-shine {
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(255, 255, 255, 0.06) 48%,
    transparent 62%
  );
}

.auth-theme-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  padding: 0.625rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(212, 212, 212, 0.9);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.auth-theme-btn:hover {
  border-color: #749dd4;
}

html.dark .auth-theme-btn {
  border-color: #2e2e2e;
  background: rgba(23, 23, 23, 0.85);
}

html.dark .auth-theme-btn:hover {
  border-color: #1a5aa8;
}

.auth-main {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 28rem;
  padding: 1.75rem 1.5rem 1.75rem;
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 1px 2px rgba(0, 40, 112, 0.04),
    0 18px 48px -16px rgba(0, 40, 112, 0.28) !important;
  animation: auth-card-in 0.45s ease-out;
}

@media (min-width: 640px) {
  .auth-card {
    padding: 2.25rem 2rem 2rem;
  }
}

html.dark .auth-card {
  background: rgba(23, 23, 23, 0.88) !important;
  border-color: rgba(64, 64, 64, 0.9) !important;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 24px 56px -18px rgba(0, 0, 0, 0.65) !important;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(212, 212, 212, 0.7);
}

html.dark .auth-logo {
  border-bottom-color: rgba(64, 64, 64, 0.85);
}

@keyframes auth-float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(28px, -22px) scale(1.06); }
}

@keyframes auth-float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-34px, 26px) scale(1.08); }
}

@keyframes auth-float-c {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18px, -30px) scale(1.04); }
}

@keyframes auth-shine {
  0%, 100% { transform: translateX(-40%) skewX(-12deg); opacity: 0.35; }
  50% { transform: translateX(35%) skewX(-12deg); opacity: 0.7; }
}

@keyframes auth-card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-orb,
  .auth-shine,
  .auth-card {
    animation: none !important;
  }
}
