/* General Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;	
}

 body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #fffaf0; /* golden-light */
  color: #333;
  line-height: 1.6;
  /*padding: 20px;*/
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: auto;
}

/* Navbar */
.navbar {
  background: #bfa059;
  color: white;
  padding: 15px 0;
}

.navbar .container {
  /* Overrides the generic .container's width:90%/max-width:1200px — the
     navbar spans the full banner width instead of being capped to a
     centered column, which on wide screens left large empty margins and
     also starved the nav-links row of the space it needs to avoid wrapping. */
  width: 100%;
  max-width: none;
  padding: 0 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar .logo {
  font-size: 1.8rem;
  font-weight: 600;
}

.navbar .logo a {
  color: inherit;
  text-decoration: none;
}

.navbar .nav-links {
  list-style: none;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  row-gap: 8px;
  gap: 16px;
  margin-left: 40px;
}

.navbar .nav-links a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: 0.3s;
  white-space: nowrap;
}

.navbar .nav-links a:hover {
  color: #fff0c1;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 30px;
  height: 24px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background: white;
  border-radius: 2px;
}

/* Hero Section */
.hero {
  width: 100%;
  height: 20vh;
  background: linear-gradient(rgba(191,160,89,0.85), rgba(191,160,89,0.85)), url('https://images.unsplash.com/photo-1581091215363-50e0d9110c07?auto=format&fit=crop&w=1470&q=80') no-repeat center center/cover;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: white;
  padding: 0 20px;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 15px;
}

.hero p {
  font-size: 1.2rem;
  margin-bottom: 20px;
}

/* Buttons */
.btn {
  background-color: #ffd700;
  color: #333;
  padding: 12px 25px;
  text-decoration: none;
  font-weight: 600;
  border-radius: 5px;
  transition: 0.3s;
}

.btn:hover {
  background-color: #e6c200;
}

/* About Section */
.about {
  padding: 50px 0;
  text-align: center;
}

.about h2 {
  color: #bfa059;
  margin-bottom: 20px;
}

/* Contact Section */
.contact {
  padding: 50px 0;
  background-color: #fff8e1;
  text-align: center;
}

.contact h2 {
  color: #bfa059;
  margin-bottom: 15px;
}

/* Headings */
h2 {
  color: #bfa059;
  border-bottom: 2px solid #bfa059;
  padding-bottom: 6px;
  margin-bottom: 15px;
}

h3 {
  margin-top: 20px;
  color: #7a5c20;
}

h3.total {
  text-align: right;
  padding-right: 30px;
  font-weight: bold;
  font-size: 1.1em;
}

/* Tables */
.table-wrapper {
  position: relative;
  overflow-x: auto;
  margin-bottom: 30px;
}

.table-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.12));
  opacity: 0;
  transition: opacity 0.2s;
}

.table-scroll-hint {
  display: none;
  text-align: center;
  font-size: 0.75rem;
  color: #8a8a8a;
  margin: -6px 0 14px;
  opacity: 1;
  transition: opacity 0.3s;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 10px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  min-width: 600px; /* ensure horizontal scroll on small screens */
}

th, td {
  border: 1px solid #dee2e6;
  padding: 6px;
  text-align: center;
}

th {
  background-color: #cc9e48;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.4px;
  font-size: 0.87rem;
  padding: 10px 8px;
}

tfoot td {
  font-weight: 700;
  background-color: #fff3cd;
  color: #7a5c20;
  font-size: 0.93rem;
  letter-spacing: 0.2px;
}

/* Inputs */
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100px;
  text-align: right;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Buttons inside tables */
button {
  padding: 6px 10px;
  margin: 2px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.add-row, .add-row-cash, .add-row-item, .add-row-others {
  background-color: #28a745; /* green */
  color: white;
}

.remove-row, .remove-cash-row, .remove-item-row, .remove-others-row {
  background-color: #dc3545; /* red */
  color: white;
}

.fetch-rate {
  background-color: #17a2b8; /* blue */
  color: white;
}

#finalEstimateTable th {
  background-color: #cc9e48;
  color: #fff;
}

#final_estimate {
  font-weight: bold;
  color: #28a745;
}

/* Bottom Buttons */
.bottom-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
}

.verify-btn, .refresh-page {
  padding: 12px 22px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.verify-btn {
  background-color: #4CAF50; /* green */
  color: white;
}

.verify-btn:hover {
  background-color: #3e8e41;
}

.refresh-page {
  background-color: #008CBA; /* blue */
  color: white;
}

.refresh-page:hover {
  background-color: #006f98;
}

/* Navbar gold rate display */
.nav-rate-item {
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  padding-left: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

#gold-rate {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-rate-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.nav-updated-time {
  font-size: 0.63rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  white-space: nowrap;
}

.nav-refresh-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background-color 0.2s;
  font-family: 'Montserrat', sans-serif;
}

.nav-refresh-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Footer */
footer {
  background: #bfa059;
  color: white;
  padding: 15px 0;
  text-align: center;
}

/* Responsive */
@media(max-width: 768px) {
  .navbar .container {
    padding: 0 20px;
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: flex;
  }

  .table-wrapper.can-scroll::after {
    opacity: 1;
  }

  .table-scroll-hint {
    display: block;
  }

  .navbar .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    margin-left: 0;
    gap: 10px;
    width: 100%;
    margin-top: 12px;
  }

  .navbar.nav-open .nav-links {
    display: flex;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero p {
    font-size: 1rem;
  }
  /*
  input[type="date"], [type="text"], input[type="number"], select {
    width: 80px;
  }
  */
  }


  /* Inputs */
  input[type="text"] {
    width: 100%;      /* use full cell width */
    max-width: 250px; /* prevent being too wide */
    text-align: left; /* better for text */
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

  input[type="number"] {
    width: 100px;
    text-align: right;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

  input[type="date"] {
    width: 120px; /* wider to show full date */
    text-align: center;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

  select {
    width: auto;        /* only minimum width needed */
    min-width: 60px;    /* ensure it doesn't shrink too much */
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
}
input.purity {
    width: 50px;
    text-align: right;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

input.others-stone, input.others-bead, input.others-mc, input.item-weight, input.item-stone, input.item-bead, input.item-wastage {
    width: 75px;
    text-align: right;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

/* ====== CALCULATOR PAGE ENHANCEMENTS ====== */

.calc-main {
  padding: 36px 0 60px;
}

.section-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 3px 18px rgba(191,160,89,0.13);
  padding: 26px 30px;
  margin-bottom: 24px;
  border: 1px solid #e8d9a0;
}

.section-card h2 {
  margin-top: 0;
}

/* Table row interactions */
tbody tr {
  transition: background-color 0.12s;
}

tbody tr:hover {
  background-color: #fff8e8 !important;
}

#givenGoldTable tbody tr:nth-child(even),
#givenCashTable tbody tr:nth-child(even),
#itemsTable tbody tr:nth-child(even),
#othersTable tbody tr:nth-child(even) {
  background-color: #fffdf8;
}

/* Input focus ring */
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: #bfa059;
  box-shadow: 0 0 0 2px rgba(191,160,89,0.22);
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Total summary bars */
h3.total {
  background: linear-gradient(90deg, #fff8e1, #fffaf0);
  border: 1px solid #e8d9a0;
  border-radius: 8px;
  padding: 14px 24px;
  box-shadow: 0 1px 5px rgba(191,160,89,0.1);
}

.given-grand-total-display,
.grand-total-display {
  font-size: 1.15em;
  color: #a07828;
}

/* Add-row buttons */
.add-row, .add-row-cash, .add-row-item, .add-row-others {
  margin-top: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.add-row:hover, .add-row-cash:hover, .add-row-item:hover, .add-row-others:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(40,167,69,0.3);
}

/* Remove buttons */
.remove-row, .remove-cash-row, .remove-item-row, .remove-others-row {
  font-size: 12px;
  padding: 4px 10px;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s;
}

.remove-row:hover, .remove-cash-row:hover,
.remove-item-row:hover, .remove-others-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(220,53,69,0.3);
}

/* Fetch rate button */
.fetch-rate {
  transition: transform 0.15s, box-shadow 0.15s;
}

.fetch-rate:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(23,162,184,0.3);
}

/* Bottom action buttons */
.verify-btn, .refresh-page {
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.4px;
}

.verify-btn:hover {
  background-color: #3e8e41;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76,175,80,0.35);
}

.refresh-page:hover {
  background-color: #006f98;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,140,186,0.35);
}

/* ====== MODE SWITCH (Buy vs Exchange) ====== */
.mode-switch {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1 1 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border: 2px solid #e8d9a0;
  background: #fff;
  border-radius: 12px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  color: #7a5c20;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.mode-btn:hover {
  border-color: #bfa059;
}

.mode-btn.active {
  background: linear-gradient(135deg, #bfa059, #d8b76a);
  border-color: #bfa059;
  color: #fff;
  box-shadow: 0 4px 14px rgba(191,160,89,0.35);
}

.mode-icon {
  font-size: 1.1rem;
}

.mode-hint {
  text-align: center;
  color: #8a7248;
  font-size: 0.92rem;
  margin-bottom: 26px;
}

.calc-main.mode-buy .exchange-only {
  display: none;
}

/* ====== SECTION HEADERS ====== */
.section-card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  color: #6b4f18;
}

.section-icon {
  font-size: 1.15rem;
}

.section-subtext {
  color: #8a7a55;
  font-size: 0.88rem;
  margin: -6px 0 18px;
}

/* ====== ICON-STYLE ROW BUTTONS ====== */
.remove-row, .remove-cash-row, .remove-item-row, .remove-others-row {
  background: #fff;
  border: 1px solid #dc3545;
  color: #dc3545;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
  font-size: 13px;
}

.remove-row:hover, .remove-cash-row:hover,
.remove-item-row:hover, .remove-others-row:hover {
  background: #dc3545;
  color: #fff;
}

.add-row, .add-row-cash, .add-row-item, .add-row-others {
  background: #fff;
  border: 1.5px dashed #bfa059;
  color: #7a5c20;
}

.add-row:hover, .add-row-cash:hover, .add-row-item:hover, .add-row-others:hover {
  background: #fff8e8;
  border-style: solid;
  box-shadow: 0 2px 8px rgba(191,160,89,0.25);
}

/* ====== BOTTOM ACTION BUTTONS ====== */
.verify-btn {
  background: linear-gradient(135deg, #bfa059, #d8b76a);
}

.verify-btn:hover {
  background: linear-gradient(135deg, #a98a44, #c7a355);
}

.refresh-page {
  background: #fff;
  border: 2px solid #bfa059;
  color: #7a5c20;
  box-shadow: none;
}

.refresh-page:hover {
  background: #fff8e8;
  color: #6b4f18;
  box-shadow: none;
}

/* ====== FINAL ESTIMATE SUMMARY ====== */
.final-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.final-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px dashed #e8d9a0;
  font-size: 0.95rem;
  flex-wrap: wrap;
  gap: 8px;
}

.final-label {
  color: #6b5a35;
  font-weight: 500;
}

.final-value {
  font-weight: 600;
  color: #333;
}

.final-rate-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.final-total-row {
  border-bottom: none;
  border-top: 2px solid #bfa059;
  margin-top: 8px;
  padding-top: 16px;
}

.final-total-row .final-label {
  font-size: 1.05rem;
  color: #6b4f18;
  font-weight: 700;
}

.final-total {
  font-size: 1.5rem;
  color: #2e7d32;
  font-weight: 800;
}

/* ====== MOBILE CARD LAYOUT FOR ENTRY TABLES ====== */
@media (max-width: 700px) {
  .mode-switch {
    flex-direction: column;
  }

  #givenGoldTable, #givenCashTable, #itemsTable, #othersTable {
    min-width: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  #givenGoldTable thead, #givenCashTable thead,
  #itemsTable thead, #othersTable thead {
    display: none;
  }

  #givenGoldTable tbody, #givenCashTable tbody,
  #itemsTable tbody, #othersTable tbody {
    display: block;
  }

  #givenGoldTable tbody tr, #givenCashTable tbody tr,
  #itemsTable tbody tr, #othersTable tbody tr {
    display: block;
    background: #fff;
    border: 1px solid #e8d9a0;
    border-radius: 10px;
    padding: 6px 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(191,160,89,0.12);
  }

  #givenGoldTable td, #givenCashTable td,
  #itemsTable td, #othersTable td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    border-bottom: 1px solid #f2ead1;
    padding: 8px 2px;
    text-align: right;
  }

  #givenGoldTable td:last-child, #givenCashTable td:last-child,
  #itemsTable td:last-child, #othersTable td:last-child {
    border-bottom: none;
    justify-content: flex-end;
  }

  #givenGoldTable td[data-label]::before, #givenCashTable td[data-label]::before,
  #itemsTable td[data-label]::before, #othersTable td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: #7a5c20;
    font-size: 0.8rem;
    margin-right: 10px;
  }

  #givenGoldTable td[data-label=""]::before, #givenCashTable td[data-label=""]::before,
  #itemsTable td[data-label=""]::before, #othersTable td[data-label=""]::before {
    content: '';
    margin: 0;
  }

  #givenGoldTable td.serial, #givenCashTable td.serial,
  #itemsTable td.serial, #othersTable td.serial {
    display: none;
  }

  #givenGoldTable tfoot tr, #givenCashTable tfoot tr,
  #itemsTable tfoot tr, #othersTable tfoot tr {
    display: flex;
    justify-content: space-between;
    background: #fff3cd;
    border-radius: 8px;
    padding: 10px 12px;
  }

  #givenGoldTable tfoot td, #givenCashTable tfoot td,
  #itemsTable tfoot td, #othersTable tfoot td {
    border: none;
    display: inline;
    padding: 0;
  }

  #givenGoldTable tfoot td:last-child, #givenCashTable tfoot td:last-child,
  #itemsTable tfoot td:last-child, #othersTable tfoot td:last-child {
    display: none;
  }

  .final-row {
    font-size: 0.9rem;
  }
}

/* ====== PRINT ====== */
.print-btn {
  background: #fff;
  border: 2px solid #7a5c20;
  color: #7a5c20;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: none;
}

.print-btn:hover {
  background: #fff8e8;
  color: #6b4f18;
}

/* Built by calc-mode.js right before printing: a condensed line-item
   receipt, not a dump of the on-screen tables — wide multi-column tables
   don't fit a print page and rows get chopped across page breaks. */
.print-receipt {
  display: none;
}

@media print {
  .navbar, .hero, .mode-switch, .mode-hint,
  .bottom-buttons, footer, .table-scroll-hint,
  .section-card {
    display: none !important;
  }

  body, .calc-main {
    background: #fff !important;
    padding: 0 !important;
  }

  .container {
    width: 100% !important;
    max-width: none !important;
  }

  .print-receipt {
    display: block !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #000;
  }

  .receipt-header {
    text-align: center;
    margin-bottom: 22px;
    border-bottom: 2px solid #bfa059;
    padding-bottom: 12px;
  }

  .receipt-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #6b4f18;
  }

  .receipt-title {
    font-size: 1rem;
    margin-top: 2px;
  }

  .receipt-meta {
    font-size: 0.8rem;
    color: #555;
    margin-top: 4px;
  }

  .receipt-section {
    margin-bottom: 18px;
    page-break-inside: avoid;
  }

  .receipt-section-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #6b4f18;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
    margin-bottom: 8px;
  }

  .receipt-line {
    font-size: 0.88rem;
    padding: 4px 0;
    border-bottom: 1px dotted #ddd;
  }

  .receipt-empty {
    color: #888;
    font-style: italic;
  }

  .receipt-subtotal {
    border-bottom: none;
    font-weight: 600;
    text-align: right;
    margin-top: 4px;
  }

  .receipt-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.92rem;
    padding: 5px 0;
    border-bottom: 1px dashed #ddd;
  }

  .receipt-final {
    border-top: 2px solid #bfa059;
    padding-top: 10px;
  }

  .receipt-total {
    border-top: 2px solid #bfa059;
    border-bottom: none;
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 700;
    font-size: 1.1rem;
  }
}

