/* ===== MOBILE VIEWPORT RESPONSIVE SYSTEM ===== */

/* Base Mobile-First Approach */
* {
  box-sizing: border-box;
}

/* Enhanced Mobile Viewport Meta Support */
@viewport {
  width: device-width;
  initial-scale: 1;
  maximum-scale: 5;
  user-scalable: yes;
}

/* ===== MOBILE BREAKPOINTS ===== */
:root {
  /* Mobile breakpoints */
  --mobile-xs: 320px;
  --mobile-sm: 375px;
  --mobile-md: 414px;
  --mobile-lg: 480px;
  --tablet-sm: 768px;
  --tablet-lg: 1024px;
  --desktop: 1200px;
  --desktop-lg: 1440px;

  /* Mobile spacing */
  --mobile-padding: 1rem;
  --mobile-margin: 0.75rem;
  --mobile-gap: 0.5rem;

  /* Mobile typography */
  --mobile-font-xs: 0.75rem;
  --mobile-font-sm: 0.875rem;
  --mobile-font-base: 1rem;
  --mobile-font-lg: 1.125rem;
  --mobile-font-xl: 1.25rem;
  --mobile-font-2xl: 1.5rem;

  /* Touch targets */
  --touch-target-min: 44px;
  --touch-target-comfortable: 48px;
}

/* ===== CONTAINER RESPONSIVE SYSTEM ===== */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: var(--mobile-padding);
}

/* Mobile First Container Sizes */
@media (min-width: 320px) {
  .container {
    padding: 1rem 0.75rem;
  }
}

@media (min-width: 375px) {
  .container {
    padding: 1rem;
  }
}

@media (min-width: 414px) {
  .container {
    padding: 1.25rem;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 1.5rem 2rem;
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 2rem;
    max-width: 1024px;
  }
}

@media (min-width: 1200px) {
  .container {
    padding: 2rem 2.5rem;
    max-width: 1200px;
  }
}

@media (min-width: 1440px) {
  .container {
    max-width: 1400px;
  }
}

/* ===== MOBILE HEADER RESPONSIVE ===== */
.header {
  font-size: var(--mobile-font-2xl);
  margin-bottom: 1.5rem;
  text-align: center;
  line-height: 1.2;
  word-wrap: break-word;
  hyphens: auto;
}

@media (min-width: 375px) {
  .header {
    font-size: 1.75rem;
    margin-bottom: 2rem;
  }
}

@media (min-width: 414px) {
  .header {
    font-size: 2rem;
  }
}

@media (min-width: 768px) {
  .header {
    font-size: 2.25rem;
    margin-bottom: 2.5rem;
  }
}

@media (min-width: 1024px) {
  .header {
    font-size: 2.75rem;
  }
}

/* ===== MOBILE NAVIGATION RESPONSIVE ===== */
.menu-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
}

@media (max-width: 480px) {
  .menu-container {
    top: 0.75rem;
    right: 0.75rem;
  }
}

.menu-btn {
  width: var(--touch-target-comfortable);
  height: var(--touch-target-comfortable);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  touch-action: manipulation;
}

.dropdown-menu {
  min-width: 280px;
  max-width: 90vw;
  right: 0;
  top: calc(var(--touch-target-comfortable) + 0.5rem);
}

@media (max-width: 480px) {
  .dropdown-menu {
    min-width: 260px;
    max-width: calc(100vw - 1.5rem);
  }
}

.dropdown-menu a {
  padding: 1rem 1.25rem;
  font-size: var(--mobile-font-sm);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  touch-action: manipulation;
}

/* ===== MOBILE BUTTONS RESPONSIVE ===== */
.sigle-buttons-container {
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: 1.5rem;
  padding: 1rem 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 1rem;
  overflow: hidden;
}

.sigle-buttons {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 1rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sigle-buttons::-webkit-scrollbar {
  display: none;
}

.sigla-btn {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  font-size: var(--mobile-font-sm);
  min-width: auto;
  min-height: var(--touch-target-min);
  border-radius: 9999px;
  white-space: nowrap;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

@media (max-width: 480px) {
  .sigla-btn {
    padding: 0.625rem 0.875rem;
    font-size: var(--mobile-font-xs);
  }
}

/* Scroll Indicators for Mobile */
.scroll-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  background: rgba(59, 130, 246, 0.9);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.scroll-indicator.left {
  left: 0.5rem;
}

.scroll-indicator.right {
  right: 0.5rem;
}

.scroll-indicator.hidden {
  opacity: 0;
  pointer-events: none;
}

.scroll-indicator:hover {
  background: rgba(59, 130, 246, 1);
  transform: translateY(-50%) scale(1.1);
}

/* ===== MOBILE TABLES RESPONSIVE ===== */
.table-container {
  margin-bottom: 2rem;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.order-book-table {
  width: 100%;
  font-size: var(--mobile-font-sm);
}

.order-book-table th,
.order-book-table td {
  padding: 0.75rem 0.5rem;
  text-align: center;
}

@media (max-width: 480px) {
  .order-book-table {
    font-size: var(--mobile-font-xs);
  }

  .order-book-table th,
  .order-book-table td {
    padding: 0.5rem 0.25rem;
  }
}

/* ===== MOBILE MARKET TIPS TABLE ===== */
.market-tips-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.market-tips-table {
  min-width: 800px;
  width: 100%;
}

.market-tips-table th {
  padding: 1rem 0.5rem;
  font-size: 0.7rem;
  line-height: 1.3;
  white-space: normal;
  word-wrap: break-word;
  min-width: 70px;
  max-width: 90px;
}

.market-tips-table td {
  padding: 0.75rem 0.5rem;
  font-size: 0.75rem;
  min-width: 70px;
  max-width: 90px;
  word-break: break-word;
  white-space: normal;
}

@media (max-width: 480px) {
  .market-tips-table {
    min-width: 700px;
  }

  .market-tips-table th {
    padding: 0.75rem 0.25rem;
    font-size: 0.65rem;
    min-width: 60px;
    max-width: 80px;
  }

  .market-tips-table td {
    padding: 0.5rem 0.25rem;
    font-size: 0.7rem;
    min-width: 60px;
    max-width: 80px;
  }
}

/* Mobile Table Labels */
@media (max-width: 768px) {
  .market-tips-table td[data-label]:before {
    content: attr(data-label) ": ";
    font-weight: bold;
    display: inline-block;
    margin-right: 0.5rem;
    color: var(--tips-text-secondary);
  }
}

/* ===== MOBILE MODALS RESPONSIVE ===== */
.modal {
  padding: 1rem;
  align-items: flex-start;
  overflow-y: auto;
}

.modal-content {
  width: 95%;
  max-width: 500px;
  margin: 2rem auto;
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 1rem;
}

@media (max-width: 480px) {
  .modal {
    padding: 0.5rem;
  }

  .modal-content {
    width: 98%;
    margin: 1rem auto;
    padding: 1rem;
    max-height: 95vh;
    border-radius: 0.75rem;
  }
}

.modal-header h2 {
  font-size: var(--mobile-font-xl);
  line-height: 1.3;
}

@media (max-width: 480px) {
  .modal-header h2 {
    font-size: var(--mobile-font-lg);
  }
}

/* ===== MOBILE FORMS RESPONSIVE ===== */
.input-group input,
.player-select {
  width: 100%;
  padding: 1rem;
  font-size: var(--mobile-font-base);
  min-height: var(--touch-target-comfortable);
  border-radius: 0.75rem;
  touch-action: manipulation;
}

@media (max-width: 480px) {
  .input-group input,
  .player-select {
    padding: 0.875rem;
    font-size: var(--mobile-font-sm);
  }
}

button,
.role-btn,
#comparePlayersBtn {
  min-height: var(--touch-target-comfortable);
  padding: 0.875rem 1.5rem;
  font-size: var(--mobile-font-base);
  border-radius: 0.75rem;
  touch-action: manipulation;
  cursor: pointer;
}

@media (max-width: 480px) {
  button,
  .role-btn,
  #comparePlayersBtn {
    padding: 0.75rem 1.25rem;
    font-size: var(--mobile-font-sm);
  }
}

/* ===== MOBILE CHARTS RESPONSIVE ===== */
.chart-container {
  height: 600px;
  margin-bottom: 1.5rem;
  border-radius: 1rem;
  overflow: hidden;
}

@media (max-width: 768px) {
  .chart-container {
    height: 350px;
  }
}

@media (max-width: 480px) {
  .chart-container {
    height: 300px;
  }
}

.chart-container canvas {
  width: 100% !important;
  height: 94% !important;
}

/* ===== MOBILE ROLE BUTTONS ===== */
.role-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 2rem 0;
}

@media (max-width: 768px) {
  .role-buttons {
    gap: 0.75rem;
    margin: 1.5rem 0;
  }
}

@media (max-width: 480px) {
  .role-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }
}

.role-btn {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
  padding: 1rem 1.5rem;
  font-size: var(--mobile-font-base);
}

@media (max-width: 768px) {
  .role-btn {
    min-width: 150px;
    padding: 0.875rem 1.25rem;
    font-size: var(--mobile-font-sm);
  }
}

@media (max-width: 480px) {
  .role-btn {
    min-width: auto;
    max-width: none;
    width: 100%;
  }
}

/* ===== MOBILE PRICE INFO ===== */
.price-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 1rem;
}

@media (min-width: 768px) {
  .price-info {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.price-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

@media (min-width: 480px) {
  .price-row {
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
  }
}

/* ===== MOBILE STK-EUR INFO ===== */
#stk-eur-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-radius: 1rem;
}

@media (min-width: 768px) {
  #stk-eur-info {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* ===== MOBILE VOLUME STATS ===== */
.volume-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 480px) {
  .volume-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .volume-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== MOBILE ORDER BOOK SECTIONS ===== */
.order-book-section {
  margin-bottom: 1.5rem;
}

.order-table {
  width: 100%;
  font-size: var(--mobile-font-sm);
}

.order-table th,
.order-table td {
  padding: 0.75rem 0.5rem;
  text-align: center;
}

@media (max-width: 480px) {
  .order-table {
    font-size: var(--mobile-font-xs);
  }

  .order-table th,
  .order-table td {
    padding: 0.5rem 0.25rem;
  }
}

/* ===== MOBILE BACK BUTTON ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: var(--mobile-font-sm);
  min-height: var(--touch-target-min);
  border-radius: 0.75rem;
  touch-action: manipulation;
  text-decoration: none;
}

@media (max-width: 480px) {
  .back-btn {
    padding: 0.75rem 1rem;
    font-size: var(--mobile-font-xs);
  }
}

/* ===== MOBILE LOADING STATES ===== */
.loading {
  padding: 3rem 1rem;
  text-align: center;
  border-radius: 1rem;
}

@media (max-width: 480px) {
  .loading {
    padding: 2rem 0.75rem;
  }
}

.loading-spinner {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
}

@media (max-width: 480px) {
  .loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ===== MOBILE SWIPE INDICATORS ===== */
.swipe-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--tips-info), var(--tips-purple));
  color: white;
  font-size: var(--mobile-font-sm);
  font-weight: 600;
}

@media (min-width: 768px) {
  .swipe-indicator {
    display: none;
  }
}

/* ===== MOBILE ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .container {
    border: 2px solid;
  }

  button,
  .sigla-btn,
  .role-btn {
    border: 2px solid;
  }
}

/* ===== MOBILE TOUCH IMPROVEMENTS ===== */
button,
.sigla-btn,
.role-btn,
.menu-btn,
.token-link,
.back-btn {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Improve touch scrolling */
.sigle-buttons,
.market-tips-table-container,
.modal-content {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ===== MOBILE LANDSCAPE ORIENTATION ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .header {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .modal-content {
    max-height: 95vh;
    margin: 0.5rem auto;
  }

  .chart-container {
    height: 250px;
  }
}

/* ===== MOBILE SAFE AREAS (iPhone X+) ===== */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(var(--mobile-padding), env(safe-area-inset-left));
    padding-right: max(var(--mobile-padding), env(safe-area-inset-right));
  }

  .menu-container {
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
  }

  .modal {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* ===== MOBILE PRINT STYLES ===== */
@media print {
  .menu-container,
  .dropdown-menu,
  .scroll-indicator,
  .swipe-indicator,
  .back-btn {
    display: none !important;
  }

  .container {
    padding: 0;
    max-width: none;
  }

  .header {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .table-container {
    break-inside: avoid;
    margin-bottom: 1rem;
  }
}
