/*
 * Trinity Fruits - Custom CSS
 * Bootstrap → Metronic Tailwind Compatibility Shim
 * Provides .card, .btn, .table, .row, .col-*, .modal, .pagination
 * classes using Metronic CSS custom properties so existing templates
 * and JSX components render correctly.
 */

/* ============================================================
   CARD COMPONENTS
   ============================================================ */
.card {
  background-color: var(--card, #ffffff);
  color: var(--card-foreground, #09090b);
  border-radius: 0.75rem;
  border: 1px solid var(--border, #e4e4e7);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.07);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border, #e4e4e7);
  min-height: 56px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground, #09090b);
  margin: 0;
  line-height: 1.4;
}

.card-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
  flex: 1 1 auto;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border, #e4e4e7);
}

/* ============================================================
   BUTTON COMPONENTS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  background-color: transparent;
  color: var(--foreground, #09090b);
}

.btn:focus {
  outline: 2px solid var(--ring, #a1a1aa);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--primary, #18181b);
  color: var(--primary-foreground, #fafafa);
  border-color: var(--primary, #18181b);
}

.btn-primary:hover {
  background-color: color-mix(in srgb, var(--primary, #18181b) 90%, transparent);
  color: var(--primary-foreground, #fafafa);
}

.btn-secondary {
  background-color: var(--secondary, #f4f4f5);
  color: var(--secondary-foreground, #18181b);
  border-color: var(--border, #e4e4e7);
}

.btn-secondary:hover {
  background-color: color-mix(in srgb, var(--secondary, #f4f4f5) 80%, transparent);
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-outline-secondary {
  background-color: transparent;
  color: var(--secondary-foreground, #18181b);
  border-color: var(--border, #e4e4e7);
}

.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.25rem;
  color: var(--muted-foreground, #71717a);
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.7;
}

.btn-close::before {
  content: '×';
  display: block;
  font-size: 1.5rem;
  line-height: 1;
}

.btn-close:hover {
  opacity: 1;
  color: var(--foreground, #09090b);
}

/* ============================================================
   BOOTSTRAP GRID
   ============================================================ */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -0.75rem;
  margin-left: -0.75rem;
}

.row.mb-2 { margin-bottom: 0.5rem !important; }
.row.mt-2 { margin-top: 0.5rem !important; }

[class*="col-"] {
  padding-right: 0.75rem;
  padding-left: 0.75rem;
  box-sizing: border-box;
}

.col-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
.col-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3  { flex: 0 0 25%;        max-width: 25%; }
.col-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6  { flex: 0 0 50%;        max-width: 50%; }
.col-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9  { flex: 0 0 75%;        max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%;       max-width: 100%; }

/* Small (sm) */
@media (min-width: 576px) {
  .col-sm-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
  .col-sm-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-sm-3  { flex: 0 0 25%;        max-width: 25%; }
  .col-sm-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-sm-6  { flex: 0 0 50%;        max-width: 50%; }
  .col-sm-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-sm-12 { flex: 0 0 100%;       max-width: 100%; }
}

/* Medium (md) */
@media (min-width: 768px) {
  .col-md-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-md-3  { flex: 0 0 25%;        max-width: 25%; }
  .col-md-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-md-6  { flex: 0 0 50%;        max-width: 50%; }
  .col-md-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-md-12 { flex: 0 0 100%;       max-width: 100%; }
}

/* float-end alignment helper */
.float-end { margin-left: auto; }

/* mx-auto */
.mx-auto { margin-left: auto; margin-right: auto; }

/* ============================================================
   TABLE COMPONENTS
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  color: var(--foreground, #09090b);
}

.table thead tr {
  background-color: var(--muted, #f4f4f5);
  border-bottom: 2px solid var(--border, #e4e4e7);
}

.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted-foreground, #71717a);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #e4e4e7);
  vertical-align: middle;
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: color-mix(in srgb, var(--muted, #f4f4f5) 40%, transparent);
}

.table-hover tbody tr:hover {
  background-color: var(--accent, #f4f4f5);
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground, #09090b);
  margin-bottom: 0.375rem;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground, #09090b);
  background-color: var(--background, #ffffff);
  border: 1px solid var(--input, #e4e4e7);
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: var(--ring, #a1a1aa);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring, #a1a1aa) 20%, transparent);
}

.input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground, #09090b);
  background-color: var(--background, #ffffff);
  border: 1px solid var(--input, #e4e4e7);
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }

/* Input for order quantity */
input.quantity {
  width: 80px;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  border: 1px solid var(--input, #e4e4e7);
  border-radius: 0.375rem;
  color: var(--foreground, #09090b);
  background-color: var(--background, #ffffff);
}

/* ============================================================
   BOOTSTRAP MODAL — Pure CSS + JS override
   ============================================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9000;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
  display: flex !important;
}

/* Legacy Bootstrap class: modal.fade stays hidden until .show is added */
.modal.fade {
  display: none;
}

.modal.fade.show {
  display: flex !important;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: auto;
  pointer-events: auto;
}

.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 2rem);
}

.modal-xl     { max-width: 1140px; }
.modal-lg     { max-width: 800px; }
.modal-sm     { max-width: 300px; }

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background-color: var(--card, #ffffff);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 0.75rem;
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border, #e4e4e7);
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground, #09090b);
  line-height: 1.4;
}

.modal-body {
  position: relative;
  flex: 1 1 auto;
  padding: 1.5rem;
}

.modal-body .text-center { text-align: center; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border, #e4e4e7);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  gap: 0.25rem;
  justify-content: center;
}

.page-item { display: inline-flex; }

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground, #09090b);
  background-color: var(--background, #ffffff);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 0.375rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.page-link:hover {
  background-color: var(--accent, #f4f4f5);
  color: var(--accent-foreground, #18181b);
}

.page-item.active .page-link {
  background-color: var(--primary, #18181b);
  color: var(--primary-foreground, #fafafa);
  border-color: var(--primary, #18181b);
}

/* ============================================================
   UTILITY HELPERS (used in JSX)
   ============================================================ */
.text-center  { text-align: center; }
.text-end     { text-align: right; }
.d-flex       { display: flex; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }

/* Status colours used in tables */
.text-success { color: #16a34a; }
.text-danger  { color: #dc2626; }
.text-muted   { color: var(--muted-foreground, #71717a); }

/* Alert-style boxes */
.bg-red-50   { background-color: #fef2f2; }
.text-red-600 { color: #dc2626; }
.bg-green-50  { background-color: #f0fdf4; }
.text-green-600 { color: #16a34a; }

/* Remove icon in order creation */
a.remove-icon {
  cursor: pointer;
  color: #ef4444;
  margin-left: 0.5rem;
}

a.remove-icon:hover {
  color: #dc2626;
}

/* ============================================================
   BOOTSTRAP MODAL JavaScript Polyfill
   Replaces Bootstrap's data-bs-toggle/data-bs-dismiss
   ============================================================ */

