:root {
  --bg-color: #f0f2f5;
  --surface: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --primary-color: #f57c00;
  --primary-hover: #e67300;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --danger-color: #f44336;
  --radius-sm: 12px;
  --radius-md: 24px;
  --radius-lg: 32px;
  --radius-full: 9999px;
  --clay-shadow-outer: 8px 8px 16px rgba(0, 0, 0, 0.08), -8px -8px 16px rgba(255, 255, 255, 0.8);
  --clay-shadow-inner: inset -4px -4px 8px rgba(0, 0, 0, 0.05), inset 4px 4px 8px rgba(255, 255, 255, 0.9);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
p { line-height: 1.6; color: var(--text-secondary); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.8s ease-out forwards; }
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }

.flex-center { display: flex; align-items: center; }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  box-shadow: 8px 8px 24px rgba(0, 0, 0, 0.12), var(--clay-shadow-inner);
  transition: var(--transition-normal);
  border: 1px solid rgba(255,255,255,0.4);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 12px 12px 30px rgba(0, 0, 0, 0.15), var(--clay-shadow-inner);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem 1.5rem;
  border: none; border-radius: var(--radius-full); font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: var(--transition-normal); text-decoration: none;
}
.btn-primary {
  background: var(--primary-color); color: white;
  box-shadow: 6px 6px 12px rgba(245, 124, 0, 0.3), inset -4px -4px 8px rgba(180, 80, 0, 0.4), inset 4px 4px 8px rgba(255, 160, 80, 0.6);
}
.btn-primary:hover {
  background: var(--primary-hover); transform: translateY(-2px);
  box-shadow: 8px 8px 16px rgba(245, 124, 0, 0.4), inset -4px -4px 8px rgba(180, 80, 0, 0.4), inset 4px 4px 8px rgba(255, 160, 80, 0.6);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 2px 2px 4px rgba(245, 124, 0, 0.2), inset 4px 4px 8px rgba(180, 80, 0, 0.4), inset -4px -4px 8px rgba(255, 160, 80, 0.6);
}
.btn-secondary {
  background: var(--surface); color: var(--primary-color); box-shadow: var(--clay-shadow-outer), var(--clay-shadow-inner);
}
.btn-secondary:hover { transform: translateY(-2px); color: var(--primary-hover); }
.btn-secondary:active {
  transform: translateY(0);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.05), inset 4px 4px 8px rgba(0,0,0,0.1), inset -4px -4px 8px rgba(255,255,255,0.9);
}
.btn-full { width: 100%; }
.btn-icon { padding: 0.75rem; border-radius: 50%; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 2px solid rgba(0,0,0,0.03);
  margin: 0 1rem;
}

.input-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.input-label { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); margin-left: 0.5rem; }
.input-field {
  padding: 1rem 1.2rem; border: none; border-radius: var(--radius-md); font-size: 1rem; transition: var(--transition-normal);
  background-color: var(--surface); color: var(--text-primary); outline: none;
  box-shadow: inset 4px 4px 8px rgba(0,0,0,0.06), inset -4px -4px 8px rgba(255,255,255,0.9);
}
.input-field:focus {
  box-shadow: inset 6px 6px 12px rgba(0,0,0,0.08), inset -6px -6px 12px rgba(255,255,255,1), 0 0 0 3px rgba(245, 124, 0, 0.2);
}

.page-container { min-height: 100vh; padding: 2rem; display: flex; flex-direction: column; }
.navbar {
  display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background: var(--surface);
  border-radius: var(--radius-full); margin-bottom: 3rem; box-shadow: var(--clay-shadow-outer), var(--clay-shadow-inner);
}
.logo-container { display: flex; align-items: center; gap: 0.5rem; }

.battery-status {
  display: flex; align-items: center; gap: 0.5rem; background: var(--surface); padding: 0.5rem 1.2rem;
  border-radius: 20px; font-size: 0.9rem; font-weight: 600; color: var(--primary-color);
  box-shadow: inset 3px 3px 6px rgba(0,0,0,0.05), inset -3px -3px 6px rgba(255,255,255,0.9);
}
.grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2.5rem; }
.routines-list { display: flex; flex-direction: column; gap: 1.2rem; }
.routine-item {
  display: flex; align-items: center; padding: 1.2rem; background: var(--surface); color: var(--text-primary);
  border-radius: var(--radius-md); transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--clay-shadow-outer), var(--clay-shadow-inner);
  position: relative;
  overflow: visible;
}
.routine-actions { display: flex; gap: 0.5rem; opacity: 0.6; transition: opacity 0.3s; }
.routine-item:hover .routine-actions { opacity: 1; }
.btn-action { 
  background: none; border: none; cursor: pointer; padding: 0.5rem; border-radius: 50%;
  color: var(--text-secondary); transition: var(--transition-normal);
}
.btn-action:hover { background: rgba(0,0,0,0.05); color: var(--primary-color); }
.btn-action.delete:hover { color: var(--danger-color); }

/* Estado Concluído Sensorial & Positivo (Sem risco feio de corte no texto) */
.routine-item.completed {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, var(--surface) 100%);
  border: 1.5px solid rgba(34, 197, 94, 0.45);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.12), var(--clay-shadow-inner);
  opacity: 1;
}
.routine-item.completed:hover {
  opacity: 1;
  border-color: rgba(34, 197, 94, 0.7);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.18), var(--clay-shadow-inner);
}
.routine-item.completed .routine-title-text {
  color: var(--text-primary);
  font-weight: 700;
}
[data-theme="dark"] .routine-item.completed {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, #1e242d 100%);
  border-color: rgba(34, 197, 94, 0.4);
}

/* Animação comemorativa ao concluir */
@keyframes celebrationPulse {
  0% { transform: scale(0.97); }
  50% { transform: scale(1.03); box-shadow: 0 0 25px rgba(34, 197, 94, 0.35); }
  100% { transform: scale(1); }
}
.routine-item.just-completed {
  animation: celebrationPulse 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Partículas Comemorativas / Confetes */
.confetti-particle {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  z-index: 99999;
  animation: confettiBurst 0.9s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}
@keyframes confettiBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.25) rotate(var(--rot));
  }
}

/* Badge de Conclusão com Brilho */
.routine-done-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.74rem;
  background: linear-gradient(135deg, rgba(34,197,94,0.18), rgba(74,222,128,0.25));
  color: #15803d;
  padding: 3px 9px;
  border-radius: 12px;
  font-weight: 800;
  margin-left: 6px;
  border: 1px solid rgba(34,197,94,0.3);
  box-shadow: 0 2px 6px rgba(34,197,94,0.15);
  animation: popInBadge 0.35s ease;
}
[data-theme="dark"] .routine-done-pill {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.22);
}
@keyframes popInBadge {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.status-list { display: flex; flex-direction: column; gap: 1.5rem; }
.status-item { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; border-bottom: 2px solid rgba(0,0,0,0.03); }
.status-item:last-child { border-bottom: none; padding-bottom: 0; }
.status-label { color: var(--text-secondary); font-weight: 500; }
.status-value { font-weight: 600; }
.status-value.success { color: var(--success-color); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success-color); box-shadow: 0 0 8px var(--success-color); }
.badge-primary {
  background: var(--surface); color: var(--primary-color); padding: 6px 14px; border-radius: 12px; font-size: 0.85rem; font-weight: 700;
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.05), inset -2px -2px 5px rgba(255,255,255,0.9);
}

/* Modal Styles */
.modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.3); z-index: 1000; justify-content: center; align-items: center;
  backdrop-filter: blur(5px); opacity: 0; transition: opacity 0.3s ease;
}
.modal.show { display: flex; opacity: 1; }
.modal-content {
  background: var(--surface); border-radius: var(--radius-md); padding: 2.5rem; width: 90%; max-width: 450px;
  box-shadow: 12px 12px 30px rgba(0, 0, 0, 0.15), var(--clay-shadow-inner);
  transform: translateY(20px) scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
  border: 1px solid rgba(255,255,255,0.4);
}
.modal.show .modal-content { transform: translateY(0) scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-close { 
  background: var(--surface); border: none; cursor: pointer; color: var(--text-secondary);
  width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; align-items: center;
  box-shadow: inset 3px 3px 6px rgba(0,0,0,0.05), inset -3px -3px 6px rgba(255,255,255,0.9);
  transition: var(--transition-normal);
}
.modal-close:hover { color: var(--danger-color); transform: translateY(-2px); }
.modal-close:active { transform: translateY(0); box-shadow: inset 4px 4px 8px rgba(0,0,0,0.1); }

/* ---- Tema escuro Global ---- */
[data-theme="dark"] {
  --bg-color: #0f0f13;
  --surface: #1a1a24;
  --text-primary: #f1f1f5;
  --text-secondary: #9090a8;
  --clay-shadow-outer: 8px 8px 16px rgba(0,0,0,0.4), -8px -8px 16px rgba(255,255,255,0.03);
  --clay-shadow-inner: inset -4px -4px 8px rgba(0,0,0,0.3), inset 4px 4px 8px rgba(255,255,255,0.04);
}
[data-theme="dark"] .card { border-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .section-card { border-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .setting-row:hover { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .modal-content, [data-theme="dark"] .confirm-box { background: #1a1a24; }
[data-theme="dark"] .confirm-cancel { border-color: #333; color: #ccc; }
[data-theme="dark"] .confirm-cancel:hover { background: #222; }

/* ---- Step Builder (Modal de Rotina) ---- */
.step-builder-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeInUp 0.22s ease both;
}
.step-builder-row .input-field {
  flex: 1;
  margin: 0;
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}
.step-builder-row .btn-remove-step {
  flex-shrink: 0;
  background: rgba(239,68,68,0.10);
  border: none;
  color: #ef4444;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-builder-row .btn-remove-step:hover {
  background: rgba(239,68,68,0.22);
}
[data-theme="dark"] .step-builder-row .btn-remove-step {
  background: rgba(239,68,68,0.18);
}

/* ---- Interactive Step Checklist (Steps Modal) ---- */
.step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.22s ease;
  animation: fadeInUp 0.2s ease both;
}
.step-item:hover { background: rgba(245,124,0,0.07); border-color: rgba(245,124,0,0.2); }
.step-item.checked {
  background: rgba(22,163,74,0.08);
  border-color: rgba(22,163,74,0.22);
  opacity: 0.8;
}
.step-item.checked .step-text { text-decoration: line-through; color: var(--text-secondary); }
.step-checkbox {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.22s ease;
  background: var(--surface);
}
.step-item.checked .step-checkbox {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.step-text { font-size: 0.9rem; line-height: 1.4; }
[data-theme="dark"] .step-item { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .step-item.checked { background: rgba(22,163,74,0.13); }

/* ==========================================================================
   PRIORIDADE 3 — COMPONENTES DE UX: SKELETONS, EMPTY STATES, AUTH GUARD
   ========================================================================== */

/* Shimmer Keyframe */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes pulseSubtle {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.88; }
}

.spin-anim {
  animation: spin 0.8s linear infinite;
}

/* Skeleton Loaders */
.routine-skeleton {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  padding: 1.15rem 1.35rem;
  border-radius: var(--radius-md, 20px);
  background: var(--surface, #ffffff);
  margin-bottom: 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: var(--clay-shadow-outer, 0 4px 12px rgba(0,0,0,0.04));
}
.skeleton-shimmer {
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.09) 37%, rgba(0,0,0,0.04) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: 8px;
}
[data-theme="dark"] .skeleton-shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 37%, rgba(255,255,255,0.04) 63%);
  background-size: 400% 100%;
}
.skeleton-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-text-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.skeleton-line {
  height: 12px;
}

/* Empty State Moderno */
.empty-state-modern {
  text-align: center;
  padding: 3rem 1.5rem;
  border-radius: 24px;
  background: var(--surface, #ffffff);
  border: 2px dashed rgba(245, 124, 0, 0.28);
  margin: 1.5rem 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.03);
}
.empty-state-icon-box {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(245, 124, 0, 0.12);
  color: var(--primary-color, #f57c00);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 24px rgba(245, 124, 0, 0.15);
}
.empty-state-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.empty-state-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto 1.5rem;
  line-height: 1.55;
}

/* Auth Guard Splash — Desativado */
.auth-guard-splash {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Form Validation Feedback */
.form-input-error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.04) !important;
}
.field-error-msg {
  font-size: 0.78rem;
  font-weight: 600;
  color: #ef4444;
  margin-top: 0.35rem;
  display: none;
}
.field-error-msg.visible {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

