/* ===== NotaScan — Stylesheet ===== */
/* Aesthetic: Industrial-organic. Like a well-worn ledger meets modern terminal. */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;500;600;700;800;900&display=swap');
:root {
  --ink: #1a1714;
  --paper: #f5f2ed;
  --paper-2: #ede9e2;
  --paper-3: #e3ddd5;
  --accent: #c85c2d;
  --accent-light: #f5e8e1;
  --green: #2d7a4f;
  --green-light: #e1f0e8;
  --muted: #7a7269;
  --border: rgba(26,23,20,0.12);
  --border-strong: rgba(26,23,20,0.22);
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(26,23,20,0.08), 0 4px 12px rgba(26,23,20,0.04);
  --font-display: 'Montserrat', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--paper);
  text-decoration: none;
}

.logo-icon { font-size: 1.25rem; }

.logo-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-nav { display: flex; gap: 4px; }

.nav-link {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 400;
  color: rgba(245,242,237,0.5);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--paper); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--paper); }

/* ── Main ── */
.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* ── Hero ── */
.hero {
  padding: 3rem 0 2rem;
  position: relative;
}

.hero-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1rem;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  font-size: 1rem;
  color: var(--muted);
  max-width: 480px;
  line-height: 1.6;
  font-weight: 300;
}

.hero--small { padding: 2rem 0 1.5rem; }

/* ── Upload ── */
.upload-section { margin-bottom: 2rem; }

.upload-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.drop-zone {
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  margin: 1rem;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-icon {
  color: var(--muted);
  opacity: 0.6;
  margin-bottom: 0.5rem;
}

.drop-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
}

.drop-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: -0.25rem;
}

.drop-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: #333; }

.btn-secondary {
  background: white;
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--paper-2); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }

.btn-scan {
  width: 100%;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px;
  border-radius: var(--radius);
  justify-content: center;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}
.btn-scan:hover { background: #b0501f; }

.btn-scan-icon {
  font-size: 1.1rem;
  animation: spin-star 4s linear infinite;
}
@keyframes spin-star {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-save {
  background: var(--green);
  color: white;
  border-color: var(--green);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius);
}
.btn-save:hover { background: #236040; }

.btn-danger {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}
.btn-danger:hover { background: #a93226; }

.btn-remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.55);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Preview ── */
.preview-zone {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-img-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-3);
  max-height: 320px;
}

.preview-img-wrap img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
}

.preview-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Processing ── */
.processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.processing-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.scan-animation {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto 1.5rem;
  color: var(--muted);
  overflow: hidden;
}

.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1.6s ease-in-out infinite;
  top: 0;
}

@keyframes scan {
  0% { top: 0; opacity: 1; }
  50% { top: 100%; opacity: 1; }
  51% { opacity: 0; }
  100% { top: 0; opacity: 0; }
}

.processing-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.processing-sub {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Results ── */
.results-section { animation: fadeUp 0.4s ease; }

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

.results-header { margin-bottom: 1.25rem; padding-top: 0.5rem; }
.results-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
}
.results-sub { font-size: 0.875rem; color: var(--muted); margin-top: 0.2rem; }

.results-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.85rem;
}

.ocr-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--paper-2);
  border-radius: var(--radius);
  padding: 1rem;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

/* ── Records Table (edit) ── */
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.records-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.records-table td {
  padding: 6px 4px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.records-table tr:last-child td { border-bottom: none; }

.records-table td input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 5px 7px;
  transition: border-color 0.15s, background 0.15s;
}

.records-table td input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-light);
}

.btn-row-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.btn-row-delete:hover { color: #c0392b; background: #fdecea; }

.records-actions {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* ── Category pills ── */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}

.pill {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.note-wrap { margin-top: 0.5rem; }
.field-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: block;
  margin-bottom: 0.5rem;
}

.notes-field {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  resize: vertical;
  min-height: 70px;
  transition: border-color 0.15s;
}
.notes-field:focus { outline: none; border-color: var(--accent); }

/* ── Save bar ── */
.save-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 0;
}

/* ── DB records page ── */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.filter-select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink);
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.3rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.db-table-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  box-shadow: var(--shadow);
}

.db-loading, .db-empty {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.mini-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.db-content { overflow-x: auto; }

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 560px;
}

.db-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--paper);
}

.db-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink);
}

.db-table tr:last-child td { border-bottom: none; }
.db-table tr:hover td { background: var(--paper); }

.badge {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-inventario { background: #e1f0e8; color: #2d7a4f; }
.badge-ventas { background: #fdecea; color: #c0392b; }
.badge-compras { background: #e8f0fe; color: #1a56c9; }
.badge-gastos { background: #fef3e2; color: #c07b00; }
.badge-otro { background: var(--paper-2); color: var(--muted); }

.db-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-row-action {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  font-size: 0.8rem;
}
.btn-row-action:hover { color: #c0392b; background: #fdecea; }

/* ── Modal ── */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}
.modal-sub { font-size: 0.875rem; color: var(--muted); margin-bottom: 1.5rem; }
.modal-btns { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 12px 24px;
  border-radius: 100px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 400;
  white-space: nowrap;
  animation: toastIn 0.3s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: #c0392b; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .btn-export { align-self: flex-start; }
  .drop-buttons { flex-direction: column; width: 100%; }
  .drop-buttons .btn { justify-content: center; }
  .save-bar { flex-direction: column; }
  .save-bar .btn { width: 100%; justify-content: center; }
}
