/* ============================================
   RIOSAN CHECK VOUCHER SYSTEM — Main Stylesheet
   ============================================ */

:root {
  --brand-red: #C8102E;
  --brand-red-dark: #9c0c23;
  --brand-red-glow: rgba(200, 16, 46, 0.35);
  --sidebar-dark: #0C0C0C;
  --bg-light: #F2F4F7;
  --text-primary: #111827;
  --shadow-ios: 0 4px 20px -2px rgba(0,0,0,0.06);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: var(--bg-light);
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  margin: 0;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand-red); color: #fff; }

/* ---- Scrollbar ---- */
.custom-scrollbar::-webkit-scrollbar { width: 7px; height: 7px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Inputs ---- */
.riosan-input {
  width: 100%;
  border: 1px solid #D1D5DB;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #1F2937;
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: 'Inter', sans-serif;
}
.riosan-input:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.12);
}
select.riosan-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.2em;
  padding-right: 2rem;
}

/* ---- Mono ---- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* ---- Voucher Status Badges ---- */
.badge-cv  { background: #dbeafe; color: #1d4ed8; }
.badge-cd  { background: #d1fae5; color: #065f46; }
.badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; display: inline-block; }

/* ---- Button base ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1.1rem; border-radius: 0.6rem; font-weight: 700;
  font-size: 0.82rem; border: none; cursor: pointer; transition: all 0.18s; gap: 6px;
  font-family: 'Inter', sans-serif;
}
.btn-red   { background: var(--brand-red); color: #fff; box-shadow: 0 4px 12px var(--brand-red-glow); }
.btn-red:hover { background: var(--brand-red-dark); }
.btn-dark  { background: var(--sidebar-dark); color: #fff; }
.btn-dark:hover { background: #222; }
.btn-gray  { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.btn-gray:hover { background: #e5e7eb; }
.btn-green { background: #059669; color: #fff; }
.btn-green:hover { background: #047857; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.75rem; border-radius: 0.4rem; }

/* ---- Header ---- */
#app-header {
  background: #fff;
  border-bottom: 4px solid var(--brand-red);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-ios);
  gap: 16px;
  flex-wrap: wrap;
  z-index: 10;
  position: relative;
}

/* ---- Logo area ---- */
#logo-area {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
}
#logo-wrap {
  width: 54px; height: 54px; border-radius: 10px;
  border: 1px solid #e5e7eb; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #fff; position: relative; flex-shrink: 0;
}
#logo-wrap:hover .logo-overlay { opacity: 1; }
.logo-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; border-radius: 9px;
}
#appLogoImg { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
#appLogoFallback {
  display: none; width: 100%; height: 100%;
  background: var(--sidebar-dark); color: var(--brand-red);
  align-items: center; justify-content: center; font-size: 22px;
}

/* ---- Header Title ---- */
.header-title-text { font-size: 1.3rem; font-weight: 900; color: #111; text-transform: uppercase; letter-spacing: -0.03em; line-height: 1.2; }
.header-company-sub { font-size: 0.7rem; color: #6b7280; font-weight: 600; margin-top: 2px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- Auth Overlay ---- */
#auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(12,12,12,0.96);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s;
}
.auth-box {
  background: #fff; padding: 40px; border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  max-width: 360px; width: 100%; text-align: center;
  border-top: 4px solid var(--brand-red);
}
.auth-icon {
  width: 76px; height: 76px; background: #fff5f5; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px; border: 2px solid #fee2e2;
  font-size: 28px; color: var(--brand-red);
}
.auth-title { font-size: 1.4rem; font-weight: 900; color: #111; text-transform: uppercase; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-sub { font-size: 0.82rem; color: #6b7280; font-weight: 500; margin-bottom: 22px; }
#sys-password {
  width: 100%; border: 2px solid #e5e7eb; border-radius: 12px;
  padding: 14px; text-align: center; font-size: 1.2rem;
  letter-spacing: 0.4em; font-weight: 700; color: #111;
  margin-bottom: 14px; font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
}
#sys-password:focus { outline: none; border-color: var(--brand-red); box-shadow: 0 0 0 3px rgba(200,16,46,0.1); }
#auth-error {
  font-size: 0.75rem; color: #dc2626; font-weight: 700;
  background: #fff5f5; padding: 8px; border-radius: 8px;
  border: 1px solid #fee2e2; margin-top: 10px;
  display: none;
}

/* ---- Preview Controls ---- */
#preview-controls {
  display: none;
  position: fixed; top: 0; left: 0; width: 100%;
  background: var(--sidebar-dark); color: #fff;
  padding: 14px 24px; justify-content: space-between; align-items: center;
  z-index: 50; border-bottom: 4px solid var(--brand-red);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.preview-icon { width: 40px; height: 40px; background: var(--brand-red); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 4px 12px var(--brand-red-glow); }

/* ---- Main Content ---- */
#app-ui { display: flex; flex-direction: column; height: 100%; }
main { flex: 1; overflow: hidden; position: relative; background: var(--bg-light); }

/* ---- Views ---- */
.view { position: absolute; inset: 0; overflow-y: auto; padding: 24px; }
.view.hidden { display: none; }

/* ---- Card ---- */
.card {
  background: #fff; border-radius: 16px; border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-ios); padding: 28px;
}
.card-sm { padding: 18px; }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #f3f4f6; padding-bottom: 12px; margin-bottom: 18px;
}
.card-title { font-size: 0.72rem; font-weight: 800; color: #374151; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---- Sticky Editor Bar ---- */
#editor-sticky-bar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
  border-radius: 14px; border: 1px solid #e5e7eb;
  padding: 14px 20px; margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

/* ---- Dashboard Table ---- */
.dashboard-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.dashboard-table thead th {
  background: #f9fafb; font-size: 10px; font-weight: 700;
  color: #9ca3af; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 14px 20px; text-align: left; border-bottom: 1px solid #f3f4f6;
}
.dashboard-table tbody tr {
  border-bottom: 1px solid #f9fafb; cursor: pointer;
  transition: background 0.15s;
}
.dashboard-table tbody tr:hover { background: #fafafa; }
.dashboard-table tbody td { padding: 14px 20px; font-size: 0.82rem; vertical-align: middle; }

/* ---- Summary Cards ---- */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-card { background: #fff; border-radius: 14px; border: 1px solid #e5e7eb; padding: 16px 20px; box-shadow: var(--shadow-ios); }
.summary-card .label { font-size: 10px; font-weight: 700; color: #9ca3af; text-transform: uppercase; margin-bottom: 6px; }
.summary-card .value { font-size: 1.4rem; font-weight: 900; color: #111; font-family: ui-monospace, monospace; }
.summary-card .sub { font-size: 10px; color: #9ca3af; margin-top: 3px; }
.summary-card.red { border-left: 4px solid var(--brand-red); }
.summary-card.blue { border-left: 4px solid #2563eb; }
.summary-card.green { border-left: 4px solid #059669; }
.summary-card.gray { border-left: 4px solid #6b7280; }

/* ---- Form Grid ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 10px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---- Section Subcard ---- */
.subcard { border-radius: 12px; padding: 16px; }
.subcard-blue { background: #eff6ff; border: 1px solid #bfdbfe; }
.subcard-green { background: #f0fdf4; border: 1px solid #bbf7d0; }
.subcard-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.subcard-blue .subcard-title { color: #1d4ed8; }
.subcard-green .subcard-title { color: #065f46; }

/* ---- Particulars / Accounts Tables ---- */
.data-table { width: 100%; }
.data-table thead th { font-size: 10px; color: #9ca3af; font-weight: 700; text-transform: uppercase; padding: 6px 8px; background: #f9fafb; }
.data-table thead th:first-child { border-radius: 6px 0 0 6px; text-align: left; }
.data-table thead th:last-child { border-radius: 0 6px 6px 0; }
.data-table tbody td { padding-bottom: 8px; padding-right: 8px; vertical-align: top; }
.data-table tfoot td { padding-top: 12px; }

/* ---- Toast ---- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #111; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 0.82rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.3s ease; max-width: 320px;
}
.toast.success { border-left: 4px solid #10b981; }
.toast.error   { border-left: 4px solid #ef4444; }
.toast.info    { border-left: 4px solid #3b82f6; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 18px; padding: 28px;
  max-width: 480px; width: 100%; box-shadow: 0 30px 80px rgba(0,0,0,0.25);
  border-top: 4px solid var(--brand-red);
}
.modal-title { font-size: 1rem; font-weight: 900; text-transform: uppercase; margin-bottom: 6px; }
.modal-sub { font-size: 0.82rem; color: #6b7280; margin-bottom: 20px; }

/* ---- Settings Panel ---- */
#settings-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 360px;
  background: #fff; box-shadow: -4px 0 30px rgba(0,0,0,0.12);
  z-index: 60; transform: translateX(100%); transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; padding: 28px;
}
#settings-panel.open { transform: translateX(0); }
.settings-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  z-index: 59; display: none;
}
.settings-backdrop.open { display: block; }

/* ---- Account Code Field ---- */
.account-code-input { width: 80px !important; font-family: ui-monospace, monospace; font-size: 11px; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { font-size: 3rem; color: #e5e7eb; margin-bottom: 14px; }
.empty-state p { font-size: 0.9rem; color: #9ca3af; font-weight: 500; }

/* ---- Voucher Status badge in table ---- */
.status-draft    { background: #fef3c7; color: #92400e; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-void     { background: #fee2e2; color: #991b1b; }
.status-pending  { background: #e0e7ff; color: #3730a3; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .view { padding: 14px; }
  .card { padding: 16px; }
  #app-header { padding: 12px 16px; }
  #settings-panel { width: 100%; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .header-title-text { font-size: 1rem; }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  @page { size: A4 portrait; margin: 8mm; }

  body {
    background: white !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    height: auto !important;
    overflow: visible !important;
  }

  #app-ui,
  #preview-controls,
  #auth-overlay,
  #toast-container,
  #settings-panel,
  .settings-backdrop { display: none !important; }

  #print-layout {
    display: block !important;
    margin: 0 !important;
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .no-print { display: none !important; }
}

/* Print layout hidden by default */
#print-layout { display: none; }

/* Print table */
.print-table th, .print-table td {
  border: 1px solid #000;
  padding: 5px 8px;
  font-size: 10.5px;
}
.print-table th {
  background-color: #f3f4f6 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  text-transform: uppercase;
  font-weight: bold;
}

/* Amount-in-words row */
.amount-words-row { background: #fffbeb !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }

/* ---- Settings items ---- */
.settings-item { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.settings-label { font-size: 11px; font-weight: 700; color: #9ca3af; text-transform: uppercase; }

/* ---- Filter Bar ---- */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filter-bar input, .filter-bar select { font-family: 'Inter', sans-serif; font-size: 0.82rem; }
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9ca3af; pointer-events: none; }
.search-wrap input { padding-left: 34px; }
