/* Application CSS & Form Field Enhancements */

/* ========================================================
   Standard Form Controls - Unified Height, Font & Alignment
   ======================================================== */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="url"],
select:not(.border-0):not(.seamless-select) {
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important; /* slate-300 */
  border-radius: 0.5rem !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
  color: #0f172a !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  padding-top: 0.55rem !important;
  padding-bottom: 0.55rem !important;
  padding-left: 0.875rem;
  padding-right: 0.875rem;
  font-size: 0.75rem !important; /* 12px / text-xs */
  line-height: 1.25rem !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  vertical-align: middle !important;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

/* Seamless inline selects (e.g. filter bars in reports & dashboard) */
select.border-0,
select.seamless-select {
  background-color: transparent !important;
  border: 0 !important;
  border-width: 0 !important;
  border-style: none !important;
  box-shadow: none !important;
  outline: none !important;
  border-radius: 0 !important;
}

/* Ensure inputs with left icon/currency have adequate breathing room */
input.pl-7,
input.pl-8,
input[class*="pl-7"],
input[class*="pl-8"] {
  padding-left: 2.25rem !important; /* 36px clearance */
}

input.pl-9,
input.pl-10,
input[class*="pl-9"],
input[class*="pl-10"] {
  padding-left: 2.75rem !important; /* 44px clearance for 16px icon */
}

input.pl-11,
input.pl-12,
input.pl-14,
input.pl-16,
input[class*="pl-11"],
input[class*="pl-12"],
input[class*="pl-14"],
input[class*="pl-16"] {
  padding-left: 3.5rem !important; /* 56px clearance for 3-letter currency like KES */
}

/* Ensure inputs with right buttons/labels have adequate right padding */
input.pr-20,
input.pr-24,
input[class*="pr-20"],
input[class*="pr-24"] {
  padding-right: 5.5rem !important;
}

input.pr-8,
input[class*="pr-8"] {
  padding-right: 2.25rem !important;
}

textarea {
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
  color: #0f172a !important;
  padding: 0.55rem 0.875rem !important;
  font-size: 0.75rem !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input[type="text"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="date"]:hover,
input[type="search"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
select:not(.border-0):not(.seamless-select):hover,
textarea:hover {
  border-color: #94a3b8 !important; /* slate-400 */
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:not(.border-0):not(.seamless-select):focus,
textarea:focus {
  background-color: #ffffff !important;
  border-color: #f59e0b !important; /* amber-500 */
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22) !important;
  outline: none !important;
}

input:disabled,
select:not(.border-0):not(.seamless-select):disabled,
textarea:disabled {
  background-color: #f1f5f9 !important; /* slate-100 */
  border-color: #e2e8f0 !important;
  color: #94a3b8 !important;
  cursor: not-allowed;
}

/* ========================================================
   TomSelect Searchable Dropdowns - Pixel-Perfect Alignment
   ======================================================== */

/* 1. Neutralize original select so it takes ZERO space in document flow */
select.tomselected,
select.ts-hidden-accessible {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  outline: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* 2. TomSelect outer wrapper matches regular form field block flow */
.ts-wrapper {
  position: relative !important;
  width: 100% !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  vertical-align: middle !important;
  box-sizing: border-box !important;
}

/* 3. The visible control box - identical to input fields */
.ts-wrapper.single .ts-control,
.ts-control {
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
  color: #0f172a !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  box-sizing: border-box !important;
  padding: 0.55rem 2rem 0.55rem 0.875rem !important; /* matches input padding left/top/bottom, 2rem right for arrow */
  margin: 0 !important;
  font-size: 0.75rem !important; /* 12px / text-xs */
  line-height: 1.25rem !important; /* 20px */
  font-weight: 500 !important;
  display: flex !important;
  align-items: center !important;
  cursor: pointer !important;
  overflow: hidden !important;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

.ts-wrapper.single .ts-control:hover,
.ts-control:hover {
  border-color: #94a3b8 !important;
}

.ts-wrapper.focus .ts-control,
.ts-wrapper.input-active .ts-control {
  border-color: #f59e0b !important; /* amber-500 */
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22) !important;
  outline: none !important;
}

/* 4. Reset anything inside .ts-control so it doesn't add padding or extra boxes */
.ts-control input,
.ts-control .items-placeholder,
.ts-wrapper .ts-control input {
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  outline: none !important;
  font-size: 0.75rem !important;
  line-height: 1.25rem !important;
  color: #0f172a !important;
  width: auto !important;
  flex: 1 1 auto !important;
  box-sizing: border-box !important;
}

.ts-control input::placeholder,
.ts-control .items-placeholder::placeholder,
.ts-wrapper .ts-control input::placeholder {
  color: #94a3b8 !important; /* slate-400 */
}

.ts-control .item,
.ts-wrapper.single .ts-control .item {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  color: #0f172a !important;
  font-size: 0.75rem !important;
  line-height: 1.25rem !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: inline-block !important;
  flex: 1 1 auto !important;
  box-sizing: border-box !important;
}

/* 5. Down chevron arrow perfectly vertically centered */
.ts-wrapper.single .ts-control::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  top: 50% !important;
  right: 12px !important;
  transform: translateY(-50%) !important;
  margin-top: 0 !important;
  width: 0 !important;
  height: 0 !important;
  border-style: solid !important;
  border-width: 5px 4px 0 4px !important;
  border-color: #64748b transparent transparent transparent !important;
  pointer-events: none !important;
}

.ts-wrapper.single.dropdown-active .ts-control::after {
  border-width: 0 4px 5px 4px !important;
  border-color: transparent transparent #64748b transparent !important;
}

/* 6. Dropdown menu */
.ts-dropdown {
  background: #ffffff !important;
  border: 1.5px solid #e2e8f0 !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08) !important;
  margin-top: 4px !important;
  padding: 4px !important;
  z-index: 1000 !important;
  font-size: 0.75rem !important;
  box-sizing: border-box !important;
}

.ts-dropdown .dropdown-input-wrap {
  padding: 4px 4px 6px 4px !important;
}

.ts-dropdown .dropdown-input-wrap input.dropdown-input {
  width: 100% !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  background-color: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.375rem !important;
  padding: 0.4rem 0.65rem !important;
  font-size: 0.75rem !important;
  color: #0f172a !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04) !important;
  box-sizing: border-box !important;
}

.ts-dropdown .dropdown-input-wrap input.dropdown-input:focus {
  border-color: #f59e0b !important;
  background-color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2) !important;
  outline: none !important;
}

.ts-dropdown .option {
  padding: 0.5rem 0.75rem !important;
  border-radius: 0.375rem !important;
  color: #1e293b !important;
  cursor: pointer !important;
  transition: background-color 0.1s ease, color 0.1s ease !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background-color: #fef3c7 !important; /* amber-100 */
  color: #92400e !important; /* amber-800 */
  font-weight: 600 !important;
}

.ts-dropdown .option.selected {
  background-color: #fde68a !important; /* amber-200 */
  color: #78350f !important;
  font-weight: 700 !important;
}

.ts-dropdown .no-results {
  padding: 0.75rem !important;
  color: #94a3b8 !important;
  font-size: 0.75rem !important;
  text-align: center !important;
}

/* ========================================================
   Dialog & Modal Placement - Unified & Centered
   ======================================================== */
dialog {
  position: fixed !important;
  inset: 0 !important;
  margin: auto !important;
  border: 1px solid #e2e8f0 !important; /* slate-200 */
  border-radius: 1rem !important;
  padding: 0 !important;
  background-color: #ffffff !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
  max-height: calc(100dvh - 3.5rem) !important;
  width: calc(100% - 2rem) !important;
  max-width: 32rem !important; /* Default bounded modal width (512px / max-w-lg) */
  overflow: auto !important;
  z-index: 1000 !important;
}

/* Modal max-width size tiers across the whole app */
dialog.max-w-xs, dialog[class*="max-w-xs"] { max-width: 20rem !important; }
dialog.max-w-sm, dialog[class*="max-w-sm"] { max-width: 24rem !important; }
dialog.max-w-md, dialog[class*="max-w-md"] { max-width: 28rem !important; }
dialog.max-w-lg, dialog[class*="max-w-lg"] { max-width: 32rem !important; }
dialog.max-w-xl, dialog[class*="max-w-xl"] { max-width: 36rem !important; }
dialog.max-w-2xl, dialog[class*="max-w-2xl"] { max-width: 42rem !important; }

dialog:not([open]) {
  display: none !important;
}

dialog[open] {
  display: flex !important;
  flex-direction: column !important;
  animation: modal-fade-in 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.65) !important; /* slate-900 / 65% */
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ========================================================
   Kasoko Dashboard Components & Visual Look-and-Feel
   ======================================================== */
.modern-box {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid #f1f5f9;
  margin-bottom: 20px;
  padding: 22px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.modern-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.07);
}

.modern-box-kasoko {
  border: 1px solid #ebb598 !important;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.stat-title {
  font-size: 12px;
  color: #8898aa;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.08);
}

.icon-blue {
  background: #eef6fc;
  color: #2196f3;
}

.icon-green {
  background: #e8f5e9;
  color: #4caf50;
}

.icon-yellow {
  background: #fff8e1;
  color: #ffc107;
}

.icon-red {
  background: #ffebee;
  color: #f44336;
}

.icon-orange {
  background: #fff3e0;
  color: #E67436;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: #32325d;
  margin-top: 6px;
  margin-bottom: 4px;
  line-height: 1.2;
}

.stat-footer {
  font-size: 12px;
  color: #8898aa;
  margin-top: 6px;
  font-weight: 500;
}

.stat-change {
  font-weight: 700;
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
}

.stat-change.up {
  color: #2dce89;
}

.stat-change.down {
  color: #f5365c;
}

.modern-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.modern-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #32325d;
}

.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.modern-table th {
  background: rgba(230, 116, 54, 0.05);
  color: #E67436;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  padding: 10px 14px;
  letter-spacing: 0.5px;
}

.modern-table td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  color: #525f7f;
  font-size: 13px;
}

.modern-table tr:hover td {
  background: #fbfcfe;
}

.badge-soft {
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 11px;
  display: inline-block;
}

.badge-soft-success {
  background: #b0eed3;
  color: #1aae6f;
}

.badge-soft-warning {
  background: #fdd1da;
  color: #f80031;
}

.badge-soft-primary {
  background: #d6e4ff;
  color: #2c66ff;
}

/* ========================================================
   Kasoko Page Boxes for Forms & Tables (Scrollable body)
   ======================================================== */
.box-kasoko-page {
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  flex: 1 1 0%;
  overflow: hidden;
}

.box-kasoko-page > .box-header,
.box-kasoko-page .box-header {
  padding: 14px 22px;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(248, 250, 252, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

.box-kasoko-page > form {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.box-kasoko-page > .box-body,
.box-kasoko-page .box-body {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 22px;
}

.box-kasoko-page > .box-footer,
.box-kasoko-page .box-footer {
  padding: 12px 22px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Kasoko Button Styles */
.btn-kasoko {
  background-color: #E67436 !important;
  color: #ffffff !important;
  border: 1px solid #E67436 !important;
  font-weight: 700;
  border-radius: 10px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-kasoko:hover {
  background-color: #d56327 !important;
  border-color: #d56327 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 116, 54, 0.25);
}

.btn-kasoko:active {
  transform: translateY(0);
}

.btn-kasoko-outline {
  background-color: #ffffff !important;
  color: #E67436 !important;
  border: 1px solid #E67436 !important;
  font-weight: 700;
  border-radius: 10px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-kasoko-outline:hover {
  background-color: #E67436 !important;
  color: #ffffff !important;
}

.btn-kasoko-secondary {
  background-color: #ffffff !important;
  color: #334155 !important;
  border: 1px solid #cbd5e1 !important;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-kasoko-secondary:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* Kasoko Custom Smooth Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(230, 116, 54, 0.45);
}

/* ========================================================
   Print Media Styles & Professional Document Resets
   ======================================================== */
@media print {
  @page {
    size: auto;
    margin: 10mm 12mm;
  }

  /* Reset document and viewport clipping so full multi-page prints work */
  html, body {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
    font-size: 10pt !important;
    line-height: 1.35 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  main {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Hide all web chrome, sidebars, navbars, and interactive buttons */
  header,
  nav,
  aside,
  footer,
  dialog,
  button,
  .no-print,
  .print\:hidden,
  .action-bar,
  #mobile-dir-menu,
  [data-controller="dropdown"] {
    display: none !important;
  }

  /* Container and card resets */
  .print-document,
  .print-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* Avoid awkward page splits inside cards, tables, rows, and signatures */
  .page-break-avoid,
  .print-avoid-break,
  .print-card,
  .ticket-card,
  table,
  tr,
  .signature-block {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* Ensure text colors are legible in grayscale / print */
  a {
    text-decoration: none !important;
    color: inherit !important;
  }

  /* Remove heavy box shadows and interactive focus rings */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }
}
