/*
 * LOLASMM Smart Responsive UI System
 * Version: 1.0.0 — 2026-06-13
 * 
 * Universal responsive layer for both admin and client panels.
 * Loaded AFTER theme CSS to override/fix layout issues.
 * Does NOT break existing styles — additive only.
 *
 * Breakpoints:
 *   Mobile:  < 768px
 *   Tablet:  768px – 1024px
 *   Desktop: > 1024px
 */

/* ============================================================
   0. CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================ */
:root {
  /* Spacing scale (8px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Layout */
  --sidebar-width: 280px;
  --sidebar-collapsed: 80px;
  --header-height: 70px;
  --navbar-bottom-height: 60px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index layers — Bootstrap modal uses 1050 (backdrop 1040, dialog 1050).
     Sidebar must be BELOW modal backdrop so modals can appear on top of sidebar. */
  --z-sidebar: 1035;
  --z-overlay: 1034;
  --z-header: 1030;
  --z-navbar-bottom: 1020;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Typography — static scale */
  --font-xs: 0.75rem;
  --font-sm: 0.8125rem;
  --font-base: 0.875rem;
  --font-md: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;

  /* Fluid type scale using clamp(min, preferred, max)
     Formula: preferred = calc(Xrem + Y * 1vw) */
  --text-xs:   clamp(0.6875rem, 0.65rem + 0.2vw,  0.75rem);
  --text-sm:   clamp(0.8125rem, 0.78rem + 0.18vw, 0.875rem);
  --text-base: clamp(0.875rem,  0.84rem + 0.18vw, 1rem);
  --text-lg:   clamp(1rem,      0.96rem + 0.22vw, 1.125rem);
  --text-xl:   clamp(1.125rem,  1rem    + 0.6vw,  1.375rem);
  --text-2xl:  clamp(1.25rem,   1.1rem  + 0.8vw,  1.625rem);
  --text-3xl:  clamp(1.5rem,    1.2rem  + 1.5vw,  2.25rem);
  --text-4xl:  clamp(1.875rem,  1.4rem  + 2.4vw,  3rem);

  /* Interactive element sizing */
  --btn-height:   clamp(36px, 4vw, 44px);
  --input-height: clamp(38px, 4vw, 46px);
}

/* ============================================================
   0b. GLOBAL FONT-FAMILY — safe system-font fallbacks
       Token vars (--font-body etc.) are defined in tokens.css.
       This ensures a consistent sans-serif if those vars are absent.
   ============================================================ */
body {
  font-family: var(--font-body, 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif);
  font-size: var(--text-base, 0.875rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-heading, 'Poppins', 'Inter', system-ui, sans-serif);
}
code, pre, kbd, samp,
.font-mono, [class*="mono"] {
  font-family: var(--font-mono, 'JetBrains Mono', 'Fira Code', ui-monospace, monospace);
}

/* ============================================================
   1. SIDEBAR OVERLAY (mobile/tablet)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-overlay);
  opacity: 0;
  transition: opacity var(--transition-normal);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ============================================================
   2. CLIENT PANEL — SIDEBAR FIXES
   ============================================================ */

/* Fix: sidebar mobile hide should use full width offset */
@media (max-width: 767.98px) {
  /* LTR default */
  .app-sidebar {
    left: -280px !important;
    right: auto !important;
    width: 280px !important;
    z-index: var(--z-sidebar);
    transition: left var(--transition-smooth), transform var(--transition-smooth);
  }
  .app-sidebar.sidebar-inact {
    left: 0px !important;
    width: 280px !important;
  }

  /* RTL: sidebar slides in from the right */
  [dir="rtl"] .app-sidebar,
  .rtl .app-sidebar,
  .rtl-enable .app-sidebar {
    left: auto !important;
    right: -280px !important;
    transition: right var(--transition-smooth);
  }
  [dir="rtl"] .app-sidebar.sidebar-inact,
  .rtl .app-sidebar.sidebar-inact,
  .rtl-enable .app-sidebar.sidebar-inact {
    right: 0px !important;
  }

  /* RTL: sidebar menu hover moves right instead of left */
  .rtl-enable .sidebar-menu li a.menu-link:hover,
  .rtl .sidebar-menu li a.menu-link:hover {
    transform: translateX(-3px) !important;
  }
  .rtl-enable .sidebar-menu li a.menu-link.active::before,
  .rtl .sidebar-menu li a.menu-link.active::before {
    left: auto;
    right: -8px;
    border-radius: 3px 0 0 3px;
  }

  /* On mobile sidebar is a drawer — hide sidebar logo (header bar shows it instead) */
  .app-sidebar .sidebar-header {
    display: none !important;
  }

  /* Content takes full width on mobile */
  .app-content {
    padding-left: 0 !important;
    padding-top: 85px !important;
    min-height: 100vh;
  }

  /* Header full width on mobile */
  .app-header {
    left: 0 !important;
    right: 0;
  }

  /* Close button visible when sidebar open */
  .app-sidebar.sidebar-inact .close-sidebar-btn {
    display: block !important;
  }
}

/* Tablet: sidebar collapsed to icon-only */
@media (min-width: 768px) and (max-width: 1024px) {
  .app-sidebar {
    width: var(--sidebar-collapsed) !important;
    z-index: var(--z-sidebar);
  }

  .app-sidebar .sidebar-header .logo-lg {
    display: none !important;
  }

  .app-sidebar .sidebar-header .logo-sm {
    display: inline-block !important;
  }

  .app-sidebar .app-user .user-name,
  .app-sidebar .app-user .user-balance {
    display: none !important;
  }

  .app-sidebar .sidebar-menu li a.menu-link {
    padding: 13px 0 !important;
    text-align: center !important;
  }

  .app-sidebar .sidebar-menu li a.menu-link .menu-text {
    display: none !important;
  }

  .app-sidebar .sidebar-menu li a.menu-link .menu-icon {
    width: 100% !important;
  }

  .app-content {
    padding-left: var(--sidebar-collapsed) !important;
  }

  .app-header {
    left: var(--sidebar-collapsed) !important;
  }

  /* Expanded sidebar on tablet */
  .app-sidebar.sidebar-inact {
    width: var(--sidebar-width) !important;
  }

  .app-sidebar.sidebar-inact .sidebar-menu li a.menu-link {
    padding: 13px 18px !important;
    text-align: left !important;
  }

  .app-sidebar.sidebar-inact .sidebar-menu li a.menu-link .menu-text {
    display: inline-block !important;
  }

  .app-sidebar.sidebar-inact .app-user .user-name,
  .app-sidebar.sidebar-inact .app-user .user-balance {
    display: block !important;
  }

  .app-sidebar.sidebar-inact .close-sidebar-btn {
    display: block !important;
  }
}

/* ============================================================
   3. TABLES — RESPONSIVE SCROLL WRAPPER
   ============================================================ */

/* Make all tables horizontally scrollable on small screens */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohide-scrollbar;
}

/* Auto-wrap tables that aren't already in a responsive wrapper */
@media (max-width: 1024px) {
  .table:not(.table-mobile-cards) {
    min-width: 600px;
  }

  /* Ensure table parent scrolls */
  .d-card-body,
  .card-body,
  .panel-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 767.98px) {
  /* Stack table mobile cards properly */
  .table-mobile-cards {
    width: 100% !important;
  }

  .table-mobile-cards tr.table-mobile-card {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* ============================================================
   4. FORMS — SINGLE COLUMN ON MOBILE
   ============================================================ */
@media (max-width: 767.98px) {
  .form-group .col-md-6,
  .form-group .col-md-4,
  .form-group .col-md-3,
  .form-group .col-lg-6,
  .form-group .col-lg-4 {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-left: var(--sp-3) !important;
    padding-right: var(--sp-3) !important;
  }

  /* Better input sizing on mobile */
  .form-control,
  .form-select,
  select.form-control {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    padding: 10px 12px !important;
  }

  /* Stack inline form groups */
  .form-inline .form-group {
    display: block !important;
    width: 100% !important;
    margin-bottom: var(--sp-3);
  }

  .form-inline .form-control {
    width: 100% !important;
  }
}

/* ============================================================
   5. CARDS — RESPONSIVE STACKING
   ============================================================ */
@media (max-width: 767.98px) {
  .d-card,
  .card {
    margin-bottom: var(--sp-4) !important;
  }

  .d-card .d-card-body,
  .card-body {
    padding: var(--sp-4) !important;
  }

  /* Dashboard status cards */
  .dash-home-status .col-lg-3 {
    margin-bottom: var(--sp-3) !important;
  }

  .dhs-item {
    padding: var(--sp-4) !important;
  }

  .dhs-item .dhs-item--text {
    font-size: 18px !important;
  }

  .dhs-item .dhs-item--title {
    font-size: 11px !important;
  }
}

/* ============================================================
   6. ADMIN PANEL — RESPONSIVE NAVBAR
   ============================================================ */

/* Admin navbar improvements */
@media (max-width: 991px) {
  /* Admin: make navbar collapse work better */
  .navbar-fixed-top .navbar-collapse {
    max-height: 80vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .navbar-fixed-top .navbar-nav > li > a {
    padding: 10px 15px !important;
    font-size: var(--font-sm) !important;
  }

  /* Admin dropdown menus */
  .navbar-fixed-top .dropdown-menu {
    position: static !important;
    float: none !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .navbar-fixed-top .dropdown-menu > li > a {
    padding-left: 30px !important;
    color: inherit !important;
  }
}

@media (max-width: 767.98px) {
  /* Admin: content below fixed navbar */
  body > .container-fluid,
  body > .container {
    padding-top: 60px;
  }

  /* Admin: tables scroll */
  .navbar-fixed-top + .container-fluid .table,
  .navbar-fixed-top ~ .container-fluid .table {
    min-width: 600px;
  }

  .navbar-fixed-top + .container-fluid,
  .navbar-fixed-top ~ .container-fluid {
    overflow-x: auto;
  }

  /* Admin: col-md panels stack */
  .col-md-6,
  .col-md-4,
  .col-md-3 {
    margin-bottom: var(--sp-3);
  }
}

/* ============================================================
   7. TYPOGRAPHY — RESPONSIVE SCALING
   ============================================================ */
/* Fluid headings — no breakpoint needed, clamp() scales continuously */
h1, .h1 { font-size: var(--text-4xl); }
h2, .h2 { font-size: var(--text-3xl); }
h3, .h3 { font-size: var(--text-2xl); }
h4, .h4 { font-size: var(--text-xl); }
h5, .h5 { font-size: var(--text-lg); }
h6, .h6 { font-size: var(--text-base); }

/* Prevent text overflow everywhere */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.d-card-head,
.simple-title,
.panel-title,
.modal-title {
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
}

/* ============================================================
   8. BUTTONS — TOUCH-FRIENDLY
   ============================================================ */
/* Buttons: clamp() sizing — consistent across all breakpoints */
.btn {
  min-height: var(--btn-height, clamp(36px, 4vw, 44px));
  min-width: 44px;
  padding: 8px 16px;
  font-size: var(--text-sm);
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.btn-xs { min-height: 32px; min-width: 32px; padding: 4px 10px; font-size: var(--text-xs); }
.btn-sm { min-height: 36px; min-width: 36px; padding: 6px 12px; font-size: var(--text-sm); }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: var(--text-base); }

/* Touch target enforcement on mobile */
@media (max-width: 767.98px) {
  .btn     { min-height: 44px; min-width: 44px; }
  .btn-xs  { min-height: 40px; min-width: 40px; }
  .btn-sm  { min-height: 40px; min-width: 40px; }
  .btn-group { flex-wrap: wrap; gap: 4px; }
}

/* Inputs: clamp() height everywhere */
.form-control,
.form-select,
select.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"] {
  min-height: var(--input-height, clamp(38px, 4vw, 46px));
  font-size: var(--text-base);
  padding: 8px 12px;
  box-sizing: border-box;
}
@media (max-width: 767.98px) {
  .form-control,
  .form-select,
  select.form-control {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    min-height: 44px;
  }
}

/* ============================================================
   9. MODALS — RESPONSIVE
   ============================================================ */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin: 10px !important;
    max-width: calc(100% - 20px) !important;
  }

  .modal-lg {
    max-width: calc(100% - 20px) !important;
  }

  .modal-body {
    padding: var(--sp-4) !important;
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* ============================================================
   10. UTILITY CLASSES
   ============================================================ */

/* Scrollable container */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Hide on specific breakpoints */
@media (max-width: 767.98px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 768px) and (max-width: 1024px) {
  .hide-tablet { display: none !important; }
}
@media (min-width: 1025px) {
  .hide-desktop { display: none !important; }
}

/* Show only on specific breakpoints */
@media (min-width: 768px) {
  .show-mobile-only { display: none !important; }
}
@media (max-width: 767.98px), (min-width: 1025px) {
  .show-tablet-only { display: none !important; }
}
@media (max-width: 1024px) {
  .show-desktop-only { display: none !important; }
}

/* Truncate text */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   11. GLOBAL FIXES
   ============================================================ */

/* Prevent horizontal overflow without breaking position:fixed on iOS Safari.
   Setting overflow-x:clip (not hidden) on <html> avoids creating a scroll container
   that makes position:fixed behave like position:absolute on iOS.
   overflow-y is left unset here — a duplicate rule below was using !important. */
html {
  overflow-x: clip;
  scroll-behavior: smooth;
}
body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Better box sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Fix images overflow */
img {
  max-width: 100%;
  height: auto;
}

/* Fix select dropdown on mobile */
@media (max-width: 767.98px) {
  .bootstrap-select .dropdown-menu {
    max-height: 200px !important;
    overflow-y: auto !important;
  }

  /* Fix dropdown-content panels (currency, language) */
  .dropdown-content {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    z-index: 9999 !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
  }
}

/* ============================================================
   12. BOTTOM NAVBAR (mobile) — IMPROVEMENTS
   ============================================================ */
@media (max-width: 767.98px) {
  .app-navbar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: var(--z-navbar-bottom) !important;
    background: #fff !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08) !important;
    padding: var(--sp-2) 0 !important;
  }

  body.dark .app-navbar {
    background: #151722 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
  }

  .app-navbar .navbar-texts {
    font-size: 10px !important;
  }

  .app-navbar a {
    font-size: 18px !important;
  }

  /* Add bottom padding to content so navbar doesn't cover it */
  .container-fluid {
    padding-bottom: calc(var(--navbar-bottom-height) + var(--sp-4)) !important;
  }
}

/* ============================================================
   13. SMART CONTENT DENSITY
   ============================================================ */

/* Compact mode for dense data tables */
@media (min-width: 1025px) {
  .table-compact td,
  .table-compact th {
    padding: 6px 10px !important;
    font-size: var(--font-sm) !important;
  }
}

/* Comfortable spacing on large screens */
@media (min-width: 1400px) {
  .app-content .container-fluid {
    max-width: 1400px;
    margin: 0 auto;
  }
}

/* ============================================================
   14. LOADING & TRANSITION STATES
   ============================================================ */

/* Skeleton loading placeholder */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

body.dark .skeleton {
  background: linear-gradient(90deg, #1a1d2e 25%, #232842 50%, #1a1d2e 75%);
  background-size: 200% 100%;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Smooth page transitions */
.app-content {
  animation: fadeInContent 0.2s ease-out;
}

@keyframes fadeInContent {
  from { opacity: 0.8; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Focus states for accessibility */
.form-control:focus,
.btn:focus,
a:focus {
  outline: 2px solid rgba(24, 91, 220, 0.4) !important;
  outline-offset: 2px;
}

/* ============================================================
   15. PRINT STYLES
   ============================================================ */
@media print {
  .app-sidebar,
  .app-header,
  .app-navbar,
  .navbar-fixed-top,
  .sidebar-overlay {
    display: none !important;
  }

  .app-content {
    padding-left: 0 !important;
    padding-top: 0 !important;
  }
}

/* ============================================================
   16. REDUCED MOTION
   ============================================================ */

/* ============================================================
   17. TERMS PAGE — PREMIUM BRANDED STYLING
   ============================================================ */

.lolasmm-terms-card {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(30, 32, 40, 0.95);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.lolasmm-terms-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.lolasmm-terms-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72); /* raised from 0.5 → passes WCAG AA 4.5:1 on dark surface */
  margin-bottom: 0;
}

.lolasmm-terms-content {
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
  font-size: clamp(14px, 1.6vw, 16px);
}

.lolasmm-terms-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lolasmm-terms-section:last-of-type {
  border-bottom: none;
}

.lolasmm-terms-section h3 {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  color: #818cf8;
  margin-bottom: 12px;
}

.lolasmm-terms-section p {
  margin-bottom: 10px;
}

.lolasmm-terms-section ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.lolasmm-terms-section ul li {
  margin-bottom: 6px;
  position: relative;
}

.lolasmm-terms-section a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lolasmm-terms-section a:hover {
  color: #a5b4fc;
}

.lolasmm-terms-contact {
  background: rgba(129, 140, 248, 0.08);
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 12px;
  padding: 20px;
  margin-top: 12px;
}

.lolasmm-terms-contact p {
  margin-bottom: 4px;
}

.lolasmm-terms-footer {
  text-align: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.65); /* raised from 0.4 → passes WCAG AA 4.5:1 on dark surface */
  font-size: 13px;
}

.lolasmm-terms-footer p {
  margin-bottom: 4px;
}

/* ============================================================
   18. API PAGE — RESPONSIVE & CENTERED
   ============================================================ */

.api.well-float {
  border-radius: 16px;
  overflow: hidden;
}

.api .g-card-body {
  padding: clamp(16px, 3vw, 32px);
}

.api h2 {
  font-size: clamp(1.25rem, 3.5vw, 2rem);
  font-weight: 700;
}

.api h4 {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
}

.api .table {
  width: 100%;
  table-layout: auto;
  word-break: break-word;
}

.api .table td,
.api .table th {
  color: inherit;
  border-color: rgba(255, 255, 255, 0.15) !important;
  padding: 10px 12px;
  font-size: clamp(13px, 1.4vw, 15px);
  vertical-align: top;
}

.api .table .width-40 {
  width: 35%;
  min-width: 100px;
}

.api pre {
  color: #e2e8f0 !important;
  background: #0f1117;
  padding: 16px;
  border-radius: 8px;
  font-size: clamp(12px, 1.3vw, 14px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  word-break: normal;
  max-width: 100%;
}

.api .btn-default {
  min-height: 44px;
  padding: 10px 24px;
}

@media (max-width: 767.98px) {
  .api .table .width-40 {
    width: 40%;
    min-width: 80px;
  }

  .api .table td,
  .api .table th {
    padding: 8px;
    font-size: 13px;
  }

  .api .form-inline {
    display: block;
  }

  .api .form-inline .form-group {
    width: 100%;
  }

  .api .form-inline .form-control {
    width: 100%;
  }

  .api .btn-default {
    width: 100%;
    text-align: center;
  }
}

/* ============================================================
   19. GLOBAL PROPORTIONAL DISPLAY — ALL DEVICES
   ============================================================ */

/* Ensure content never overflows viewport */
.app-content,
.container,
.container-fluid {
  max-width: 100%;
  box-sizing: border-box;
}

/* Cards: proportional on all screens */
.g-card,
.card,
.panel {
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* Images: never overflow */
img {
  max-width: 100%;
  height: auto;
}

/* Pre/code blocks: scroll instead of overflow */
pre, code {
  max-width: 100%;
  overflow-x: auto;
  word-break: break-word;
}

/* Tables: responsive wrapper behavior */
.table {
  max-width: 100%;
}

/* Forms: proportional inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea,
select,
.form-control {
  max-width: 100%;
  box-sizing: border-box;
}

/* ============================================================
   20. SERVICES PAGE — SCROLLBAR & MOBILE FIX
   ============================================================ */

/* Always show scrollbar on services table wrapper */
.table-responsive,
.bg-lighter {
  overflow-y: visible;
}

/* Services table: horizontal scroll with visible scrollbar */
.bg-lighter .table,
table.services {
  display: block;
  width: 100%;
}

table.services {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure scrollbar is always visible (not auto-hidden) */
table.services::-webkit-scrollbar {
  height: 8px;
  display: block;
}
table.services::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
table.services::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}
table.services::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Dark mode scrollbar */
body.dark table.services::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
body.dark table.services::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

/* Mobile: services table card layout */
@media (max-width: 767.98px) {
  table.services thead {
    display: none;
  }

  table.services tbody tr.service {
    display: flex;
    flex-direction: column;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  table.services tbody tr.service td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    font-size: 13px;
    width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    word-break: break-word;
  }

  table.services tbody tr.service td::before {
    content: attr(data-title);
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
    min-width: 80px;
    font-size: 12px;
    opacity: 0.7;
    text-transform: uppercase;
  }

  table.services tbody tr.service td.pm-ikon {
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-bottom: 4px;
  }

  table.services tbody tr.service td.pm-ikon::before {
    display: none;
  }

  /* Category rows stay full width */
  table.services tbody tr.service-category {
    display: block;
    padding: 10px 0;
  }

  table.services tbody tr.service-category td {
    display: block;
    width: 100% !important;
    font-size: 15px;
    font-weight: 700;
    padding: 8px 4px;
  }

  /* Fix filter dropdown on mobile */
  .dropdown .btn.dropdown-toggle {
    width: 100%;
    text-align: left;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .filter-items {
    width: 100% !important;
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Fix search input */
  .input-group.input-style {
    width: 100%;
  }

  /* Buttons: ensure full visibility */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 16px;
    font-size: 14px;
    white-space: normal;
    word-break: break-word;
  }

  /* Icon-only buttons */
  .btn .ri-search-line,
  .btn .icon-details,
  a .icon-details,
  a .ri-search-line {
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
  }

  /* Services page hero section */
  .bg-pattern {
    padding: 16px !important;
  }

  .bg-pattern .h3 {
    font-size: 20px;
  }

  .bg-lighter {
    padding: 12px !important;
  }
}

/* Tablet: services table scrollable with visible bar */
@media (min-width: 768px) and (max-width: 1024px) {
  table.services {
    display: block;
    overflow-x: auto;
  }

  table.services th,
  table.services td {
    white-space: nowrap;
    padding: 8px 10px;
    font-size: 13px;
  }

  /* Ensure buttons are visible */
  .btn {
    min-height: 38px;
    white-space: normal;
  }
}

/* Global scrollbar visibility fix for all themes */
.app-content,
.page-content,
.container-fluid {
  overflow-y: visible;
}

/* Page scroll: scrollbar-gutter reserves space so content doesn't shift
   when scrollbar appears/disappears (replaces overflow-y: scroll !important) */
html {
  scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}
