/* Examina LMS – app.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Hard-stop horizontal scroll at root level (clip does not break position:fixed, unlike hidden) */
html { overflow-x: clip; }
body { width: 100%; max-width: 100%; }

/* Base font — Inter is optimised for screen readability at all sizes */
body, button, input, select, textarea {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Flex layout: prevent flex children from overflowing their container (needed for tables) */
main, .flex-1 { min-width: 0; }

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: #1565C0;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-primary:hover { background: #0D47A1; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: #fff;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid #D1D5DB;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #F9FAFB; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: #DC2626;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-danger:hover { background: #B91C1C; }

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  border-radius: 0.375rem;
}

/* Cards */
.card {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid #E5E7EB;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden; /* contain table overflow properly */
}

/* Allow autocomplete dropdowns to extend outside card (e.g. facility picker on test request) */
.card.overflow-visible,
.card-body.overflow-visible {
  overflow: visible !important;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 1.25rem; }

/* Form inputs */
.form-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #D1D5DB;
  border-radius: 0.5rem;
  background: #fff;
  color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: #1565C0;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #D1D5DB;
  border-radius: 0.5rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") no-repeat right 0.5rem center/1rem;
  appearance: none;
  box-sizing: border-box;
  color: #111827;
}
.form-select:focus {
  outline: none;
  border-color: #1565C0;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.form-textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #D1D5DB;
  border-radius: 0.5rem;
  background: #fff;
  color: #111827;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
}
.form-textarea:focus {
  outline: none;
  border-color: #1565C0;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7280;
  background: #F9FAFB;
  border-bottom: 1px solid #E5E7EB;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #F3F4F6;
  color: #374151;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #F9FAFB; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Stat cards */
.stat-card {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid #E5E7EB;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
a.stat-card {
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  cursor: pointer;
}
a.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
  border-color: #BFDBFE;
}

/* Print styles */
@media print {
  @page { size: A4; margin: 8mm 12mm 8mm; }

  nav, aside, header, .no-print { display: none !important; }
  main { margin: 0 !important; padding: 0 !important; }
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 8pt !important;
    font-family: Arial, Helvetica, sans-serif !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 2-column print grid: main content (left) + invoice (right) */
  .print-form {
    display: grid !important;
    grid-template-columns: 1.85fr 1fr !important;
    gap: 7pt !important;
    align-items: start !important;
  }
  .print-invoice { display: block !important; }

  /* Cards — flat, tight */
  .card {
    border-radius: 2px !important;
    box-shadow: none !important;
    border: 0.5pt solid #b0b0b0 !important;
    break-inside: avoid;
  }
  .card-body  { padding: 4pt 6pt !important; }
  .card-header{ padding: 3pt 6pt !important; }
  .p-4        { padding: 3pt 6pt !important; }

  /* Spacing */
  .space-y-5 > * + * { margin-top: 4pt !important; }
  .gap-5  { gap: 4pt !important; }
  .gap-4  { gap: 3pt !important; }
  .mb-4, .mb-5, .mb-6 { margin-bottom: 3pt !important; }
  .mt-3, .mt-4         { margin-top: 2pt !important; }
  .mt-1, .mt-0\.5      { margin-top: 1pt !important; }
  .pt-4 { padding-top: 3pt !important; }
  .border-t { border-top: 0.3pt solid #ccc !important; }

  /* Typography */
  h3 { font-size: 8.5pt !important; margin-bottom: 2pt !important; }
  .text-xl  { font-size: 10pt !important; }
  .text-lg  { font-size: 9pt  !important; }
  .text-sm  { font-size: 7.5pt !important; }
  .text-xs  { font-size: 7pt !important; }
  .font-mono{ font-family: 'Courier New', monospace !important; font-size: 7.5pt !important; }

  /* Status / info bar — compact flex */
  .flex-wrap.gap-4 { gap: 6pt !important; }

  /* Test rows */
  .divide-y > div { padding: 3pt 5pt !important; }
  .divide-y > div + div { border-top: 0.3pt solid #ddd !important; }

  /* Strip heavy backgrounds */
  .bg-gray-50, .bg-gray-100 { background: #f9f9f9 !important; }
  .bg-blue-50, .bg-green-50, .bg-amber-50 { background: #fff !important; }

  /* Invoice bottom padding */\n  .print-invoice .px-4.pb-4 { padding: 3pt 6pt !important; }\n  .space-y-4 > * + * { margin-top: 3pt !important; }\n  .space-y-2 > * + * { margin-top: 2pt !important; }\n\n  /* Print header */
  .print-header { margin-bottom: 5pt !important; }
  .print-header img { height: 30pt !important; }
}

/* ── Mobile: responsive improvements (medium phones ~360px–480px) ─────── */
@media (max-width: 768px) {

  /* ── Stat cards: compact padding on phones so 2-col grid never overflows ── */
  .stat-card {
    padding: 0.875rem 0.75rem;
    gap: 0.625rem;
  }
  .stat-card .text-2xl { font-size: 1.35rem; }
  .stat-card .text-xl  { font-size: 1.15rem; }
  /* Icon box sizing: ONLY apply fixed size when stat-card has an icon child
     (icon boxes use rounded-xl + flex + items-center — target via :has or
     just scope to stat-cards that have exactly 2 children via the icon class) */
  .stat-card > .rounded-xl:first-child,
  .stat-card > div.flex:first-child.items-center { width: 2.25rem; height: 2.25rem; min-width: 2.25rem; }

  /* ── Tables: horizontal scroll inside cards ── */
  .overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table { min-width: 480px; }

  /* ── Prevent iOS zoom on form focus ── */
  .form-input, .form-select, .form-textarea,
  .form-input-reg, .form-select-reg { font-size: 16px !important; }

  /* ── Toast: full width on small screens ── */
  #toastContainer {
    right: 0.75rem !important;
    left: 0.75rem !important;
    width: auto !important;
  }

  /* ── Sidebar overlay ── */
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 39;
    backdrop-filter: blur(1px);
  }
  #sidebar-overlay.active { display: block; }

  /* ── Card header: wrap on small screens ── */
  .card-header { flex-wrap: wrap; gap: 0.5rem; }
  .card-header .btn-primary,
  .card-header .btn-secondary { font-size: 0.75rem; padding: 0.375rem 0.625rem; }
}
