/* ============================================================
   Suchitra Collections — Stylesheet
   Design: Matched to MeterBabu (ai.suchitrafabrics.com)
   Font: IBM Plex Sans · Colors: MeterBabu :root vars
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* ── MeterBabu-matched tokens ── */
  --bg:        #f2ede3;
  --panel:     #faf7f0;
  --panel2:    #e5dcc8;
  --border:    #cec5b0;
  --orange:    #c94808;
  --orange-dim:#a33906;
  --text:      #0d0f0e;
  --muted:     #7a7060;
  --success:   #1a6b3c;
  --danger:    #d03030;
  --warning:   #b89000;
  --info:      #1860a8;
  --topbar:    #131825;
  --radius:    10px;

  /* ── Aliases used throughout the CSS ── */
  --navy:      #131825;
  --navy-dark: #0d1020;
  --navy-mid:  #1e2a40;
  --amber:     #c94808;
  --amber-lt:  #fdf0e8;
  --green:     #1a6b3c;
  --green-lt:  #d4f0e1;
  --red:       #d03030;
  --red-lt:    #fde8e8;
  --yellow:    #b89000;
  --yellow-lt: #fdf5d0;
  --blue-lt:   #dbeafe;
  --gray-50:   var(--panel);
  --gray-100:  var(--bg);
  --gray-200:  var(--border);
  --gray-400:  var(--muted);
  --gray-600:  #5a5040;
  --gray-800:  var(--text);
  --white:     #ffffff;
  --shadow:    0 1px 4px rgba(0,0,0,.07), 0 2px 10px rgba(0,0,0,.05);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.12);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  background-color: var(--bg);
  /* Same crosshatch grid texture as MeterBabu */
  background-image:
    linear-gradient(rgba(180,168,148,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180,168,148,.18) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { font-size: .95rem; }

/* ── Header / Topbar ─────────────────────────────────────── */
.topbar {
  background: var(--topbar);
  color: var(--white);
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--orange);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.topbar-brand .logo-dot {
  width: 30px; height: 30px;
  background: var(--orange);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; color: var(--white);
  font-family: 'IBM Plex Sans', sans-serif;
  letter-spacing: -.01em;
}
.topbar-brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.01em;
}
.topbar-brand span {
  font-size: .72rem;
  color: rgba(255,255,255,.6);
  display: block;
  margin-top: -2px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-user {
  font-size: .82rem;
  color: rgba(255,255,255,.8);
}
.topbar-user strong { color: var(--amber); }

/* ── Nav tabs ────────────────────────────────────────────── */
.nav-tabs {
  background: var(--topbar);
  display: flex;
  padding: .5rem 1.25rem;
  gap: .35rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.nav-tab {
  padding: .4rem 1rem;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: all .15s;
  letter-spacing: .01em;
}
.nav-tab:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.06); }
.nav-tab.active {
  background: var(--orange);
  color: var(--white);
}

/* ── Container ───────────────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.25rem;
}
.container-wide { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.card-header {
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--panel2);
}
.card-header h3 { color: var(--text); font-size: .92rem; font-weight: 700; }
.card-header .icon {
  width: 28px; height: 28px;
  background: var(--navy);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: .9rem;
  flex-shrink: 0;
}
.card-header .icon.amber { background: var(--amber); }
.card-header .icon.green { background: var(--green); }
.card-header .icon.red   { background: var(--red); }
.card-body { padding: 1.1rem; }

/* ── Form elements ───────────────────────────────────────── */
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
input[type="text"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .92rem;
  color: var(--text);
  background: var(--panel);
  font-family: 'IBM Plex Sans', sans-serif;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(201,72,8,.12);
}
textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.form-group { margin-bottom: .9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* Party search autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white);
  border: 1.5px solid var(--navy);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  display: none;
}
.autocomplete-item {
  padding: .65rem .9rem;
  cursor: pointer;
  font-size: .9rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
}
.autocomplete-item:hover { background: var(--amber-lt); }
.autocomplete-item .outstanding {
  font-size: .78rem;
  color: var(--red);
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--orange); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--orange-dim); }
.btn-amber     { background: var(--orange); color: var(--white); }
.btn-amber:hover:not(:disabled) { background: var(--orange-dim); }
.btn-green     { background: var(--green); color: var(--white); }
.btn-green:hover:not(:disabled) { background: #15803d; }
.btn-outline   { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--orange); color: var(--white); border-color: var(--orange); }
.btn-danger    { background: var(--red); color: var(--white); }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Voice recorder ──────────────────────────────────────── */
.voice-section { text-align: center; padding: .5rem 0; }
.mic-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-size: 1.8rem;
  border: none;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.mic-btn.recording {
  background: var(--red);
  animation: pulse 1.2s ease-in-out infinite;
}
.mic-btn:hover:not(:disabled) { transform: scale(1.06); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%       { box-shadow: 0 0 0 16px rgba(220,38,38,.0); }
}
.voice-status {
  margin-top: .5rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-400);
}
.voice-status.active { color: var(--red); }
.lang-selector {
  display: flex;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .85rem;
}
.lang-btn {
  padding: .3rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--white);
  cursor: pointer;
  transition: all .15s;
  color: var(--gray-600);
}
.lang-btn.active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* ── Status badges ───────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
}
.status-chip {
  padding: .5rem .6rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--gray-600);
  background: var(--white);
}
.status-chip:hover { border-color: var(--navy); }
.status-chip.active {
  color: var(--white);
  border-color: transparent;
}
.status-chip[data-val="payment_received"].active  { background: var(--green); }
.status-chip[data-val="part_payment"].active      { background: var(--green); }
.status-chip[data-val="cheque_received"].active   { background: var(--navy-mid); }
.status-chip[data-val="promise_to_pay"].active    { background: var(--yellow); }
.status-chip[data-val="complaint"].active         { background: var(--red); }
.status-chip[data-val="no_answer"].active         { background: var(--gray-400); }
.status-chip[data-val="rescheduled"].active       { background: var(--amber); }
.status-chip[data-val="other"].active             { background: var(--gray-600); }

/* ── Photo upload ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--amber);
  background: var(--amber-lt);
}
.upload-zone p { font-size: .85rem; color: var(--gray-600); margin-top: .35rem; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-top: .75rem;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--gray-200);
}
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.photo-thumb .remove-photo {
  position: absolute; top: 3px; right: 3px;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: .7rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-thumb .type-tag {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.55);
  color: var(--white);
  font-size: .65rem;
  font-weight: 700;
  text-align: center;
  padding: 2px;
}
.ocr-result {
  background: var(--blue-lt);
  border: 1px solid #BFDBFE;
  border-radius: 8px;
  padding: .75rem .9rem;
  margin-top: .5rem;
  font-size: .8rem;
}
.ocr-result strong { display: block; margin-bottom: .25rem; color: var(--navy); }

/* ── Summary stat cards ──────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
@media (min-width: 640px) { .stat-cards { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: .72rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; color: var(--orange); margin: .15rem 0; }
.stat-card .sub   { font-size: .75rem; color: var(--gray-600); }
.stat-card.amber .value { color: var(--amber); }
.stat-card.green .value { color: var(--green); }
.stat-card.red   .value { color: var(--red); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  background: var(--panel2);
  padding: .65rem .85rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
tbody tr:hover { background: var(--gray-50); }
.badge {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-green  { background: var(--green-lt);  color: #15803d; }
.badge-navy   { background: var(--blue-lt);   color: var(--navy-mid); }
.badge-yellow { background: var(--yellow-lt); color: #92400e; }
.badge-red    { background: var(--red-lt);    color: var(--red); }
.badge-gray   { background: var(--gray-200);  color: var(--gray-600); }
.badge-amber  { background: var(--amber-lt);  color: #92400e; }

/* ── Filters ─────────────────────────────────────────────── */
.filters {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: flex-end;
}
.filters .form-group { margin-bottom: 0; flex: 1; min-width: 130px; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--topbar);
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 32px 32px;
  padding: 1.5rem;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  width: 60px; height: 60px;
  background: var(--orange);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 1.2rem;
}
.login-card h2 { color: var(--text); margin-bottom: .25rem; }
.login-card p  { color: var(--gray-400); font-size: .85rem; margin-bottom: 1.75rem; }
.pin-inputs {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-bottom: 1.2rem;
}
.pin-digit {
  width: 48px; height: 56px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  outline: none;
  transition: border-color .2s;
  background: var(--gray-50);
}
.pin-digit:focus { border-color: var(--navy); background: var(--white); }
.employee-select { margin-bottom: 1rem; }
.error-msg {
  background: var(--red-lt);
  color: var(--red);
  border-radius: 8px;
  padding: .55rem .9rem;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .75rem;
}
.success-msg {
  background: var(--green-lt);
  color: var(--green);
  border-radius: 8px;
  padding: .55rem .9rem;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .75rem;
}

/* ── Toast notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(420px, 92vw);
}
.toast {
  padding: .75rem 1.1rem;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--white);
  animation: slideUp .25s ease;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--navy-mid); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { color: var(--navy); }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 1.2rem;
}
.modal-body { padding: 1.25rem; }

/* ── Misc helpers ────────────────────────────────────────── */
.text-muted    { color: var(--gray-400); font-size: .82rem; }
.text-right    { text-align: right; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.amount { font-weight: 700; font-family: 'Courier New', monospace; }
.amount.credit { color: var(--green); }
.amount.debit  { color: var(--red); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .nav-tab { padding: .6rem .7rem; font-size: .8rem; }
}
