/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* ===== LAYOUT ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

.header-logo {
  max-width: 300px;
  width: 90%;
  height: auto;
  display: block;
  margin: 0 auto 0.5rem;
}

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ===== MODE TABS ===== */
.mode-tabs {
  display: flex;
  gap: 0;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.mode-tab {
  flex: 1;
  padding: 0.7rem 0.5rem;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}
.mode-tab.active {
  background: var(--primary);
  color: white;
}
.mode-content { display: none; }
.mode-content.active { display: block; animation: fadeIn 0.2s ease; }

/* ===== DIVIDIR CORTA ===== */
.corta-form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.corta-label {
  font-weight: 600; font-size: 0.85rem; color: var(--text-secondary);
  margin-bottom: -0.5rem;
}
.input-lg { font-size: 1.2rem; padding: 0.85rem 1rem; text-align: center; font-weight: 700; }

.tip-options {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.tip-btn {
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tip-btn.active {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}
.tip-btn:hover { border-color: var(--primary); }
.tip-custom {
  width: 70px;
  padding: 0.4rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
}

.corta-result { text-align: center; }
.corta-per-person {
  padding: 1.5rem 0;
}
.corta-pp-label { font-size: 0.9rem; color: var(--text-secondary); }
.corta-pp-amount { font-size: 2.5rem; font-weight: 800; color: var(--primary); display: block; margin-top: 0.25rem; }
.corta-detail { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1rem; }

/* ===== REVIEW TIP ===== */
.review-tip {
  margin: 0.75rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.review-tip-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
  color: var(--primary);
}

/* ===== VIEWS ===== */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== CARD ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

/* ===== UPLOAD ZONE ===== */
.upload-card { text-align: center; padding: 2rem 1.5rem; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  background: #f1f5f9;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
}

.upload-icon {
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.upload-text { font-size: 1.05rem; margin-bottom: 0.25rem; }
.upload-hint { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1.25rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  text-align: center;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
  width: 100%;
  margin-top: 0.5rem;
}

.btn-secondary:hover { background: #e2e8f0; }

.btn-lg { padding: 0.9rem 1.5rem; font-size: 1.05rem; }

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  white-space: nowrap;
}

.btn-soft {
  background: #fef3c7;
  color: #92400e;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-soft:hover { background: #fde68a; }

/* ===== INPUT ===== */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: #f8fafc;
  transition: border-color 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.input-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0.75rem;
}

/* ===== HOW IT WORKS ===== */
.how-it-works { margin-top: 1.5rem; }

.how-it-works h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.step {
  background: var(--card);
  padding: 1rem;
  border-radius: var(--radius-sm);
  text-align: center;
  box-shadow: var(--shadow);
}

.step-num {
  display: inline-flex;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.step p { font-size: 0.85rem; color: var(--text-secondary); }

/* ===== PROCESSING ===== */
.processing-card { text-align: center; padding: 3rem 1.5rem; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing-text { font-weight: 600; font-size: 1.1rem; }
.processing-hint { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }

/* ===== ITEMS LIST ===== */
.items-list { margin: 1rem 0; }

.item-row {
  display: flex;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}

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

.item-info { flex: 1; }
.item-name { font-weight: 500; font-size: 0.95rem; }
.item-cantidad { font-size: 0.8rem; color: var(--text-secondary); }
.item-precio { font-weight: 600; font-size: 0.95rem; white-space: nowrap; }

.item-edit input {
  width: 70px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: right;
}

/* ===== REVIEW ===== */
.review-hint { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 0.5rem; }

.review-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--text);
  margin-bottom: 1rem;
}

.review-actions { display: flex; flex-direction: column; gap: 0.25rem; }

/* ===== REVIEW: COMPARTIDO & PAYER ===== */
.review-payer-section {
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 2px dashed var(--border);
}
.review-payer-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.item-compartido {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.item-compartido label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.item-compartido input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.item-compartido input[type="number"] {
  width: 40px; padding: 0.2rem; border: 1px solid var(--border);
  border-radius: 4px; font-size: 0.8rem; text-align: center;
}
.item-compartido .compartido-badge {
  background: #fef3c7; color: #92400e; padding: 0.15rem 0.4rem;
  border-radius: 4px; font-size: 0.75rem; font-weight: 600;
}

.review-payer-row {
  display: flex; align-items: center; padding: 0.5rem 0;
  border-bottom: 1px solid var(--border); gap: 0.75rem;
}
.review-payer-row:last-child { border-bottom: none; }
.review-payer-row .rp-info { flex: 1; }
.review-payer-row .rp-name { font-weight: 500; font-size: 0.9rem; }
.review-payer-row .rp-cant { font-size: 0.8rem; color: var(--text-secondary); }
.review-payer-row .rp-picker { display: flex; align-items: center; gap: 0.4rem; }
.review-payer-row .rp-qty {
  font-weight: 600; min-width: 24px; text-align: center; font-size: 0.95rem;
}
.review-payer-row .rp-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border);
  background: white; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.review-payer-row .rp-btn:active { background: var(--border); }
.review-payer-row .rp-price { font-weight: 600; font-size: 0.9rem; white-space: nowrap; }

/* ===== SHARE ===== */
.share-card { text-align: center; }
.share-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.share-text { color: var(--text-secondary); margin-bottom: 1rem; }

.share-link-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.share-link-box .input { flex: 1; font-size: 0.85rem; text-align: center; }
.share-hint { color: var(--text-secondary); font-size: 0.85rem; margin: 0.75rem 0; }

/* ===== ASSIGN ===== */
.assign-header { margin-bottom: 0.5rem; }

.assign-user { margin: 0.75rem 0; }

.assign-list .item-row {
  cursor: pointer;
  border-radius: 8px;
  padding: 0.7rem 0.6rem;
  margin: 0.2rem 0;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.assign-list .item-row:hover { background: #f1f5f9; }
.assign-list .item-row.selected { border-color: var(--primary); background: #eff6ff; }
.assign-list .item-row.blocked {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border);
  background: #f8fafc;
}

.assign-list .item-row.blocked::after {
  content: '🔒';
  margin-left: auto;
  font-size: 0.9rem;
}

.assign-list .item-row.shared { border-color: var(--accent); background: #fffbeb; }
.assign-list .item-row.shared::after {
  content: '🤝';
  margin-left: auto;
  font-size: 0.9rem;
}

.item-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:active { background: var(--border); }

.qty-display { font-weight: 600; min-width: 24px; text-align: center; }

.assign-summary {
  text-align: center;
  padding: 1rem 0;
  font-size: 1.1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.assign-hint { color: var(--text-secondary); font-size: 0.85rem; text-align: center; margin-top: 0.75rem; }

/* ===== AMIGOS BAR ===== */
.amigos-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem;
  justify-content: center;
}

.amigo-chip {
  background: #f1f5f9;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.amigo-chip.done { background: #dcfce7; color: #166534; }
.amigo-chip .check { color: var(--success); }

/* ===== DASHBOARD ===== */
.amigos-status { margin: 1rem 0; }

.amigo-status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

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

.status-pending {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}

.status-done {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 500;
}

.dashboard-actions { margin-top: 1rem; }

/* ===== RESULT ===== */
.result-card { text-align: center; }
.result-icon { font-size: 3rem; margin-bottom: 0.5rem; }

.result-amount {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0.5rem 0;
}

.result-transfer {
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  white-space: pre-line;
}

.result-actions { margin-top: 0.75rem; }

.donation {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.donation p { font-size: 0.9rem; color: var(--text-secondary); }

/* ===== RECEIPT IMAGE ===== */
.receipt-image {
  margin: 0.5rem 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}
.receipt-image img {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: contain;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  width: auto;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.privacy-notice {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  padding-bottom: 0.5rem;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  #app { max-width: 560px; padding: 0 2rem; }
  .logo { font-size: 2rem; }
}
