/* ==========================================================================
   LT Fault Record - Stylesheet (v2)
   Font: Nunito Sans
   Unified Table Styling, Dark Mode Support, Animations, and PWA Responsiveness
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap');

:root {
  --font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  width: 100%;
  min-width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

body {
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Nav header container styling - spans 100% of viewport edge-to-edge */
header {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Smooth mobile table scrolling without capturing vertical page scroll */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: auto;
  overscroll-behavior-y: auto !important;
  scrollbar-width: thin;
}

/* Ensure mouse wheel scrolling vertically over any table chains smoothly to window */
table, .overflow-x-auto, div[class*="overflow-x-auto"] {
  overscroll-behavior-y: auto !important;
}
.overflow-x-auto::-webkit-scrollbar {
  height: 4px;
}
.overflow-x-auto::-webkit-scrollbar-track {
  background: transparent;
}
.overflow-x-auto::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.dark .overflow-x-auto::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Prevent auto-zoom and responsive touch targets */
input, select, textarea, button {
  touch-action: manipulation;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Tab Transitions & Animations */
.tab-content {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.tab-content.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: tabFadeSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}
@keyframes tabFadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Nav items smooth transition */
.nav-btn {
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Card and interactive element transitions */
.record-row {
  transition: background-color 0.12s ease;
}

/* Accordion Details Row Transition */
.detail-transition-container {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: grid-template-rows;
}
.detail-transition-container.open {
  grid-template-rows: 1fr;
}
.detail-transition-content {
  overflow: hidden;
  min-height: 0;
}

/* Buttons & Touch Bounces */
button, .btn-bounce {
  transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1), filter 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 38px;
}
button:active, .btn-bounce:active {
  transform: scale(0.97);
}

/* Card, panel and chip smooth transitions */
.kpi-card, .dashboard-card, .approval-item {
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease, border-color 0.15s ease;
}

.filter-chip {
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

/* UNIFIED TABLE STYLING:
   Zone Performance Summary & DLP vs Road Layout Matrix have matching sizing,
   font sizes, and cell padding for visual harmony. */
#dashboard-zone-tbody tr td,
#dashboard-dlp-tbody tr td,
#dashboard-monthly-matrix-tbody tr td,
#dashboard-monthly-carryfwd-tbody tr td {
  padding: 0.75rem 0.65rem;
  font-size: 0.8125rem; /* 13px */
  line-height: 1.25rem;
}

/* Ensure all dashboard summary tables have perfectly centered and middle-aligned numerical cells */
#dashboard-zone-tbody td,
#dashboard-zone-tbody th,
#dashboard-dlp-tbody td,
#dashboard-dlp-tbody th,
#dashboard-monthly-matrix-tbody td,
#dashboard-monthly-matrix-tbody th,
#dashboard-monthly-carryfwd-tbody td,
#dashboard-monthly-carryfwd-tbody th {
  vertical-align: middle !important;
}

#dashboard-zone-tbody tr td:not(:first-child),
#dashboard-dlp-tbody tr td:not(:first-child),
#dashboard-monthly-matrix-tbody tr td:not(:first-child),
#dashboard-monthly-carryfwd-tbody tr td:not(.text-left):not(:nth-child(2)) {
  text-align: center !important;
  vertical-align: middle !important;
}

#dashboard-zone-tbody tr td a,
#dashboard-zone-tbody tr td span,
#dashboard-dlp-tbody tr td span,
#dashboard-monthly-matrix-tbody tr td span,
#dashboard-monthly-carryfwd-tbody tr td span {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
}

#dashboard-zone-tbody tr,
#dashboard-dlp-tbody tr {
  height: 44px;
}

/* VIEW DATA MASTER TABLE BOX ALIGNMENT & COMPACT STYLING (V1 PARITY):
   Neat box borders, compact padding, sharp text alignment, and prevents unwanted horizontal scrolling on standard columns */
#tab-view-data table {
  border-collapse: collapse !important;
  width: 100%;
}

#records-thead-tr th {
  border: 1px solid #e2e8f0 !important;
  padding: 0.45rem 0.65rem !important;
  font-size: 0.6875rem !important; /* 11px */
  text-align: left;
  background-color: #f8fafc;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.dark #records-thead-tr th {
  border-color: #334155 !important;
  background-color: rgba(30, 41, 59, 0.7);
}

#records-tbody tr.record-row td,
#records-tbody tr td {
  border: 1px solid #e2e8f0 !important;
  padding: 0.4rem 0.65rem !important;
  font-size: 0.75rem !important; /* 12px */
  line-height: 1.15rem;
  vertical-align: middle;
}

.dark #records-tbody tr.record-row td,
.dark #records-tbody tr td {
  border-color: #334155 !important;
}

#records-tbody tr[id^="detail-row-"] td {
  border: none !important;
  padding: 0 !important;
}

/* Shimmer Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.dark .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Floating AI Chatbot elements */
#chat-bubble {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  border-radius: 9999px;
  box-shadow: 0 10px 25px -5px rgba(29, 78, 216, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  z-index: 40;
  transition: transform 0.2s, box-shadow 0.2s;
}
@media (max-width: 640px) {
  #chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
  }
}
#chat-bubble:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 28px -4px rgba(29, 78, 216, 0.6);
}
#chat-bubble:active {
  transform: scale(0.95);
}
#chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 800;
  border-radius: 9999px;
  padding: 2px 6px;
  display: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#chat-overlay {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: calc(100vh - 100px);
  border-radius: 1.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  z-index: 50;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0);
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  opacity: 0;
  pointer-events: none;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
}
.dark #chat-overlay {
  background-color: rgba(15, 23, 42, 0.85);
  border-color: rgba(51, 65, 85, 0.8);
}
#chat-overlay.active {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* High Contrast Suggestion Buttons for Chatbot */
.welcome-suggestion-card {
  display: block;
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.55rem 0.75rem;
  margin-top: 0.375rem;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.welcome-suggestion-card:hover {
  background: #eff6ff;
  border-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.18);
}
.welcome-suggestion-card:active {
  transform: translateY(0);
  background: #dbeafe;
}
.welcome-suggestion-card strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1d4ed8;
  line-height: 1.25;
}
.welcome-suggestion-card .desc {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  color: #334155;
  margin-top: 0.15rem;
  line-height: 1.2;
}
.dark .welcome-suggestion-card {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.dark .welcome-suggestion-card:hover {
  background: #0f172a;
  border-color: #60a5fa;
  box-shadow: 0 4px 6px -1px rgba(96, 165, 250, 0.25);
}
.dark .welcome-suggestion-card strong {
  color: #93c5fd;
}
.dark .welcome-suggestion-card .desc {
  color: #cbd5e1;
}

/* Chart Lightbox Modal Overlay */
#chart-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#chart-modal.active {
  display: flex !important;
}

/* Online Pulse Indicator */
.online-pulse {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #22c55e;
  margin-left: 6px;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Multi-select filter panel */
.multi-select-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 40;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
}
.dark .multi-select-panel {
  background: #0f172a;
  border-color: #334155;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #chat-overlay {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    display: none !important;
  }
  #chat-overlay.active {
    display: flex !important;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Smooth Hardware-Accelerated Modal Transitions & Backdrop Blur */
.modal-backdrop-smooth {
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  background-color: rgba(15, 23, 42, 0.65) !important;
}

.modal-dialog-smooth {
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  will-change: transform, opacity;
}

/* Pulsing Notification Bell Badge */
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); box-shadow: 0 0 8px rgba(239, 68, 68, 0.8); }
}

.badge-has-unread {
  animation: badge-pulse 2s infinite ease-in-out;
}

/* Smooth Card Hover & Micro-Interactions */
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.1);
}
.dark .kpi-card:hover {
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.4);
}

/* Mobile Responsiveness & Touch Ergonomics */
@media (max-width: 640px) {
  input[type="text"], input[type="date"], select, textarea {
    min-height: 42px !important;
    font-size: 14px !important; /* Prevents auto-zoom on iOS Safari */
  }
  .modal-dialog-smooth {
    width: 96vw !important;
    max-width: 96vw !important;
    margin: 8px auto !important;
    max-height: 90vh !important;
  }
  .overflow-x-auto {
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* Token Search Bar Styling & Dropdown Scrollbars */
#filter-drawer-content.expanded-visible {
  overflow: visible !important;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  border-width: 1px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

#filter-fields-dropdown::-webkit-scrollbar,
#filter-values-popover .popover-list::-webkit-scrollbar {
  width: 4px;
}
#filter-fields-dropdown::-webkit-scrollbar-thumb,
#filter-values-popover .popover-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}
.dark #filter-fields-dropdown::-webkit-scrollbar-thumb,
.dark #filter-values-popover .popover-list::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Columns Checklist Popover */
#columns-checklist-panel:not(.hidden) {
  display: block !important;
}

