/* ====================================================
   Hissab – Elderly-Friendly Mobile Sales Tracker
   Mobile-first, large text, high contrast
   ==================================================== */

/* ---------- CSS Variables ---------- */
:root {
  --clr-bg:       #f4f6f8;
  --clr-white:    #ffffff;
  --clr-primary:  #1a73e8;
  --clr-primary-dark: #1558b0;
  --clr-green:    #0f9d58;
  --clr-green-bg: #e6f4ea;
  --clr-blue:     #1a73e8;
  --clr-blue-bg:  #e8f0fe;
  --clr-purple:   #7b1fa2;
  --clr-purple-bg:#f3e5f5;
  --clr-orange:   #e65100;
  --clr-orange-bg:#fff3e0;
  --clr-red:      #d32f2f;
  --clr-red-bg:   #fce8e6;
  --clr-danger:   var(--clr-red);
  --clr-text:     #202124;
  --clr-text-sub: #5f6368;
  --clr-border:   #dadce0;
  --clr-nav-bg:   #ffffff;
  --clr-nav-active: #1a73e8;
  --radius:       14px;
  --shadow:       0 2px 8px rgba(0,0,0,0.12);
  --font-base:    20px;    /* large base for elderly */
  --font-small:   16px;
  --font-large:   24px;
  --font-xl:      32px;
  --nav-height:   70px;
  --header-height:64px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: var(--font-base);
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  padding-bottom: var(--nav-height);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--clr-primary);
  color: var(--clr-white);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: var(--header-height);
  box-shadow: var(--shadow);
  gap: 10px;
}

.app-logo { font-size: 2rem; }

.app-title {
  font-size: var(--font-large);
  font-weight: 700;
  letter-spacing: 0.5px;
  flex: 1;
}

.header-date {
  font-size: var(--font-small);
  opacity: 0.9;
  text-align: right;
  white-space: nowrap;
}

/* ---------- Main Scrollable Content ---------- */
.main-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

/* ---------- Tab Sections ---------- */
.tab-section { display: none; }
.tab-section.active { display: block; }

/* ---------- Summary Cards ---------- */
.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow);
  border-left: 5px solid transparent;
}

.card-green  { border-left-color: var(--clr-green);  background: var(--clr-green-bg); }
.card-blue   { border-left-color: var(--clr-blue);   background: var(--clr-blue-bg); }
.card-purple { border-left-color: var(--clr-purple); background: var(--clr-purple-bg); }
.card-orange { border-left-color: var(--clr-orange); background: var(--clr-orange-bg); }

.card-label {
  font-size: var(--font-small);
  color: var(--clr-text-sub);
  margin-bottom: 6px;
}

.card-value {
  font-size: var(--font-xl);
  font-weight: 700;
  line-height: 1.1;
}

.card-green  .card-value { color: var(--clr-green); }
.card-blue   .card-value { color: var(--clr-blue); }
.card-purple .card-value { color: var(--clr-purple); }
.card-orange .card-value { color: var(--clr-orange); }

.card-sub {
  font-size: var(--font-small);
  color: var(--clr-text-sub);
  margin-top: 4px;
}

/* ---------- Section Titles ---------- */
.section-title {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--clr-text);
  margin: 20px 0 10px;
  border-bottom: 2px solid var(--clr-border);
  padding-bottom: 6px;
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--clr-primary);
  color: var(--clr-white);
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover  { background: var(--clr-primary-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-big {
  width: 100%;
  justify-content: center;
  padding: 18px 24px;
  font-size: var(--font-large);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.btn-danger {
  background: var(--clr-danger);
  color: var(--clr-white);
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

.btn-secondary {
  background: var(--clr-white);
  color: var(--clr-text);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

.btn-nav {
  background: none;
  border: none;
  font-size: var(--font-large);
  cursor: pointer;
  padding: 8px 14px;
  color: var(--clr-primary);
  touch-action: manipulation;
}

/* ---------- Form ---------- */
.form-card {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
}

.form-title {
  font-size: var(--font-large);
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--clr-primary);
}

.form-label {
  display: block;
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 6px;
  margin-top: 14px;
}

.form-input {
  display: block;
  width: 100%;
  padding: 16px 14px;
  font-size: var(--font-large);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-white);
  color: var(--clr-text);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-input:focus { border-color: var(--clr-primary); }

.save-msg {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: var(--font-base);
  font-weight: 600;
  text-align: center;
}

.save-msg.success { background: var(--clr-green-bg); color: var(--clr-green); }
.save-msg.error   { background: #fce8e6; color: var(--clr-danger); }
.hidden { display: none !important; }

/* ---------- Item List ---------- */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item-info { flex: 1; }

.item-name {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--clr-text);
}

.item-time {
  font-size: var(--font-small);
  color: var(--clr-text-sub);
  margin-top: 3px;
}

.item-price {
  font-size: var(--font-large);
  font-weight: 700;
  color: var(--clr-green);
  white-space: nowrap;
}

.item-delete {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #b0b0b0;
  padding: 6px;
  line-height: 1;
  touch-action: manipulation;
  transition: color 0.2s;
}
.item-delete:hover { color: var(--clr-danger); }

.empty-msg {
  color: var(--clr-text-sub);
  font-size: var(--font-base);
  text-align: center;
  padding: 24px 0;
  line-height: 1.6;
}

/* ---------- Log Header (date navigation) ---------- */
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 8px 4px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.log-date-label {
  font-size: var(--font-large);
  font-weight: 700;
  color: var(--clr-text);
  text-align: center;
  flex: 1;
}

.day-total-bar {
  background: var(--clr-green-bg);
  color: var(--clr-green);
  font-size: var(--font-large);
  font-weight: 700;
  text-align: center;
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

/* ---------- Monthly Breakdown ---------- */
.breakdown-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.breakdown-row {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  gap: 10px;
}

.breakdown-day {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--clr-text);
  min-width: 100px;
}

.breakdown-items {
  font-size: var(--font-small);
  color: var(--clr-text-sub);
  flex: 1;
}

.breakdown-profit {
  font-size: var(--font-small);
  font-weight: 600;
  margin-top: 2px;
}
.breakdown-profit.profit { color: var(--clr-green); }
.breakdown-profit.loss   { color: var(--clr-red); }

.breakdown-total {
  font-size: var(--font-large);
  font-weight: 700;
  color: var(--clr-primary);
  white-space: nowrap;
}

/* ---------- Chart ---------- */
.chart-container {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 16px 10px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  max-height: 260px;
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--clr-nav-bg);
  border-top: 1px solid var(--clr-border);
  display: flex;
  height: var(--nav-height);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  gap: 3px;
  color: var(--clr-text-sub);
  font-size: 0.75rem;
  touch-action: manipulation;
  transition: color 0.2s;
}

.nav-btn.active { color: var(--clr-nav-active); }
.nav-btn:focus  { outline: 2px solid var(--clr-primary); }

.nav-icon { font-size: 1.6rem; line-height: 1; }
.nav-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.2px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 28px 22px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-text {
  font-size: var(--font-large);
  font-weight: 600;
  text-align: center;
  margin-bottom: 22px;
}

.modal-row {
  display: flex;
  gap: 12px;
}

/* ---------- Responsive tweaks for larger screens ---------- */
@media (min-width: 600px) {
  .main-content { padding: 24px 20px 32px; }
  .card-value    { font-size: 2.4rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --clr-bg:      #1c1c1e;
    --clr-white:   #2c2c2e;
    --clr-text:    #f2f2f7;
    --clr-text-sub:#aeaeb2;
    --clr-border:  #3a3a3c;
    --clr-nav-bg:  #1c1c1e;
    --clr-green-bg:#0a3320;
    --clr-blue-bg: #0a2040;
    --clr-purple-bg:#2a0a3a;
    --clr-orange-bg:#3a1a00;
    --clr-red-bg:  #3a0a0a;
  }
}

/* ---------- card-red ---------- */
.card-red  { border-left-color: var(--clr-red);   background: var(--clr-red-bg); }
.card-red  .card-value { color: var(--clr-red); }

/* ---------- Form label optional hint ---------- */
.form-label-optional {
  font-size: var(--font-small);
  font-weight: 400;
  color: var(--clr-text-sub);
}

/* ---------- Item profit/margin sub-line ---------- */
.item-margin {
  font-size: var(--font-small);
  margin-top: 3px;
}
.item-margin.profit { color: var(--clr-green); }
.item-margin.loss   { color: var(--clr-red); }

/* ---------- Loan cards ---------- */
.loans-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.loan-card {
  background: var(--clr-white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.loan-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.loan-name {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--clr-text);
  flex: 1;
}

.loan-total {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--clr-primary);
  white-space: nowrap;
}

.loan-progress-bar {
  height: 10px;
  border-radius: 99px;
  background: var(--clr-border);
  overflow: hidden;
  margin-bottom: 8px;
}

.loan-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--clr-green);
  transition: width 0.3s;
}

.loan-progress-fill.overpaid { background: var(--clr-orange); }

.loan-stats {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-small);
  color: var(--clr-text-sub);
  margin-bottom: 10px;
}

.loan-remaining {
  font-weight: 700;
  color: var(--clr-danger);
}

.loan-remaining.paid-off {
  color: var(--clr-green);
}

.loan-actions {
  display: flex;
  gap: 10px;
}

.btn-pay {
  flex: 1;
  background: var(--clr-green);
  color: var(--clr-white);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: var(--font-small);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s;
}
.btn-pay:hover { background: #0b7a42; }

.btn-loan-delete {
  background: none;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 1.1rem;
  cursor: pointer;
  color: #b0b0b0;
  touch-action: manipulation;
  transition: color 0.2s, border-color 0.2s;
}
.btn-loan-delete:hover { color: var(--clr-danger); border-color: var(--clr-danger); }

/* ---------- 5-tab nav ---------- */
.nav-label { font-size: 0.68rem; }

/* ---------- Modal form input spacing ---------- */
.modal-input { margin-bottom: 10px; }
.modal-input:last-of-type { margin-bottom: 16px; }

