/* components.css — botões, cards, modais, chips, badges, inputs */

/* ─── BOTÕES ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1;
  transition: background var(--t-base), transform var(--t-fast), opacity var(--t-fast);
  user-select: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--bg4); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-danger {
  background: rgba(255,92,92,0.12);
  color: var(--red);
  border: 1px solid rgba(255,92,92,0.2);
}
.btn-danger:hover { background: rgba(255,92,92,0.2); }

.btn-icon {
  padding: 8px;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text2);
  transition: background var(--t-base), color var(--t-base);
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

.btn-sm { padding: 7px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { padding: 14px 24px; font-size: var(--fs-sub); border-radius: 10px; }

/* ─── INPUTS ─── */
.input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text2);
}

.input,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="email"],
select,
textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: var(--fs-body);
  color: var(--text);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  appearance: none;
  -webkit-appearance: none;
}

.input:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.input::placeholder,
input::placeholder,
textarea::placeholder { color: var(--text3); }

.input-error {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(255,92,92,0.12) !important;
}

.input-error-msg {
  font-size: var(--fs-sm);
  color: var(--red);
  margin-top: 4px;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23909098' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* Input de valor grande */
.input-value-large {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border2);
  border-radius: 0;
  padding: 8px 0;
  width: 100%;
  text-align: center;
  color: var(--text);
  transition: border-color var(--t-base);
}
.input-value-large:focus { border-color: var(--accent); box-shadow: none; }

/* ─── TOGGLE ─── */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg4);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-base);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text2);
  transition: transform var(--t-base), background var(--t-base);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: #fff;
}

/* ─── CARDS ─── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  animation: fadeIn var(--t-slow);
}

.card-hover {
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-base);
}
.card-hover:hover {
  background: var(--bg3);
  border-color: var(--border2);
  transform: translateY(-1px);
}
.card-hover:active { transform: scale(0.99); }

/* ─── MODAIS (bottom sheet) ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  animation: fadeIn var(--t-base);
}

.modal-overlay.centered {
  align-items: center;
  padding: var(--space-lg);
}

.modal {
  background: var(--bg2);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp var(--t-slow) cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
}

.modal-centered {
  background: var(--bg2);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn var(--t-base);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border2);
  border-radius: var(--r-full);
  margin: 12px auto 8px;
  flex-shrink: 0;
}

.modal-header {
  padding: var(--space-lg) var(--space-xl) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}

.modal-title {
  font-size: var(--fs-sub);
  font-weight: 500;
}

.modal-body {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.modal-footer {
  padding: var(--space-md) var(--space-xl) var(--space-xl);
  display: flex;
  gap: var(--space-sm);
}

.modal-footer .btn { flex: 1; }

/* ─── TOAST ─── */
#toast-container {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg4);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--r-full);
  padding: 10px 20px;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: auto;
  animation: slideUp var(--t-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.toast.hiding {
  animation: fadeIn var(--t-base) reverse;
}

.toast-undo {
  color: var(--accent2);
  cursor: pointer;
  font-weight: 500;
  margin-left: 4px;
}

/* ─── FAB ─── */
.fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom) + 12px);
  right: var(--space-lg);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(108,99,255,0.4);
  transition: transform var(--t-base), box-shadow var(--t-base);
  z-index: 100;
  cursor: pointer;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(108,99,255,0.5);
}
.fab:active { transform: scale(0.95); }

/* ─── CHIPS ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
  white-space: nowrap;
  user-select: none;
}

.chip:hover { background: var(--bg4); color: var(--text); }

.chip.active {
  background: var(--accent-bg);
  border-color: rgba(108,99,255,0.3);
  color: var(--accent2);
}

.chips-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-md);
  font-size: var(--fs-meta);
  font-weight: 500;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Badges de prioridade */
.badge-urgente { background: rgba(255,92,92,0.15); color: var(--red); }
.badge-alta    { background: rgba(245,166,35,0.15); color: var(--amber); }
.badge-media   { background: rgba(77,163,255,0.15); color: var(--blue); }
.badge-baixa   { background: rgba(144,144,152,0.15); color: var(--text2); }

/* Badges de método de pagamento */
.badge-pix     { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-credito { background: rgba(108,99,255,0.15); color: var(--accent2); }
.badge-debito  { background: rgba(77,163,255,0.15); color: var(--blue); }
.badge-dinheiro{ background: rgba(245,166,35,0.15); color: var(--amber); }
.badge-ted     { background: rgba(144,144,152,0.15); color: var(--text2); }

/* ─── PROGRESS BAR ─── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg4);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.5s ease, background var(--t-base);
}

.progress-fill.ok     { background: var(--green); }
.progress-fill.warn   { background: var(--amber); }
.progress-fill.danger { background: var(--red); }

/* ─── DIVIDER ─── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

/* ─── SECTION HEADER ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

/* ─── EMPTY STATE ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-xl);
  gap: var(--space-md);
  text-align: center;
  color: var(--text3);
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--fs-body);
  color: var(--text3);
}

/* ─── LOADING ─── */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.skeleton {
  background: var(--bg3);
  border-radius: var(--r-md);
  animation: pulse 1.4s ease infinite;
}

/* ─── TYPE TOGGLE ─── */
.type-toggle {
  display: flex;
  background: var(--bg3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 3px;
}

.type-toggle-btn {
  flex: 1;
  padding: 8px;
  border-radius: calc(var(--r-md) - 2px);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text2);
  transition: background var(--t-base), color var(--t-base);
  text-align: center;
  cursor: pointer;
}

.type-toggle-btn.active {
  background: var(--bg2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ─── LIST ITEM ─── */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.list-item:last-child { border-bottom: none; }

.list-item-left { flex-shrink: 0; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-right { flex-shrink: 0; text-align: right; }

/* ─── CATEGORY DOT ─── */
.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── SWIPE ACTIONS ─── */
.swipe-container {
  position: relative;
  overflow: hidden;
}

.swipe-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  transform: translateX(100%);
  transition: transform var(--t-base);
}

.swipe-action {
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
}

.swipe-action-delete { background: var(--red); color: #fff; }
.swipe-action-edit   { background: var(--accent); color: #fff; }

/* ─── CHECKBOX ─── */
.checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base);
  flex-shrink: 0;
}

.checkbox.checked {
  background: var(--green);
  border-color: var(--green);
}

.checkbox.checked::after {
  content: '✓';
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  animation: checkmark var(--t-fast);
}

/* ─── PRIORITY BUTTONS ─── */
.priority-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}

.priority-btn {
  padding: 8px 4px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--t-base);
  background: var(--bg3);
  color: var(--text2);
}

.priority-btn.urgente.active { background: rgba(255,92,92,0.15); color: var(--red); border-color: rgba(255,92,92,0.3); }
.priority-btn.alta.active    { background: rgba(245,166,35,0.15); color: var(--amber); border-color: rgba(245,166,35,0.3); }
.priority-btn.media.active   { background: rgba(77,163,255,0.15); color: var(--blue); border-color: rgba(77,163,255,0.3); }
.priority-btn.baixa.active   { background: rgba(144,144,152,0.15); color: var(--text2); border-color: rgba(144,144,152,0.3); }

/* ─── CONFIRM DIALOG ─── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  animation: fadeIn var(--t-base);
}

.confirm-dialog {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r-xl);
  padding: var(--space-xl);
  max-width: 320px;
  width: 100%;
  text-align: center;
  animation: scaleIn var(--t-base);
}

.confirm-title {
  font-size: var(--fs-sub);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.confirm-msg {
  font-size: var(--fs-sm);
  color: var(--text2);
  margin-bottom: var(--space-xl);
}

.confirm-actions {
  display: flex;
  gap: var(--space-sm);
}
.confirm-actions .btn { flex: 1; }

/* ─── TABS ─── */
.tabs {
  display: flex;
  background: var(--bg3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}

.tab-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: calc(var(--r-md) - 2px);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text2);
  transition: all var(--t-base);
  text-align: center;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--bg2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn var(--t-base); }

/* ─── METRIC CARD ─── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.metric-card {
  background: var(--bg3);
  border-radius: var(--r-lg);
  padding: var(--space-md);
  text-align: center;
}

.metric-label {
  font-size: var(--fs-meta);
  color: var(--text3);
  margin-bottom: 4px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: var(--fs-title);
  font-weight: 500;
}

/* ─── DATE GROUP HEADER ─── */
.date-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  margin-top: var(--space-md);
}

.date-group-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text2);
}

.date-group-total {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text3);
}

/* ─── INLINE EDIT ─── */
.inline-edit-input {
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font-size: inherit;
  color: var(--text);
  width: 100%;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}
