/* ============================================================
   CSS/global.css — Sistema de Design · Dark Mode · Mobile First
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&display=swap');

/* ── Tokens de Design ────────────────────────────────────────── */
:root {
  /* Paleta principal */
  --bg:             #0d0d12;
  --surface:        #14141c;
  --surface-2:      #1c1c28;
  --surface-3:      #242436;
  --border:         rgba(255,255,255,.07);
  --border-strong:  rgba(255,255,255,.14);

  /* Texto */
  --text-primary:   #f0f0f8;
  --text-secondary: #9898b8;
  --text-muted:     #5a5a7a;

  /* Cores de status */
  --green:        #22c55e;
  --green-light:  rgba(34,197,94,.15);
  --red:          #ef4444;
  --red-light:    rgba(239,68,68,.15);
  --accent:       #7c3aed;
  --accent-light: rgba(124,58,237,.2);
  --accent-glow:  rgba(124,58,237,.35);

  /* Tipografia */
  --font: 'Sora', system-ui, sans-serif;

  /* Espaçamento */
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
  --shadow:    0 4px 24px rgba(0,0,0,.6);
  --shadow-lg: 0 8px 48px rgba(0,0,0,.8);

  /* Transições */
  --t: .2s cubic-bezier(.4,0,.2,1);

  /* Barra inferior (nav) */
  --nav-height: 72px;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100svh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Layout wrapper ──────────────────────────────────────────── */
.app-wrapper {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.page-content {
  padding: 0 1rem calc(var(--nav-height) + 1.5rem);
  min-height: 100svh;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }

/* ── Tipografia ──────────────────────────────────────────────── */
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; }
a  { color: var(--accent); text-decoration: none; }

/* ── Utilitários de texto ─────────────────────────────────────── */
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent  { color: var(--accent); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--t);
}
.card:hover { border-color: var(--border-strong); }

/* ── Botões ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t), box-shadow var(--t);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; box-shadow: 0 4px 20px var(--accent-glow); }
.btn-secondary { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text-primary); }
.btn-danger   { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-sm { padding: .45rem .875rem; font-size: .8rem; }
.btn-icon { padding: .55rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; transition: all var(--t); }
.btn-icon:hover { background: var(--surface-3); color: var(--text-primary); }

/* ── Inputs & Selects ────────────────────────────────────────── */
.form-field { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  color: var(--text-primary);
  font-size: .95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select { 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='%235a5a7a' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .875rem center; padding-right: 2.5rem; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Row/Grid helpers ────────────────────────────────────────── */
.row { display: flex; gap: .75rem; }
.row > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── Chip / Badge ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: var(--green-light);   color: var(--green); }
.badge-red    { background: var(--red-light);     color: var(--red); }
.badge-purple { background: var(--accent-light);  color: var(--accent); }

/* ── Section header ──────────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Divisor ─────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 1rem;
}
.empty-state svg { color: var(--text-muted); opacity: .6; }
.empty-state p { color: var(--text-secondary); font-size: .95rem; max-width: 260px; }

/* ── Toast / Notificação ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  color: var(--text-primary);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  z-index: 9999;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: rgba(34,197,94,.4); color: var(--green); }
.toast.error   { border-color: rgba(239,68,68,.4);  color: var(--red); }

/* ── Skeleton loader ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Animações de entrada ─────────────────────────────────────── */
.fade-in { animation: fadeIn .3s var(--t) both; }
@keyframes fadeIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

.slide-up { animation: slideUp .35s var(--t) both; }
@keyframes slideUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }

/* ── FAB (Floating Action Button) ────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) / 2);
  left: 50%;
  transform: translateX(-50%) translateY(50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 4px var(--bg);
  transition: transform var(--t), box-shadow var(--t);
  z-index: 100;
}
.fab:hover { transform: translateX(-50%) translateY(50%) scale(1.08); box-shadow: 0 6px 32px var(--accent-glow), 0 0 0 4px var(--bg); }
.fab:active { transform: translateX(-50%) translateY(50%) scale(.94); }
.fab svg { transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.fab.open svg { transform: rotate(45deg); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 92svh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.32,0,.15,1);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: var(--surface-3); border-radius: 99px; margin: 0 auto 1.5rem; }
.modal-title  { font-size: 1.2rem; font-weight: 700; text-align: center; margin-bottom: 1.5rem; }
.modal-tabs   { display: flex; gap: .5rem; background: var(--surface-2); border-radius: var(--radius); padding: .3rem; margin-bottom: 1.5rem; }
.modal-tab    { flex: 1; padding: .5rem; text-align: center; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: all var(--t); border: none; background: none; font-family: var(--font); }
.modal-tab.active { background: var(--accent); color: #fff; }

/* ── Color picker helper ─────────────────────────────────────── */
.color-picker-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.color-dot {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform var(--t), border-color var(--t);
}
.color-dot.active, .color-dot:hover { transform: scale(1.15); border-color: #fff; }

/* ── Responsive (tablet+) ────────────────────────────────────── */
@media (min-width: 600px) {
  .page-content { padding: 1rem 1.5rem calc(var(--nav-height) + 2rem); }
  .grid-2 { gap: 1rem; }
}
