html {
  font-size: 15px;
}

body {
  font-family: "Inter", sans-serif;
  font-size: 11px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.animate-fade-in {
  animation: fadeInUp 0.4s ease-out forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

* {
  transition-property:
    background-color, border-color, color, fill, stroke, opacity, box-shadow,
    transform;
  transition-duration: 200ms;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

/* ===== Mobile UI optimizations (no logic changes) ===== */
@media (max-width: 1023px) {
  /* overall spacing */
  .container,
  .page,
  .content,
  main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* cards */
  .card,
  .panel,
  .section,
  .bg-white.rounded-xl,
  .bg-white.rounded-xl {
    border-radius: 16px !important;
  }

  /* header */
  header,
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    touch-action: none;
  }

  .topbar .right-actions,
  header .right-actions {
    gap: 8px !important;
  }

  /* add subtle shadow when on mobile */
  aside {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  }

  /* allow main content full width */
  .app-shell,
  .layout,
  .root {
    grid-template-columns: 1fr !important;
  }

  /* tables: horizontal scroll */
  .table-wrap,
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px;
  }

  th,
  td {
    white-space: nowrap;
  }

  /* forms: full width inputs, tighter spacing */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* prevent iOS zoom */
  .form-row {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .form-actions {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .form-actions > button {
    width: 100% !important;
  }

  /* modals/drawers */
  .modal,
  .dialog {
    align-items: flex-end !important;
  }

  .modal-content,
  .dialog-content {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 88vh !important;
    overflow: auto !important;
  }

  /* detail pages: stack columns */
  .grid,
  .grid-cols-3,
  .grid-cols-2,
  .lg\:grid-cols-3,
  .lg\:col-span-2 {
    grid-template-columns: 1fr !important;
  }

  /* buttons: bigger touch targets */
  button {
    min-height: 40px;
  }

  .btn,
  .button {
    min-height: 42px;
  }

  /* Reduce padding for mobile components */

  .p-6 {
    padding: 1rem !important;
  }

  .p-5 {
    padding: 1rem !important;
  }

  .px-6 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .py-6 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  .gap-6 {
    gap: 1rem !important;
  }
}

/* helper: safe horizontal scroll container */
.table-wrap {
  overflow-x: auto;
}

/* ===== Mobile Drawer Sidebar (override) ===== */
@media (max-width: 1023px) {
  /* Dynamic viewport height on mobile to prevent bottom bar cut off */
  .h-screen {
    height: 100dvh !important;
  }

  /* Smooth inertial momentum scrolling globally on mobile */
  .overflow-auto,
  .overflow-y-auto,
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch !important;
  }

  /* Treat sidebarOpen=true (w-72) as drawer open; sidebarOpen=false (w-20) as hidden */
  aside {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh !important;
    z-index: 60 !important;
    will-change: transform;
    transition: transform 0.2s ease !important;
  }

  aside nav {
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 96px !important; /* Safe padding for bottom browser bars */
  }

  /* Hidden state */
  aside.w-20 {
    transform: translateX(-110%) !important;
  }

  /* Open state */
  aside.w-72 {
    width: 82vw !important;
    max-width: 320px !important;
    transform: translateX(0) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  }

  /* Ensure sidebar items are clickable */
  aside * {
    pointer-events: auto;
  }

  /* Don't reserve left space for sidebar on mobile */
  .flex-1.flex.flex-col.overflow-hidden {
    margin-left: 0 !important;
  }
}

/* ===== Mobile backdrop for closing sidebar ===== */
.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 55;
  display: none;
}

@media (max-width: 1023px) {
  .mobile-backdrop {
    display: block;
  }
}

/* ===== Mobile notification dropdown improvements ===== */
@media (max-width: 1023px) {
  /* target the notification popup (uses absolute + bg-white + rounded-xl + shadow) */
  .notif-dropdown {
    position: fixed !important;
    top: 56px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 70vh !important;
    overflow: auto !important;
    border-radius: 16px !important;
  }

  .notif-dropdown .notif-item {
    padding: 12px !important;
  }
}

/* Mobile typography & spacing tweaks */
@media (max-width: 1023px) {
  html {
    font-size: 15px;
  }

  /* Synchronized base font size for mobile text inheritance */
  body {
    font-size: 13px !important;
  }

  /* Opt: Increase base font size for mobile readability */
  h1,
  h2,
  h3 {
    letter-spacing: -0.01em;
  }

  .notif-dropdown {
    width: 92vw !important;
  }

  table th,
  table td {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  table th {
    font-size: 10px !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .sidebar-open {
    width: 100% !important;
  }

  /* Nav items smaller on mobile */
  aside nav button {
    font-size: 13px !important;
    padding: 10px !important;
  }

  /* Hide scrollbars for horizontal scrolling areas */
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }

  .no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in-left {
  animation: slideInLeft 0.3s ease-out forwards;
}

@keyframes icwspin {
  to {
    transform: rotate(360deg);
  }
}
