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

:root {
  /* Cores Padrão (Light Mode) */
  --color-primary: #10b981; /* Esmeralda mais moderno que o 4CAF50 antigo */
  --color-primary-dark: #059669;
  --color-primary-light: #d1fae5;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-text: #1f2937;
  --color-text-secondary: #6b7280;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --header-height: 60px;
}

/* Dark Mode Automático */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #10b981;
    --color-primary-dark: #34d399;
    --color-primary-light: #064e3b;
    --color-danger: #f87171;
    --color-warning: #fbbf24;
    --color-text: #f9fafb;
    --color-text-secondary: #9ca3af;
    --color-bg: #111827;
    --color-surface: #1f2937;
    --color-border: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  }
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  position: relative;
  transition: background-color 0.3s ease;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--color-surface);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--color-surface) 85%, transparent);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
}

.sync-status {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.app-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.offline-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px;
  gap: 16px;
}

.offline-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-warning);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 4px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card.purchased {
  opacity: 0.5;
  text-decoration: line-through;
  background: var(--color-bg);
  border-style: dashed;
}

.nav-bar {
  display: flex;
  padding: 12px 8px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding-bottom: env(safe-area-inset-bottom, 12px); /* Para iPhones */
}

.nav-bar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.7rem;
  padding: 8px 4px;
  border-radius: 8px;
}

.nav-bar button svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
  transition: stroke 0.3s, transform 0.2s;
}

.nav-bar button:hover {
  background: var(--color-bg);
}

.nav-bar button.active {
  color: var(--color-primary);
  font-weight: 700;
}

.nav-bar button.active svg {
  stroke: var(--color-primary);
  transform: translateY(-2px);
}

/* Custom Dialogs */
.custom-dialog-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

.custom-dialog {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-dialog p {
  margin: 0 0 24px 0;
  font-size: 1.05rem;
  color: var(--color-text);
  line-height: 1.5;
}

.custom-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.custom-dialog-actions button {
  padding: 10px 16px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  min-width: 90px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
