/* Mobile-First Responsive Styles for THDS */

/* Base mobile styles (apply to all screens) */
body {
  font-size: 14px;
  overflow-x: hidden;
  padding-bottom: 50px !important;
}

/* Container adjustments for mobile */
.container-xxl,
.container-xl,
.container-fluid {
  padding-left: 8px !important;
  padding-right: 8px !important;
}

/* Responsive tables - mobile first */
.table-responsive {
  display: block !important;
  width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  margin: 0 auto !important;
}

/* Ensure all tables have horizontal scrolling on mobile */
@media (max-width: 767px) {
  table,
  .table,
  [class*="table"] {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
  }
  
  /* Wrap table in scrollable container if not already */
  .card-body > table:not(.table-responsive table),
  .kt-card-body > table:not(.table-responsive table) {
    display: block !important;
    overflow-x: auto !important;
    max-width: 100% !important;
  }
}

/* Table base styles for mobile - evenly spaced columns with reduced row height */
.table {
  font-size: 11px !important;
  min-width: 100% !important;
  table-layout: fixed !important;
  width: 100% !important;
}

.table td,
.table th {
  padding: 4px 3px !important;
  font-size: 10px !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
  line-height: 1.2 !important;
  height: auto !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Compact row height */
.table tr {
  height: 28px !important;
}

.table-row-slim {
  height: 28px !important;
}

/* Even spacing for columns */
.table-cell-slim {
  width: auto !important;
  max-width: none !important;
  word-break: normal !important;
  white-space: nowrap !important;
}

/* Make table headers sticky on scroll for better UX */
.table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #ffccff !important;
  padding: 5px 3px !important;
}

/* Card adjustments */
.card {
  margin-bottom: 10px !important;
}

.card-body {
  padding: 8px !important;
}

/* Form controls for mobile */
.form-select,
.form-control,
.btn {
  font-size: 13px !important;
  padding: 6px 10px !important;
}

/* Reduce title sizes on mobile */
h1, .h1 {
  font-size: 1.75rem !important;
}

h2, .h2 {
  font-size: 1.2rem !important;
}

h3, .h3 {
  font-size: 1.05rem !important;
}

h4, .h4 {
  font-size: 0.95rem !important;
}

/* Dashboard table specific mobile styles - more compact */
.table-title td {
  padding: 6px 3px !important;
  font-size: 0.95rem !important;
  line-height: 1.1 !important;
}

.table-title p {
  margin-bottom: 2px !important;
  line-height: 1.1 !important;
}

.table-cell-slim {
  max-width: 100px !important;
  word-break: break-word !important;
  white-space: normal !important;
  font-size: 10px !important;
}

/* Alert cells - ensure visibility on mobile */
.red-alert-cell,
.yellow-alert-cell,
.orange-alert-cell,
.tqi-alert-cell {
  font-size: 10px !important;
  padding: 3px 2px !important;
}

/* HQ table mobile optimization */
.table-hq {
  width: 100% !important;
  max-width: 100% !important;
  font-size: 10px !important;
}

.table-hq td,
.table-hq th {
  padding: 3px 2px !important;
  font-size: 13px !important;
}

/* Ticker adjustments for mobile - FIXED AT BOTTOM (only for layout ticker) */
.ticker-container {
  font-size: 11px !important;
  padding: 6px 8px !important;
  display: block !important;
  overflow: hidden !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 1000 !important;
  background-color: #fff7e6 !important;
  border-top: 2px solid #ffe0b2 !important;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1) !important;
  margin: 0 !important;
}

/* Table ticker - NOT sticky, appears after the table */
#table-ticker {
  font-size: 11px !important;
  padding: 6px 8px !important;
  display: block !important;
  overflow: hidden !important;
  position: relative !important;
  width: 100% !important;
  background-color: #fff7e6 !important;
  border: 1px solid #ffe0b2 !important;
  margin: 10px 0 !important;
}

/* Add padding to body to prevent content from being hidden behind fixed ticker */
body {
  padding-bottom: 50px !important;
}

.wrapper {
  padding-bottom: 50px !important;
}

.ticker-wrapper {
  display: flex !important;
  width: 100% !important;
}

.ticker-content {
  display: inline-block !important;
  white-space: nowrap !important;
  animation: ticker-scroll 30s linear infinite !important;
}

.ticker-text,
#tableTickerText {
  font-size: 11px !important;
  display: inline-block !important;
  line-height: 1.3 !important;
}

@keyframes ticker-scroll {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Header adjustments - maintain original sizing on mobile */
.header {
  padding: 0 !important;
  height: 80px !important;
  max-height: 80px !important;
}

.header-top {
  height: 80px !important;
  max-height: 80px !important;
  min-height: 80px !important;
  align-items: center !important;
  padding: 0 !important;
}

.header-top .d-flex {
  align-items: center !important;
}

/* Logo sizing for mobile - keep reasonable size */
.h-90px {
  height: 70px !important;
  max-height: 70px !important;
}

/* Hide logo on mobile view */
@media (max-width: 767px) {
  .header .flex.items-center.gap-2\.5 a img,
  .header img[src*="logo"] {
    display: none !important;
  }
}

/* Ensure buttons and other header elements don't expand the header */
.header .btn,
.header .btn-icon {
  margin: 0 !important;
}

/* Touch-friendly button sizes */
.header .btn-icon {
  min-width: 44px !important;
  min-height: 44px !important;
  width: 44px !important;
  height: 44px !important;
}

/* Button groups */
.btn-group {
  flex-wrap: wrap !important;
}

.btn-sm {
  font-size: 12px !important;
  padding: 6px 10px !important;
}

/* Dropdowns on mobile */
.dropdown-menu {
  font-size: 14px !important;
  max-width: 90vw !important;
}

/* Alert boxes */
.alert {
  font-size: 13px !important;
  padding: 10px !important;
}

/* Toolbar mobile optimization */
.toolbar {
  padding: 8px 0 !important;
}

/* Grid spacing reduction for mobile */
.row {
  margin-left: -4px !important;
  margin-right: -4px !important;
}

.row > * {
  padding-left: 4px !important;
  padding-right: 4px !important;
}

/* Column stacking for forms on mobile */
.col-md-2,
.col-md-3,
.col-md-4,
.col-md-6 {
  width: 100% !important;
  margin-bottom: 8px !important;
}

/* Side menu mobile optimization */
.side-menu {
  width: 250px !important;
}

.side-menu-close {
  display: block !important;
}

/* Content padding for mobile */
#kt_content_container {
  padding: 8px 4px !important;
}

.content {
  padding: 4px !important;
}

/* Ensure wrapper has space for fixed ticker */
.wrapper {
  padding-bottom: 50px !important;
}

/* Ensure images are responsive */
img {
  max-width: 100% !important;
  height: auto !important;
}

/* Scrollbar styling for mobile webkit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Tablet and above (768px+) */
@media (min-width: 768px) {
  body {
    font-size: 15px;
    padding-bottom: 60px !important;
  }

  .table {
    font-size: 12px !important;
  }

  .table td,
  .table th {
    padding: 2px 4px !important;
    font-size: 12px !important;
    height: auto !important;
  }

  .table tr {
    height: 32px !important;
  }

  .table-row-slim {
    height: 32px !important;
  }

  .container-xxl,
  .container-xl,
  .container-fluid {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #kt_content_container {
    padding: 12px 8px !important;
  }

  .content {
    padding: 6px !important;
  }

  .row {
    margin-left: -6px !important;
    margin-right: -6px !important;
  }

  .row > * {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }

  .col-md-2 {
    width: 16.666667% !important;
    margin-bottom: 0 !important;
  }

  .col-md-3 {
    width: 25% !important;
    margin-bottom: 0 !important;
  }

  .col-md-4 {
    width: 33.333333% !important;
    margin-bottom: 0 !important;
  }

  .col-md-6 {
    width: 50% !important;
    margin-bottom: 0 !important;
  }

  .table-title td {
    font-size: 1.2rem !important;
    padding: 8px 5px !important;
  }

  .table-cell-slim {
    max-width: 120px !important;
    font-size: 12px !important;
  }

  .h-90px {
    height: 70px !important;
    max-height: 70px !important;
  }

  .card-body {
    padding: 12px !important;
  }

  .ticker-container,
  .ticker-text {
    font-size: 13px !important;
    /* padding: 8px 10px !important; */
  }
  
  #table-ticker,
  #tableTickerText {
    font-size: 13px !important;
    padding: 8px 10px !important;
  }
  
  .wrapper {
    padding-bottom: 60px !important;
  }
  
  .header {
    height: 80px !important;
    max-height: 80px !important;
  }
  
  .header-top {
    height: 80px !important;
    max-height: 80px !important;
    min-height: 80px !important;
  }
}

/* Desktop (992px+) */
@media (min-width: 992px) {
  body {
    font-size: 16px;
    padding-bottom: 70px !important;
  }

  .table {
    font-size: 13px !important;
  }

  .table td,
  .table th {
    padding: 2px 4px !important;
    font-size: 13px !important;
    height: auto !important;
  }

  .table tr {
    height: 28px !important;
  }

  .table-row-slim {
    height: 28px !important;
  }

  .table-title td {
    font-size: 1.4rem !important;
    padding: 10px 6px !important;
  }

  .table-cell-slim {
    max-width: 150px !important;
    font-size: 13px !important;
  }

  .h-90px {
    height: 70px !important;
    max-height: 70px !important;
  }

  .container-xxl,
  .container-xl,
  .container-fluid {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  #kt_content_container {
    padding: 16px 12px !important;
  }

  .content {
    padding: 8px !important;
  }

  .row {
    margin-left: -8px !important;
    margin-right: -8px !important;
  }

  .row > * {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .card-body {
    padding: 16px !important;
  }

  .ticker-container,
  .ticker-text {
    font-size: 14px !important;
    /* padding: 10px 12px !important; */
  }
  
  #table-ticker,
  #tableTickerText {
    font-size: 14px !important;
    padding: 10px 12px !important;
  }

  .wrapper {
    padding-bottom: 70px !important;
  }
  
  .header {
    height: 80px !important;
    max-height: 80px !important;
  }
  
  .header-top {
    height: 80px !important;
    max-height: 80px !important;
    min-height: 80px !important;
  }

  .header-fixed.header-extended .wrapper {
    padding-top: 80px;
  }
}

/* Large desktop (1200px+) */
@media (min-width: 1200px) {
  .table-hq {
    width: 50% !important;
    max-width: 800px !important;
  }

  .table-cell-slim {
    max-width: 180px !important;
    font-size: 13px !important;
  }

  .container-xxl,
  .container-xl,
  .container-fluid {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  #kt_content_container {
    padding: 20px 16px !important;
  }

  .content {
    padding: 10px !important;
  }
}

/* Extra large desktop (1400px+) */
@media (min-width: 1400px) {
  .container-xxl {
    max-width: 1320px !important;
  }

  .table-cell-slim {
    max-width: 220px !important;
  }
}

/* Landscape mobile specific adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    padding-bottom: 45px !important;
  }

  .wrapper {
    padding-bottom: 45px !important;
  }

  .header {
    height: 60px !important;
    max-height: 60px !important;
  }
  
  .header-top {
    height: 60px !important;
    max-height: 60px !important;
    min-height: 60px !important;
  }

  .h-90px {
    height: 50px !important;
    max-height: 50px !important;
  }

  .table td,
  .table th {
    padding: 2px 2px !important;
    font-size: 9px !important;
  }

  .table tr {
    height: 24px !important;
  }

  .ticker-container {
    padding: 4px 6px !important;
    font-size: 10px !important;
  }
  
  #table-ticker {
    padding: 4px 6px !important;
    font-size: 10px !important;
  }
}

/* Print styles */
@media print {
  .side-menu,
  .header,
  .toolbar,
  .ticker-container,
  #table-ticker,
  .btn,
  .alert {
    display: none !important;
  }

  body {
    padding-bottom: 0 !important;
  }

  .wrapper {
    padding-bottom: 0 !important;
  }

  .table {
    font-size: 9px !important;
  }

  .table td,
  .table th {
    padding: 2px !important;
    font-size: 9px !important;
  }
}

/* Utility classes for mobile */
.mobile-hide {
  display: none !important;
}

@media (min-width: 768px) {
  .mobile-hide {
    display: block !important;
  }
  
  .mobile-only {
    display: none !important;
  }
}

/* Touch-friendly sizing */
@media (hover: none) and (pointer: coarse) {
  .btn,
  a,
  button {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  .form-select,
  .form-control {
    min-height: 44px !important;
  }
}
