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

:root {
  --bg-main: #070a13;
  --bg-surface: #0e1424;
  --bg-card: #131b2e;
  --bg-card-hover: #18223a;
  --bg-input: #090e1a;
  --text-main: #f8fafc;
  --text-muted: #8492a6;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.28);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #05070d;
  color: var(--text-main);
  min-height: 100vh;
  padding-bottom: 70px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  background-image: url('/cat-bg.svg');
  background-size: var(--cat-size, 340px) var(--cat-size, 340px);
  background-repeat: repeat;
  opacity: 0.9;
  animation: catAmbientDrift 110s linear infinite;
  will-change: background-position;
  transition: background-size var(--cat-zoom-transition, 2.4s cubic-bezier(0.16, 1, 0.3, 1));
}

@keyframes catAmbientDrift {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 320px 640px;
  }
}

.app-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 18px;
  position: relative;
  z-index: 1;
}

/* HEADER */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 16px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-back-link svg {
  width: 14px;
  height: 14px;
}

.nav-back-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(-2px);
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header h1 svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.app-header-cat {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  vertical-align: middle;
  flex-shrink: 0;
}

.status-badge {
  font-size: 0.74rem;
  padding: 3px 9px;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.status-badge.syncing {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.notify-trigger-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.notify-trigger-btn svg {
  width: 16px;
  height: 16px;
}

.notify-trigger-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.notify-trigger-btn:active {
  transform: scale(0.97);
}

@media (max-width: 480px) {
  .btn-text-desktop {
    display: none;
  }
}

/* BARRA DE RESUMO ULTRA-COMPACTA */
.summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stats-counter {
  font-weight: 500;
  white-space: nowrap;
}

.counter-highlight {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
}

.counter-total {
  opacity: 0.6;
  font-size: 0.78rem;
  margin-left: 2px;
}

.summary-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-subtle svg {
  width: 12px;
  height: 12px;
}

.btn-subtle:hover, .btn-subtle:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: #fff;
}

/* CAIXA DE ADIÇÃO COMPACTA (SLIM QUICK-ADD) */
.add-box-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  margin: 10px 0 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.form-row-main {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-primary {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.18s;
  min-width: 0;
}

.input-primary:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
  background: #0d1424;
}

.btn-toggle-details {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}

.btn-toggle-details svg {
  width: 16px;
  height: 16px;
}

.btn-toggle-details:hover, .btn-toggle-details.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.btn-primary-add {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
  box-shadow: 0 3px 10px var(--primary-glow);
  padding: 0;
}

.btn-primary-add .btn-add-label {
  display: none;
}

.btn-primary-add svg {
  width: 18px;
  height: 18px;
}

.btn-primary-add:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-primary-add:active {
  transform: scale(0.96);
}

@media (min-width: 600px) {
  .btn-primary-add {
    width: auto;
    padding: 0 16px;
    gap: 6px;
  }
  .btn-primary-add .btn-add-label {
    display: inline;
    font-size: 0.85rem;
    font-weight: 700;
  }
}

/* GAVETA DE DETALHES (RECOLHIDA POR PADRÃO) */
.form-details-drawer {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  animation: drawerSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.form-details-drawer.open {
  display: block;
}

@keyframes drawerSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-row-details {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.flex-grow {
  flex-grow: 1;
}

.input-sm, .select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-family: inherit;
  transition: all 0.18s;
}

.input-sm:focus, .select-sm:focus {
  outline: none;
  border-color: var(--primary);
}

.input-sm {
  width: 50px;
  text-align: center;
}

.form-row-notes input {
  width: 100%;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #cbd5e1;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-family: inherit;
  transition: all 0.18s;
}

.form-row-notes input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.02);
}

/* GRUPOS DE COMPRAS */
.shopping-group {
  margin-bottom: 24px;
}

.group-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #93c5fd;
  letter-spacing: -0.2px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-cat-icon {
  width: 17px;
  height: 17px;
  color: #34d399;
  flex-shrink: 0;
}

.group-title-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* CARTÃO DO ITEM */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  cursor: pointer;
}

/* Checkbox grande para o polegar com visual clean */
.item-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s ease;
  position: relative;
}

.item-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.item-checkbox:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  display: block;
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.2px;
  line-height: 1.35;
}

.item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-qty-tag {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #34d399;
  padding: 1px 7px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.74rem;
}

.item-card.checked {
  opacity: 0.45;
  background: rgba(14, 20, 36, 0.5);
  border-color: rgba(255, 255, 255, 0.04);
}

.item-card.checked .item-name {
  text-decoration: line-through;
  color: #94a3b8;
}

.btn-delete-item {
  background: transparent;
  border: none;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
}

.btn-delete-item svg {
  width: 15px;
  height: 15px;
}

.btn-delete-item:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.empty-icon-wrap svg {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
}
