/* DukaBooks — Mobile-first trader accounting UI */

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

:root {
  --primary:        #2e7d32;
  --primary-light:  #4caf50;
  --primary-dark:   #1b5e20;
  --income:         #2e7d32;
  --income-bg:      #e8f5e9;
  --expense:        #c62828;
  --expense-bg:     #ffebee;
  --bg:             #f0f4f0;
  --card:           #ffffff;
  --text:           #1a1a1a;
  --text-2:         #616161;
  --border:         #e0e0e0;
  --shadow:         0 2px 10px rgba(0,0,0,0.08);
  --radius:         14px;
  --nav-h:          66px;
  --hdr-h:          56px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─── */
#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--hdr-h);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.header-left { display: flex; align-items: center; gap: 8px; }
.app-logo   { font-size: 24px; }
.app-title  { font-size: 21px; font-weight: 800; letter-spacing: -0.5px; }
.sync-badge {
  font-size: 12px; font-weight: 700;
  padding: 5px 12px; border-radius: 20px;
  letter-spacing: 0.3px;
}
.sync-badge.online  { background: rgba(255,255,255,0.18); color: #b9f6ca; }
.sync-badge.offline { background: rgba(255,80,80,0.25);   color: #ffcdd2; }

/* ─── Main scroll area ─── */
#app-main {
  position: fixed;
  top: var(--hdr-h); bottom: var(--nav-h);
  left: 0; right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Views ─── */
.view { display: none; padding: 14px 14px 20px; min-height: 100%; }
.view.active { display: block; }

/* ─── Bottom Nav ─── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.07);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  color: #9e9e9e; padding: 6px 4px;
  transition: color 0.18s;
  -webkit-user-select: none; user-select: none;
}
.nav-btn.active { color: var(--primary); }
.nav-icon  { font-size: 22px; }
.nav-label { font-size: 11px; font-weight: 600; }

/* ─── Summary Cards ─── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 14px;
}
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 12px 8px; box-shadow: var(--shadow); text-align: center;
}
.card-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--text-2); margin-bottom: 6px;
}
.card-value { font-size: 15px; font-weight: 800; color: var(--text); }
.card-value.positive { color: var(--income); }
.card-value.negative { color: var(--expense); }
.card-profit .card-label { color: var(--primary); }

/* ─── Chart ─── */
.chart-container {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 12px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-2); margin-bottom: 10px;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-header .section-title { margin-bottom: 0; }
.view-all-btn {
  font-size: 13px; font-weight: 600; color: var(--primary);
  background: none; border: none; cursor: pointer; padding: 0;
}
#profit-chart { width: 100%; display: block; }
.chart-legend {
  display: flex; gap: 16px; margin-top: 8px;
  justify-content: center; font-size: 12px;
}
.legend-income  { color: var(--income);  font-weight: 600; }
.legend-expense { color: var(--expense); font-weight: 600; }

/* ─── Transaction rows ─── */
.recent-section {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 12px; box-shadow: var(--shadow);
}
.transaction-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  role: listitem;
}
.transaction-row:last-child { border-bottom: none; }
.tx-left {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
}
.tx-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; flex-shrink: 0;
}
.tx-icon.income  { background: var(--income-bg);  color: var(--income); }
.tx-icon.expense { background: var(--expense-bg); color: var(--expense); }
.tx-info { min-width: 0; }
.tx-desc {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tx-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.tx-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tx-amount { font-size: 15px; font-weight: 800; }
.tx-amount.income  { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.delete-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--expense-bg); color: var(--expense);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.unsync-dot { color: #ef6c00; font-size: 10px; margin-left: 3px; }

.empty-state {
  text-align: center; padding: 28px 16px;
  color: var(--text-2); font-size: 14px; line-height: 1.7;
}

/* ─── Voice Section ─── */
.voice-section {
  background: var(--card); border-radius: var(--radius);
  padding: 20px 16px; box-shadow: var(--shadow);
  margin-bottom: 14px; text-align: center;
}
.voice-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; color: var(--text); }

.voice-buttons-row {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 14px;
}
.voice-option   { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.voice-sublabel { font-size: 10px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.3px; }
.voice-or {
  font-size: 12px; color: var(--text-2); font-weight: 600;
  padding: 0 14px; align-self: center; margin-bottom: 18px;
}

.voice-button {
  width: 90px; height: 90px; border-radius: 50%;
  border: 3px solid var(--primary);
  background: var(--card); cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  margin: 0 auto 16px;
  transition: all 0.18s;
  box-shadow: 0 4px 16px rgba(46,125,50,0.18);
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.voice-button.listening {
  background: var(--primary); transform: scale(1.07);
  box-shadow: 0 6px 24px rgba(46,125,50,0.4);
}
.voice-button.listening .mic-icon  { filter: brightness(10); }
.voice-button.listening .mic-label { color: #fff; }
.voice-button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Whisper AI button — teal accent to distinguish it */
.whisper-btn { border-color: #00796b; box-shadow: 0 4px 16px rgba(0,121,107,0.18); }
.whisper-btn .mic-label { color: #00796b; }
.whisper-btn.listening  { background: #00796b; box-shadow: 0 6px 24px rgba(0,121,107,0.4); }
.mic-icon  { font-size: 30px; }
.mic-label { font-size: 9px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.5px; }

.transcript-area {
  min-height: 52px; background: #f5f5f5;
  border-radius: 10px; padding: 12px 14px; text-align: left;
}
.hint         { font-size: 13px; color: var(--text-2); font-style: italic; line-height: 1.5; }
.transcript-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.listening-text  { font-size: 14px; color: var(--primary); font-weight: 600; animation: blink 1s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.error-text { font-size: 13px; color: var(--expense); }

.parsed-preview {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; flex-wrap: wrap;
}
.parsed-type {
  font-size: 11px; font-weight: 800; padding: 3px 10px;
  border-radius: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.parsed-type.income  { background: var(--income-bg);  color: var(--income); }
.parsed-type.expense { background: var(--expense-bg); color: var(--expense); }
.parsed-amount { font-size: 17px; font-weight: 800; }
.parsed-desc   { font-size: 13px; color: var(--text-2); }
.use-voice-btn {
  margin-top: 10px; width: 100%; padding: 13px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background 0.15s;
}
.use-voice-btn:active { background: var(--primary-dark); }

.divider {
  text-align: center; font-size: 13px; color: var(--text-2);
  margin: 14px 0; user-select: none;
}

/* ─── Transaction Form ─── */
.transaction-form {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.type-btn {
  flex: 1; padding: 13px;
  border: 2px solid var(--border);
  border-radius: 10px; background: var(--card);
  font-size: 15px; font-weight: 700; cursor: pointer;
  color: var(--text-2); transition: all 0.18s;
}
.type-btn[data-type="income"].active  { border-color: var(--income);  background: var(--income-bg);  color: var(--income); }
.type-btn[data-type="expense"].active { border-color: var(--expense); background: var(--expense-bg); color: var(--expense); }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.4px; margin-bottom: 6px;
}
.form-group input, .form-group select {
  width: 100%; padding: 13px 14px;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 16px; color: var(--text); background: var(--card);
  transition: border-color 0.18s;
  appearance: none; -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--primary);
}
.amount-input { position: relative; }
.currency-prefix {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px; font-weight: 700; color: var(--text-2);
  pointer-events: none;
}
.amount-input input { padding-left: 50px; }

.submit-btn {
  width: 100%; padding: 16px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 12px;
  font-size: 17px; font-weight: 800; cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(46,125,50,0.3);
  transition: background 0.15s;
}
.submit-btn:active { background: var(--primary-dark); }

/* ─── Ledger ─── */
.ledger-header { margin-bottom: 12px; }
.filter-tabs   { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-btn {
  padding: 8px 18px; border: 2px solid var(--border);
  border-radius: 20px; background: var(--card);
  font-size: 13px; font-weight: 700; cursor: pointer; color: var(--text-2);
  transition: all 0.18s;
}
.filter-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

#month-filter {
  width: 100%; padding: 9px 12px;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; background: var(--card);
  appearance: none; -webkit-appearance: none;
}

.date-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 8px; background: var(--bg);
  border-radius: 8px; margin: 10px 0 0;
}
.date-label    { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; }
.day-summary   { font-size: 14px; font-weight: 800; }
.day-summary.positive { color: var(--income); }
.day-summary.negative { color: var(--expense); }

#ledger-list {
  background: var(--card); border-radius: var(--radius); padding: 0 12px; box-shadow: var(--shadow);
}

/* ─── Scan ─── */
.scan-area {
  background: var(--card); border-radius: var(--radius);
  padding: 20px 16px; box-shadow: var(--shadow);
}
.scan-area h3  { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.camera-preview {
  width: 100%; border-radius: 12px; overflow: hidden;
  background: #000; margin: 14px 0; display: none; position: relative;
}
#camera-video { width: 100%; display: block; max-height: 280px; object-fit: cover; }
.scan-controls { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.scan-btn {
  padding: 15px; background: var(--primary); color: #fff;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s;
}
.scan-btn:active { background: var(--primary-dark); }

.ocr-image { width: 100%; border-radius: 10px; margin-bottom: 12px; max-height: 220px; object-fit: contain; }
.ocr-status { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.ocr-result { }
.ocr-items  { }
.ocr-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border); gap: 10px;
}
.ocr-item:last-child { border-bottom: none; }
.ocr-item-info { flex: 1; min-width: 0; }
.ocr-item-desc   { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ocr-item-amount { font-size: 14px; font-weight: 800; color: var(--expense); }
.add-ocr-item {
  padding: 9px 14px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}

/* ─── Confirm Modal (bottom sheet) ─── */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: flex-end;
  z-index: 200;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-content {
  position: relative;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 24px 20px 36px; width: 100%; z-index: 1;
  animation: slideUp 0.28s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-content h3 { font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.confirm-type-badge {
  display: inline-block; font-size: 11px; font-weight: 800;
  padding: 4px 14px; border-radius: 14px; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 10px;
}
.confirm-type-badge.income  { background: var(--income-bg);  color: var(--income); }
.confirm-type-badge.expense { background: var(--expense-bg); color: var(--expense); }
.confirm-amount  { font-size: 34px; font-weight: 900; line-height: 1.1; margin-bottom: 8px; }
.confirm-amount.income  { color: var(--income); }
.confirm-amount.expense { color: var(--expense); }
.confirm-desc    { font-size: 16px; color: var(--text); margin-bottom: 4px; font-weight: 500; }
.confirm-meta    { font-size: 13px; color: var(--text-2); margin-bottom: 18px; }
.offline-note {
  font-size: 12px; background: #fff8e1; color: #e65100;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 14px; font-weight: 600;
}
.modal-actions { display: flex; gap: 10px; }
.btn-secondary {
  flex: 1; padding: 15px;
  border: 2px solid var(--border); border-radius: 12px;
  background: var(--card); font-size: 16px; font-weight: 700;
  cursor: pointer; color: var(--text);
}
.btn-primary {
  flex: 2; padding: 15px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 800; cursor: pointer;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%; transform: translateX(-50%) translateY(16px);
  background: #212121; color: #fff;
  padding: 12px 22px; border-radius: 24px;
  font-size: 14px; font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 88%; text-align: center;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Responsive tweak for larger screens ─── */
@media (min-width: 520px) {
  #app-header, #app-main, #bottom-nav { max-width: 520px; left: 50%; transform: translateX(-50%); right: auto; }
  #bottom-nav { width: 520px; }
  .modal-content { max-width: 520px; margin: 0 auto; border-radius: 24px; }
  .modal { justify-content: center; align-items: flex-end; }
}
