/* ============================================
   Responsive CSS for Klick-Game
   Optimized for all screen sizes
   ============================================ */

/* ============================================
   Base Responsive Styles
   ============================================ */

/* Box sizing for all elements */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Make all images responsive */
img {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

/* Responsive iframes and embeds */
iframe, embed, object, video {
  max-width: 100%;
  height: auto;
}

/* Make form elements responsive */
input, select, textarea, button {
  max-width: 100%;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
}

/* ============================================
   Table Responsive Styles
   ============================================ */

/* Wrapper for responsive tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* Make tables responsive on mobile */
@media (max-width: 767px) {
  table:not(.table-force-layout) {
    width: 100% !important;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table:not(.table-force-layout) thead {
    display: none;
  }

  table:not(.table-force-layout) tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
  }

  table:not(.table-force-layout) td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem !important;
    text-align: right !important;
    border-bottom: 1px solid #dee2e6;
  }

  table:not(.table-force-layout) td:before {
    content: attr(data-label);
    font-weight: bold;
    text-align: left;
    margin-right: 1rem;
  }

  table:not(.table-force-layout) td:last-child {
    border-bottom: 0;
  }
}

/* ============================================
   Mobile Adjustments (< 768px)
   ============================================ */
@media (max-width: 767px) {
  /* Container adjustments */
  .container {
    padding: 0 10px !important;
    width: 100% !important;
  }
  
  .site-content-main {
    padding: 10px !important;
  }
  
  /* Hide certain elements on mobile */
  .mobile-hidden,
  .d-none-mobile {
    display: none !important;
  }
  
  /* Show mobile-only elements */
  .mobile-only {
    display: block !important;
  }
  
  /* Sidebar adjustments */
  .site-content-left, 
  .site-content-right {
    margin-bottom: 1rem;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Navigation improvements */
  nav, .navigation {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Button improvements */
  button, 
  .btn,
  input[type="button"],
  input[type="submit"] {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    white-space: normal;
    min-height: 2.75rem; /* 44px touch-friendly */
  }

  .btn-group {
    display: flex;
    flex-direction: column;
  }

  .btn-group button,
  .btn-group .btn {
    width: 100%;
    margin-right: 0;
  }
  
  /* Form improvements */
  form {
    width: 100%;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: bold;
  }
  
  /* Grid adjustments */
  [class*="col-"] {
    width: 100% !important;
    margin-bottom: 1rem;
  }
  
  /* Card adjustments */
  .card, .panel, .box {
    margin-bottom: 1rem;
  }
  
  /* Modal adjustments */
  .modal-content {
    padding: 10px;
    margin: 0 10px;
  }

  .modal-dialog {
    max-width: 100%;
    margin: 0.5rem;
  }
  
  /* Market table mobile optimization */
  .market-table {
    font-size: 0.875rem;
  }

  .market-table input[type="text"] {
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .market-table input[type="submit"] {
    width: 100%;
  }
  
  /* Responsive text sizes */
  body {
    font-size: 0.875rem; /* 14px */
  }
  
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  h4, h5, h6 {
    font-size: 1.1rem;
  }

  /* Spacing adjustments */
  .p-3, .p-4, .p-5 {
    padding: 1rem !important;
  }

  .m-3, .m-4, .m-5 {
    margin: 1rem !important;
  }

  /* Navigation bars */
  .navbar {
    flex-wrap: wrap;
  }

  .navbar-nav {
    flex-direction: column;
    width: 100%;
  }

  .navbar-nav li {
    width: 100%;
  }

  /* Tooltips on mobile */
  .tooltip,
  .tooltip2,
  .tooltip3,
  .tooltip4,
  .tooltip5 {
    position: fixed !important;
    max-width: 90vw !important;
    left: 5vw !important;
    font-size: 0.875rem;
  }

  /* Item rows */
  .item-row {
    flex-direction: column;
    padding: 1rem;
  }

  .item-name,
  .item-stock,
  .item-rate,
  .item-price,
  .item-action {
    width: 100% !important;
    text-align: left !important;
    margin-bottom: 0.5rem;
  }

  /* Flex utilities for mobile */
  .d-flex-mobile-column {
    flex-direction: column !important;
  }
}

/* ============================================
   Small Mobile Screens (< 480px)
   ============================================ */
@media (max-width: 480px) {
  body {
    font-size: 0.8125rem; /* 13px */
  }
  
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3, h4 {
    font-size: 1.1rem;
  }

  /* Smaller padding on very small screens */
  .container {
    padding: 0 0.3125rem !important; /* 5px */
  }

  .site-content-main {
    padding: 0.3125rem !important; /* 5px */
  }

  /* Adjust button sizes */
  button,
  .btn,
  input[type="button"],
  input[type="submit"] {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
  }

  /* Sidebar menu */
  .sidebar {
    font-size: 0.875rem;
  }

  .menu-text {
    font-size: 12px;
  }

  .sidebar-items-left a,
  .sidebar-items-right a {
    font-size: 11px;
  }
}

/* ============================================
   Tablet Screens (768px - 991px)
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {
  .container {
    width: 100%;
    max-width: 750px;
  }

  /* Restore table display */
  table {
    display: table !important;
  }

  /* 2-column layout for medium screens */
  .col-md-6 {
    width: 50%;
    float: left;
  }

  /* Adjust sidebar widths */
  .site-content-left,
  .site-content-right {
    flex: 0 0 180px;
    max-width: 180px;
  }
}

/* ============================================
   Desktop Screens (> 992px)
   ============================================ */
@media (min-width: 992px) {
  .container {
    max-width: 1200px;
  }

  /* Full layout with sidebars */
  .site-content-left,
  .site-content-right {
    flex: 0 0 200px;
    max-width: 200px;
  }

  /* Hide mobile-only elements */
  .mobile-only {
    display: none !important;
  }
}

/* ============================================
   Large Desktop Screens (> 1200px)
   ============================================ */
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
  }

  .site-content-left,
  .site-content-right {
    flex: 0 0 220px;
    max-width: 220px;
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .site-content-left,
  .site-content-right,
  .no-print {
    display: none !important;
  }

  .site-content-main {
    width: 100% !important;
    max-width: 100% !important;
  }

  body {
    font-size: 12pt;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* ============================================
   Utility Classes
   ============================================ */

/* Responsive visibility classes */
.hidden-xs { display: none !important; }
@media (min-width: 768px) { .hidden-xs { display: block !important; } }

.hidden-sm { display: block !important; }
@media (min-width: 768px) and (max-width: 991px) { .hidden-sm { display: none !important; } }

.hidden-md { display: block !important; }
@media (min-width: 992px) and (max-width: 1199px) { .hidden-md { display: none !important; } }

.hidden-lg { display: block !important; }
@media (min-width: 1200px) { .hidden-lg { display: none !important; } }

/* Visible classes */
.visible-xs { display: none !important; }
@media (max-width: 767px) { .visible-xs { display: block !important; } }

.visible-sm { display: none !important; }
@media (min-width: 768px) and (max-width: 991px) { .visible-sm { display: block !important; } }

.visible-md { display: none !important; }
@media (min-width: 992px) and (max-width: 1199px) { .visible-md { display: block !important; } }

.visible-lg { display: none !important; }
@media (min-width: 1200px) { .visible-lg { display: block !important; } }

/* Touch-friendly elements */
.touch-target {
  min-height: 2.75rem; /* 44px */
  min-width: 2.75rem; /* 44px */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Responsive spacing */
.responsive-spacing {
  padding: 1rem;
}

@media (min-width: 768px) {
  .responsive-spacing {
    padding: 1.5rem;
  }
}

@media (min-width: 992px) {
  .responsive-spacing {
    padding: 2rem;
  }
}