:root {
  --bg-app: #090a0f;
  --bg-card: #11131c;
  --bg-input: #171a27;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: #f59e0b;
  
  --text-main: #f8f9fa;
  --text-muted: #7982a9;
  
  --color-green: #10b981;
  --color-green-light: rgba(16, 185, 129, 0.1);
  --color-yellow: #f59e0b;
  --color-red: #ff6b6b;
  --color-red-light: rgba(255, 107, 107, 0.1);
  
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Container principal ajustado para mobile-first */
.app-container {
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.25rem 7.5rem 1.25rem; /* folga para o footer flutuante */
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

/* Header */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.4rem;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  width: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
}

.back-link:hover {
  color: var(--color-yellow);
  border-color: var(--color-yellow);
  background-color: rgba(245, 158, 11, 0.05);
}

.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-title .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Add Item Form */
.add-item-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.add-item-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.input-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.name-group input {
  font-size: 1rem;
  font-weight: 500;
}

input[type="text"],
input[type="number"] {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
  width: 100%;
}

input:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 0.6rem;
  align-items: flex-end;
}

/* Qty Control */
.qty-control {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  height: 38px;
}

.qty-control input {
  border: none;
  background: transparent;
  text-align: center;
  padding: 0;
  width: 28px;
  font-size: 0.95rem;
  font-weight: 600;
}

.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 600;
  width: 24px;
  height: 100%;
  cursor: pointer;
  transition: var(--transition);
}

.qty-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Buttons */
.primary-button {
  background-color: var(--color-yellow);
  color: #000;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 0 0.85rem;
  height: 38px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  font-size: 0.85rem;
}

.primary-button:hover {
  background-color: #e09205;
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.ghost-button:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--color-red);
  border-color: rgba(255, 107, 107, 0.3);
}

/* Tabs */
.list-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--color-yellow);
}

/* Items List */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
}

.empty-state p {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.empty-state span {
  font-size: 0.8rem;
}

/* Card de Item */
.item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.item-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

/* Checkbox estilizada */
.custom-checkbox {
  position: relative;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-checkbox::after {
  content: "✓";
  color: #000;
  font-size: 0.75rem;
  font-weight: 800;
  opacity: 0;
  transition: var(--transition);
}

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

.item-card.checked .custom-checkbox::after {
  opacity: 1;
}

/* Info do Item */
.item-details {
  display: flex;
  flex-direction: column;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  transition: var(--transition);
}

.item-card.checked .item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.item-meta .meta-price {
  color: var(--color-yellow);
  font-weight: 500;
}

/* Lado Direito do Item (Preço Total + Ações) */
.item-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.item-subtotal {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
  min-width: 65px;
}

.item-card.checked .item-subtotal {
  color: var(--color-green);
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.btn-delete:hover {
  color: var(--color-red);
  background-color: var(--color-red-light);
}

/* Totais Flutuantes na parte inferior */
.totals-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  background-color: rgba(17, 19, 28, 0.85);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1.5rem;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.totals-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-box {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.total-divider {
  width: 1px;
  height: 32px;
  background-color: var(--border-color);
  margin: 0 1.25rem;
}

.total-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.primary-total .total-value {
  color: var(--color-green);
  font-size: 1.35rem;
  font-weight: 700;
}

.secondary-total .total-value {
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
}

.header-actions .scanner-label,
.header-actions #btnClearAll {
  flex: 1;
  justify-content: center;
  text-align: center;
  height: 36px;
  display: inline-flex;
  align-items: center;
}

.scanner-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background-color: rgba(245, 158, 11, 0.05);
  border-color: rgba(245, 158, 11, 0.2);
  color: var(--color-yellow);
}

.scanner-label:hover {
  background-color: rgba(245, 158, 11, 0.15) !important;
  border-color: var(--color-yellow) !important;
}

/* OCR Loader */
.ocr-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-card);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  animation: ocrPulse 2s infinite ease-in-out;
}

.ocr-loader p {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-yellow);
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.ocr-loader span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  border-top-color: var(--color-yellow);
  animation: ocrSpin 0.8s linear infinite;
}

/* Input de Preço Manual no Item */
.card-price-input {
  background: transparent;
  border: none !important;
  border-bottom: 1px dashed var(--text-muted) !important;
  color: var(--color-yellow);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  width: 55px;
  padding: 0 2px;
  text-align: left;
  transition: var(--transition);
  border-radius: 0 !important;
}

.card-price-input:focus {
  outline: none !important;
  border-bottom-color: var(--color-yellow) !important;
  background-color: rgba(255, 255, 255, 0.04) !important;
}

/* Animations */
@keyframes ocrSpin {
  to { transform: rotate(360deg); }
}

@keyframes ocrPulse {
  0% { opacity: 0.85; }
  50% { opacity: 1; }
  100% { opacity: 0.85; }
}

.item-title[contenteditable="true"] {
  border-bottom: 1px solid transparent;
  padding: 0 2px;
  border-radius: 4px;
  transition: var(--transition);
}

.item-title[contenteditable="true"]:focus {
  outline: none !important;
  border-bottom-color: var(--color-yellow);
  background-color: rgba(255, 255, 255, 0.04);
}
