/* Lista de Compras - Design system */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border: #334155;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-muted: rgba(13, 148, 136, 0.2);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.25);
  --font-sans: 'Outfit', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding: clamp(16px, 4vw, 32px);
}

.app {
  max-width: 560px;
  margin: 0 auto;
}

/* Header - branding nível startup */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header-brand .header-title {
  margin: 0 0 0.4rem 0;
  font-size: clamp(1.85rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.header-brand .header-tagline {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header-icon {
  font-size: 1.15em;
  line-height: 1;
  display: inline-block;
}

.header h1 {
  font-size: clamp(1.75rem, 4vw, 2rem);
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.02em;
}

.header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Form card */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 80px 100px auto;
  gap: 0.75rem;
  align-items: end;
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid .field-qty { grid-column: 1; }
  .form-grid .field-price { grid-column: 2; }
  .form-grid .field-submit { grid-column: 1 / -1; }
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

.input-wrap {
  position: relative;
  display: block;
}

.input-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
}

.field-with-icon .input-wrap input {
  padding-left: 2.5rem;
  width: 100%;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-add-icon {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* List */
.list-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-section h2 span {
  background: var(--border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

#shoppingList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#shoppingList:empty::after {
  content: 'Nenhum item na lista. Adicione o primeiro acima.';
  display: block;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.item {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, opacity 0.25s, transform 0.25s;
  animation: itemIn 0.35s ease-out;
}

@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item.removing {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

.item.bought {
  opacity: 0.82;
}

.item.bought .item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.item.bought .item-sub {
  opacity: 0.7;
}

.item.bought .item-price {
  text-decoration: line-through;
  opacity: 0.8;
}

.check-wrap {
  position: relative;
}

.check-wrap input {
  position: absolute;
  opacity: 0;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.check-wrap .check-visual {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.check-wrap input:focus-visible + .check-visual {
  box-shadow: 0 0 0 2px var(--primary-muted);
}

.check-wrap input:checked + .check-visual {
  transform: scale(1.05);
}

.check-wrap input:checked + .check-visual {
  background: var(--success);
  border-color: var(--success);
}

.check-wrap .check-visual svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.2s;
}

.check-wrap input:checked + .check-visual svg {
  opacity: 1;
}

.item-body {
  min-width: 0;
}

.item-name {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
  word-break: break-word;
}

.item-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0 0;
}

.item-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.item-price {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  white-space: nowrap;
  text-align: right;
}

.item-actions {
  display: flex;
  gap: 0.25rem;
}

/* Clear list */
.clear-list-wrap {
  margin-top: 1rem;
  text-align: center;
}

.clear-list-wrap.hidden {
  display: none;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-clear:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Total - destaque principal */
.total-bar {
  margin-top: 1.75rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.25) 0%, rgba(13, 148, 136, 0.12) 100%);
  border: 1px solid rgba(13, 148, 136, 0.4);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-card);
}

.total-icon {
  font-size: 2rem;
  line-height: 1;
}

.total-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.total-bar .label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.total-bar .value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary);
  transition: transform 0.2s ease;
}

.total-bar .value.pop {
  animation: totalPop 0.35s ease;
}

@keyframes totalPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.total-bar.hidden {
  display: none;
}

.saved-feedback {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  margin: 0;
  padding: 0.5rem 1rem;
  background: var(--success);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
  z-index: 500;
}

.saved-feedback.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.storage-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.9rem;
}

.storage-error.hidden {
  display: none;
}

.storage-error.show {
  display: block;
}

/* PWA install hint */
.install-hint {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  line-height: 1.5;
}

.install-hint strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.install-hint-text {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
}

.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
}

.btn-install:hover {
  background: var(--primary-hover);
  color: #fff;
}

.install-hint.hidden {
  display: none;
}

.install-hint button {
  font-family: inherit;
  cursor: pointer;
}

/* Offline indicator */
.offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 1rem;
  background: #b91c1c;
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s;
}

.offline-banner.show {
  transform: translateY(0);
}
