/* ========================================
   MOBILE RESPONSIVE STYLES
   For Pipeline and Data-Heavy Pages
   ======================================== */

/* Base Mobile Adjustments */
@media (max-width: 768px) {
  body {
    padding-top: 140px !important;
    font-size: 14px;
  }
  
  /* Container adjustments */
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  
  /* Typography */
  h1, h2, h3, h4, h5, h6 {
    font-size: 16px;
    margin-bottom: 12px;
  }
  
  /* Buttons */
  .btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .btn-group .btn {
    flex: 0 1 auto;
    margin: 0;
  }
  
  /* Cards - make them stack */
  .card,
  .order-card {
    margin-bottom: 12px;
  }
  
  .card-block {
    padding: 12px;
  }
  
  /* Tables - make them scrollable */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
  }
  
  table.table {
    min-width: 800px; /* Force horizontal scroll */
    font-size: 11px;
    margin-bottom: 0;
  }
  
  table.table th,
  table.table td {
    padding: 8px 6px;
    white-space: nowrap;
  }
  
  /* Make first column (names) sticky on mobile */
  table.table thead th:first-child,
  table.table tbody td:first-child {
    position: sticky;
    left: 0;
    background: white;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  }
  
  table.table thead th:first-child {
    background: rgb(22, 49, 101);
    z-index: 11;
  }
  
  /* Form controls */
  .form-control {
    font-size: 14px;
    height: 40px;
  }
  
  input[type="text"],
  input[type="search"] {
    -webkit-appearance: none;
    border-radius: 8px;
  }
  
  /* Modals */
  .modal-dialog {
    margin: 10px;
    width: auto;
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  /* Navigation pills/tabs */
  .nav-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
  }
  
  .nav-pills > li {
    flex: 0 1 auto;
  }
  
  .nav-pills > li > a {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  /* Labels and badges */
  .label,
  .badge {
    font-size: 10px;
    padding: 3px 6px;
  }
  
  /* Dropdown menus on mobile */
  .dropdown-menu {
    max-height: 400px;
    overflow-y: auto;
  }
}

/* Small Mobile (phones in portrait) */
@media (max-width: 480px) {
  body {
    font-size: 13px;
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-size: 14px;
  }
  
  .btn {
    font-size: 11px;
    padding: 5px 10px;
  }
  
  table.table {
    font-size: 10px;
  }
  
  table.table th,
  table.table td {
    padding: 6px 4px;
  }
  
  /* Stack cards in single column */
  .row > [class*='col-'] {
    width: 100%;
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* Tablet Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    padding-top: 112px !important;
  }
  
  .container {
    padding-left: 20px;
    padding-right: 20px;
  }
  
  table.table {
    font-size: 12px;
  }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
  body {
    padding-top: 100px !important;
  }
  
  .navbar-custom {
    min-height: 80px;
  }
  
  .activity-sidebar {
    max-height: 300px;
  }
}

/* Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets for mobile */
  button,
  a,
  input[type="button"],
  input[type="submit"],
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .btn:hover,
  .nav-pills > li > a:hover {
    transform: none;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .btn,
  .activity-sidebar {
    display: none !important;
  }
  
  body {
    padding-top: 0 !important;
  }
  
  table.table {
    font-size: 10px;
  }
}

/* ========================================
   PIPELINE-SPECIFIC MOBILE STYLES
   ======================================== */

@media (max-width: 768px) {
  /* Pipeline summary cards */
  .order-card h4 {
    font-size: 14px;
  }
  
  .order-card p {
    font-size: 11px;
  }
  
  /* Pipeline table specific */
  #portfolioTable {
    width: 100%;
  }
  
  #portfolioTable caption {
    font-size: 14px;
    padding: 8px;
  }
  
  /* Search input for pipeline */
  #myInput {
    font-size: 14px;
    padding: 10px;
    margin-bottom: 12px;
    border-radius: 8px;
  }
  
  /* Player names - make them more prominent on mobile */
  table.table td:first-child a {
    font-weight: 600;
    color: #0052cc;
  }
  
  /* Status labels */
  .label-hollow {
    font-size: 9px;
    padding: 2px 5px;
  }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
  /* Focus states for keyboard navigation */
  a:focus,
  button:focus,
  input:focus,
  select:focus {
    outline: 3px solid #6366f1;
    outline-offset: 2px;
  }
  
  /* Skip to main content link */
  .skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    background: #6366f1;
    color: white;
    padding: 12px;
    z-index: 100000;
    border-radius: 0 0 8px 0;
  }
  
  .skip-to-main:focus {
    top: 0;
  }
}

/* ========================================
   LOADING STATES
   ======================================== */

@media (max-width: 768px) {
  /* Show loading indicator for tables */
  .table-loading {
    position: relative;
    opacity: 0.6;
  }
  
  .table-loading::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Mobile-only visibility */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none !important;
  }
  
  /* Text alignment utilities */
  .mobile-text-center {
    text-align: center;
  }
  
  .mobile-text-left {
    text-align: left;
  }
  
  /* Spacing utilities */
  .mobile-mt-2 {
    margin-top: 8px;
  }
  
  .mobile-mb-2 {
    margin-bottom: 8px;
  }
  
  .mobile-p-2 {
    padding: 8px;
  }
}

/* ========================================
   DYNAMIC PLAYER MODAL - MOBILE OPTIMIZED
   ======================================== */

@media (max-width: 768px) {
  /* Modal dialog - make it fullscreen on mobile */
  #dynamicPlayerModal .modal-dialog {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
  }
  
  #dynamicPlayerModal .modal-content {
    height: 100vh !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Modal Header - Compact on mobile */
  #dynamicPlayerModal .modal-header {
    padding: 16px 20px !important;
    border-radius: 0 !important;
    min-height: auto !important;
  }
  
  #dynamicPlayerModal .modal-header .close {
    position: absolute;
    right: 12px;
    top: 12px;
    font-size: 22px !important;
    z-index: 100;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 50% !important;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
  }
  
  #dynamicPlayerModal .modal-header .close:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3) !important;
  }
  
  /* Player title area */
  #modalPlayerTitle {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding-right: 40px; /* Space for close button */
  }
  
  #modalPlayerImage {
    height: 60px !important;
    width: 60px !important;
    border-width: 2px !important;
  }
  
  #modalPlayerName {
    font-size: 20px !important;
    line-height: 1.2 !important;
  }
  
  #modalPlayerMeta {
    font-size: 12px !important;
  }
  
  /* Modal Body - Scrollable content */
  #dynamicPlayerModal .modal-body {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 16px !important;
  }
  
  /* Navigation tabs - make them scrollable horizontally */
  #dynamicPlayerModal .nav-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 0 !important;
    margin: 0 !important;
    border-bottom: 1px solid #e5e7eb;
  }
  
  #dynamicPlayerModal .nav-tabs > li {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  
  #dynamicPlayerModal .nav-tabs > li > a {
    font-size: 11px !important;
    padding: 8px 12px !important;
    margin-right: 4px;
  }
  
  /* Tab content */
  #dynamicPlayerModal .tab-content {
    padding: 16px;
  }
  
  /* Forms in modal */
  #dynamicPlayerModal .form-group {
    margin-bottom: 16px;
  }
  
  #dynamicPlayerModal .form-group label {
    font-size: 11px !important;
    margin-bottom: 6px;
  }
  
  #dynamicPlayerModal input,
  #dynamicPlayerModal textarea,
  #dynamicPlayerModal select {
    font-size: 14px !important;
    padding: 10px 12px !important;
  }
  
  #dynamicPlayerModal textarea {
    min-height: 100px;
  }
  
  /* Buttons in modal */
  #dynamicPlayerModal .btn {
    font-size: 13px !important;
    padding: 10px 16px !important;
    min-height: 44px; /* Touch-friendly */
  }
  
  /* Tables inside modal */
  #dynamicPlayerModal .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px; /* Extend to edges */
    padding: 0 16px;
  }
  
  #dynamicPlayerModal table.table {
    font-size: 11px !important;
    min-width: 600px;
  }
  
  #dynamicPlayerModal table.table th,
  #dynamicPlayerModal table.table td {
    padding: 8px 6px !important;
  }
  
  /* Player sidebar in modal (if present) */
  .modal-player-sidebar {
    display: none !important; /* Hide on mobile to save space */
  }
  
  /* Enhanced player header in modal (if present) */
  .modal-player-header {
    padding: 16px !important;
  }
  
  .modal-player-header .player-name {
    font-size: 18px !important;
  }
  
  .modal-player-header .rating {
    display: flex;
    gap: 6px;
  }
  
  .modal-player-header .star {
    font-size: 20px !important;
    width: 28px;
    height: 28px;
  }
  
  /* Activity timeline in modal */
  #activityTimelineContainer {
    padding: 12px 0;
  }
  
  .activity-item {
    padding: 12px;
    font-size: 12px;
    margin-bottom: 8px;
  }
  
  /* Loading spinner */
  #modalLoadingSpinner {
    padding: 40px 20px !important;
  }
  
  /* Price button in modal */
  .price-btn {
    min-height: 40px !important;
    font-size: 12px !important;
    padding: 8px 12px !important;
  }
  
  /* Modal footer (if present) */
  #dynamicPlayerModal .modal-footer {
    padding: 16px 20px !important;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  #dynamicPlayerModal .modal-footer .btn {
    flex: 1;
    min-width: 100px;
  }
}

/* Small mobile - even more compact */
@media (max-width: 480px) {
  #dynamicPlayerModal .modal-header {
    padding: 12px 16px !important;
  }
  
  #modalPlayerName {
    font-size: 18px !important;
  }
  
  #modalPlayerImage {
    height: 50px !important;
    width: 50px !important;
  }
  
  #dynamicPlayerModal .nav-tabs > li > a {
    font-size: 10px !important;
    padding: 6px 10px !important;
  }
  
  #dynamicPlayerModal table.table {
    font-size: 10px !important;
  }
  
  #dynamicPlayerModal .btn {
    font-size: 12px !important;
  }
}

/* Landscape mode - optimize for width */
@media (max-width: 768px) and (orientation: landscape) {
  #dynamicPlayerModal .modal-dialog {
    height: 100vh !important;
  }
  
  #dynamicPlayerModal .modal-header {
    padding: 12px 20px !important;
  }
  
  #modalPlayerTitle {
    flex-direction: row !important;
    align-items: center !important;
  }
  
  #modalPlayerImage {
    height: 50px !important;
    width: 50px !important;
  }
  
  #modalPlayerName {
    font-size: 18px !important;
  }
}
