/* ==========================================================================
 * AutoZelo CSS [1/3]: Base, Tema, Layout 9:16, Header, Navegação e Botões
 * ========================================================================== */

:root {
  --bg-desktop: #0b1120;
  --bg-app: #f4f6f9;
  --bg-card: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-header: rgba(255, 255, 255, 0.88);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent-emerald: #10b981;
  --accent-emerald-dark: #059669;
  --accent-emerald-soft: rgba(16, 185, 129, 0.13);
  --accent-orange: #ea580c;
  --accent-orange-soft: rgba(234, 88, 12, 0.12);
  --accent-blue: #2563eb;
  --accent-amber: #d97706;
  --accent-red: #ef4444;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 58px;
  --nav-height: 64px;
}

[data-theme="dark"] {
  --bg-desktop: #050811;
  --bg-app: #0a0f1c;
  --bg-card: #111827;
  --bg-elevated: #1a2334;
  --bg-header: rgba(17, 24, 39, 0.88);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --border-strong: #334155;
  --accent-emerald-soft: rgba(16, 185, 129, 0.18);
  --accent-orange-soft: rgba(249, 115, 22, 0.18);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-desktop);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

/* Container Vertical 9:16 */
.app-viewport {
  position: relative;
  width: 100%;
  max-width: 470px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

@media (min-width: 520px) {
  body {
    background: radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.16), transparent 45%),
      radial-gradient(circle at 80% 80%, rgba(37, 99, 235, 0.16), transparent 45%),
      var(--bg-desktop);
  }
  .app-viewport {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }
}

/* Cabeçalho Superior */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--safe-top) + 8px) 14px 8px;
  min-height: calc(var(--header-height) + var(--safe-top));
  background: var(--bg-header);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: none;
  background: transparent;
  padding: 4px 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  color: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.brand-text {
  font-size: 1.18rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-text strong {
  color: var(--accent-emerald);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.install-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: var(--accent-emerald-soft);
  color: var(--accent-emerald-dark);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

[data-theme="dark"] .install-pill {
  color: #34d399;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: transform 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}


/* Conteúdo Principal */
.main-content {
  flex: 1;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 22px);
}

.tab-view {
  display: none;
}

.tab-view.is-active {
  display: block;
}


/* Botões e Campos */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  transition: opacity 0.15s, transform 0.12s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.82rem;
  border-radius: 10px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
}

.btn-orange {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
}

.btn-ghost {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--accent-red);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent-emerald);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.checkbox-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.82rem;
  font-weight: 600;
}

.checkbox-pill input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-emerald);
}

/* Navegação Inferior */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 470px;
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: var(--bg-header);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  z-index: 45;
}

.nav-btn {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.nav-btn.is-active {
  color: var(--accent-emerald);
}

.nav-btn--create {
  color: var(--text-primary);
}

.create-fab {
  width: 42px;
  height: 36px;
  border-radius: 13px;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  color: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.nav-icon-wrap {
  position: relative;
  display: inline-flex;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent-red);
  color: #ffffff;
  font-size: 0.64rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}


/* Empty & Loading */
.empty-state {
  text-align: center;
  padding: 38px 22px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.load-more-wrap {
  padding: 8px 14px 20px;
  display: flex;
  justify-content: center;
}

/* Toast */
.app-toast {
  position: fixed;
  top: calc(var(--safe-top) + 14px);
  left: 50%;
  transform: translate(-50%, -18px);
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  z-index: 150;
  transition: opacity 0.2s, transform 0.2s;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-toast--success {
  background: #059669;
}

.app-toast--error {
  background: #dc2626;
}

/* Botão Admin no Cabeçalho */
.admin-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-blue);
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
}

