/* ============================================
   MySetMatch - Mobile Responsive Styles
   Mobile-First Responsive Design
   ============================================ */

/* ============================================
   CSS CUSTOM PROPERTIES - Mobile Overrides
   ============================================ */
:root {
  /* Touch-friendly sizes */
  --touch-target-min: 44px;
  --mobile-spacing: 1rem;
  --mobile-padding: 1rem;

  /* Mobile typography */
  --mobile-font-base: 16px;
  --mobile-font-lg: 1.125rem;
  --mobile-font-xl: 1.5rem;
}

/* ============================================
   GLOBAL MOBILE OPTIMIZATIONS
   ============================================ */

/* Prevent text size adjustment on iOS */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Touch-friendly interactions - Base mobile styles */
@media (max-width: 767px) {
  body {
    font-size: var(--mobile-font-base);
    gap: 2rem; /* Reduce gap on mobile */
  }

  /* Container padding adjustments */
  .container,
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Reduce heading sizes on mobile */
  h1, .h1 { font-size: 1.75rem; }
  h2, .h2 { font-size: 1.5rem; }
  h3, .h3 { font-size: 1.25rem; }
  h4, .h4 { font-size: 1.125rem; }
  h5, .h5 { font-size: 1rem; }

  .display-1 { font-size: 3rem; }
  .display-2 { font-size: 2.5rem; }
  .display-3 { font-size: 2rem; }
  .display-4 { font-size: 1.75rem; }
  .display-5 { font-size: 1.5rem; }
  .display-6 { font-size: 1.25rem; }

  /* Lead text */
  .lead {
    font-size: 1rem;
  }

  /* Card padding adjustments */
  .card-body {
    padding: 1.5rem;
  }

  .card-header {
    padding: 1rem 1.5rem;
  }
}

/* ============================================
   NAVIGATION - Mobile Menu
   ============================================ */

/* Mobile navigation styles (below 576px) */
@media (max-width: 575px) {
  .navbar-nav {
    padding: 1rem 0;
  }

  .nav-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
  }

  .nav-item:last-child {
    border-bottom: none;
  }

  .nav-link {
    padding: 0.75rem 1rem !important;
    font-size: 1.125rem !important;
  }

  .nav-link:hover {
    background: var(--bg-body);
    padding-left: 1.5rem !important;
  }
}

/* Tablet navigation (576px - 991px) */
@media (min-width: 576px) and (max-width: 991px) {
  .nav-link {
    padding: 0.75rem 1rem !important;
  }
}

/* Navbar toggler adjustments */
@media (max-width: 991px) {
  .navbar-toggler {
    border: 2px solid var(--primary-blue);
    padding: 0.5rem 0.75rem;
  }

  .navbar-toggler:focus {
    box-shadow: 0 0 0 0.25rem rgba(43, 76, 140, 0.25);
  }

  .navbar-collapse {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
  }
}

/* ============================================
   BUTTONS - Touch-Friendly
   ============================================ */

@media (max-width: 767px) {
  .btn {
    min-height: 44px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  .btn-sm {
    min-height: 38px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .btn-lg {
    min-height: 50px;
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
  }

  /* Full width buttons on mobile utility class */
  .btn-mobile-block {
    width: 100%;
    display: block;
  }
}

/* ============================================
   FORMS - Mobile Optimized
   ============================================ */

@media (max-width: 767px) {
  .form-control,
  .form-select {
    font-size: 16px; /* Prevents iOS zoom on input focus */
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .form-control-sm,
  .form-select-sm {
    font-size: 14px;
    min-height: 38px;
  }

  .form-control-lg,
  .form-select-lg {
    font-size: 18px;
    min-height: 50px;
  }

  .form-label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  textarea.form-control {
    min-height: 100px;
  }

  /* Input groups */
  .input-group-lg .btn,
  .input-group-lg .form-control {
    min-height: 50px;
    font-size: 1.125rem;
  }
}

/* ============================================
   CARDS - Responsive Adjustments
   ============================================ */

@media (max-width: 767px) {
  .card {
    margin-bottom: 1rem;
    border-radius: 12px;
  }

  .card-header {
    font-size: 1rem;
  }

  /* Card hover effects disabled on touch devices */
  .card:hover {
    transform: none;
  }
}

/* ============================================
   TABLES - Mobile Responsive Patterns
   ============================================ */

/* Table responsive wrapper */
@media (max-width: 767px) {
  .table-responsive {
    border: none;
    margin-bottom: 1rem;
  }

  /* Hide table on mobile when using mobile-card pattern */
  .table-responsive-mobile table {
    display: none;
  }

  .table-responsive-mobile .mobile-card-view {
    display: block;
  }

  /* Standard table adjustments for tables that stay as tables */
  .table {
    font-size: 0.875rem;
  }

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

  /* Hide less important columns on mobile */
  .table .d-none-mobile {
    display: none;
  }
}

/* Tablet view - show mobile-card view on medium screens too if needed */
@media (min-width: 768px) {
  .table-responsive-mobile table {
    display: table;
  }

  .table-responsive-mobile .mobile-card-view {
    display: none;
  }
}

/* ============================================
   FOOTER - Mobile Stacking
   ============================================ */

@media (max-width: 767px) {
  .footer {
    padding: 2rem 0;
    text-align: center;
  }

  .footer h5 {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .footer .col-12 {
    margin-bottom: 2rem;
  }

  .footer .col-12:last-child {
    margin-bottom: 0;
  }

  .footer .d-flex {
    justify-content: center !important;
  }
}

/* ============================================
   HERO SECTION - Responsive Typography
   ============================================ */

@media (max-width: 767px) {
  .hero-section {
    padding: 3rem 0;
    border-radius: 0 0 25px 25px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .hero-subtitle {
    font-size: 1.125rem;
  }
}

/* ============================================
   MODALS - Mobile Adjustments
   ============================================ */

@media (max-width: 575px) {
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-content {
    border-radius: 12px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.125rem;
  }
}

/* ============================================
   BADGES - Mobile Sizing
   ============================================ */

@media (max-width: 575px) {
  .badge {
    font-size: 0.7rem;
    padding: 0.3em 0.5em;
  }

  .badge-lg {
    font-size: 0.85rem;
    padding: 0.4em 0.65em;
  }
}

/* ============================================
   ALERTS - Mobile Adjustments
   ============================================ */

@media (max-width: 767px) {
  .alert {
    padding: 1rem;
    font-size: 0.9rem;
  }

  .alert-dismissible .btn-close {
    padding: 0.75rem;
  }
}

/* ============================================
   PAGINATION - Mobile Adjustments
   ============================================ */

@media (max-width: 575px) {
  .pagination {
    font-size: 0.875rem;
  }

  .page-link {
    padding: 0.375rem 0.75rem;
  }

  /* Hide page numbers on very small screens, keep prev/next */
  .pagination .page-item:not(.page-item:first-child):not(.page-item:last-child) {
    display: none;
  }
}

/* ============================================
   LIVE SCORE PAGE - Specific Styles
   ============================================ */

@media (max-width: 575px) {
  /* Live score cards */
  .live-matches-grid .card-header h5 {
    font-size: 1rem;
  }

  .live-matches-grid .player-avatar i {
    font-size: 2rem !important;
  }

  .live-matches-grid .display-4 {
    font-size: 2rem;
  }

  .live-matches-grid .player1-name,
  .live-matches-grid .player2-name {
    font-size: 0.9rem;
  }

  /* Set scores display */
  .live-matches-grid .set-score-item {
    font-size: 0.85rem;
  }

  /* Tournament section */
  .tournament-section {
    padding: 1rem;
  }

  .tournament-section h3 {
    font-size: 1.25rem;
  }
}

/* ============================================
   TOURNAMENT PAGES - Responsive Cards
   ============================================ */

@media (max-width: 767px) {
  /* Tournament cards in grid */
  .tournament-card .card-title {
    font-size: 1.125rem;
  }

  .tournament-card .badge {
    font-size: 0.7rem;
  }

  /* Tournament details tabs */
  .nav-tabs {
    border-bottom: 2px solid var(--border-color);
  }

  .nav-tabs .nav-link {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  /* Tournament info grid */
  .tournament-info-item {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
  }
}

/* ============================================
   PLAYER DASHBOARD - Responsive Stats
   ============================================ */

@media (max-width: 575px) {
  /* Welcome card */
  .player-welcome-card .card-body {
    padding: 1.5rem 1rem;
  }

  /* Stats cards - 2 columns on mobile */
  .stats-card {
    margin-bottom: 1rem;
  }

  .stats-card .card-body {
    padding: 1rem;
  }

  .stats-card i {
    font-size: 1.5rem !important;
  }

  .stats-card h3 {
    font-size: 1.5rem;
  }

  .stats-card small {
    font-size: 0.75rem;
  }
}

/* ============================================
   LEADERBOARD - Responsive Table/Cards
   ============================================ */

@media (max-width: 767px) {
  /* Podium display */
  .podium-container {
    margin-bottom: 2rem;
  }

  .podium-item {
    margin-bottom: 1rem;
  }

  /* Leaderboard mobile cards */
  .leaderboard-mobile-card {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
  }

  .leaderboard-mobile-card:last-child {
    border-bottom: none;
  }

  .leaderboard-rank {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 50px;
  }

  .leaderboard-player-info {
    flex: 1;
  }

  .leaderboard-rating {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-blue);
  }
}

/* ============================================
   CHAT - Mobile Sidebar
   ============================================ */

@media (max-width: 767px) {
  /* Chat toggle button */
  .chat-toggle-btn {
    width: 100%;
    margin-bottom: 1rem;
  }

  /* Chat sidebar - mobile overlay */
  .chat-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    z-index: 1050;
    background: white;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
  }

  .chat-sidebar.show {
    left: 0;
  }

  /* Chat overlay backdrop */
  .chat-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
  }

  .chat-overlay.show {
    display: block;
  }

  /* Chat main area */
  .chat-main {
    height: calc(100vh - 200px);
    min-height: 400px;
  }

  /* Chat input */
  .chat-input textarea {
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 44px;
  }

  .chat-input .btn {
    min-width: 50px;
    min-height: 50px;
  }

  /* Chat messages */
  .chat-message {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .chat-message-content {
    font-size: 0.9rem;
  }
}

/* Desktop chat layout */
@media (min-width: 768px) {
  .chat-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 200px);
    gap: 1rem;
  }

  .chat-sidebar {
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
  }

  .chat-main {
    overflow-y: auto;
  }
}

/* ============================================
   BRACKETS - Mobile Scroll
   ============================================ */

@media (max-width: 767px) {
  .bracket-container {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
    margin: 0 -1rem; /* Expand to screen edges */
    padding: 0 1rem;
  }

  .bracket-inner {
    min-width: 800px; /* Force horizontal scroll */
  }

  /* Zoom controls for mobile brackets */
  .bracket-zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
  }

  .bracket-zoom-controls button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: none;
    background: var(--primary-blue);
    color: white;
    font-size: 1.25rem;
  }
}

/* ============================================
   UTILITY CLASSES - Mobile Specific
   ============================================ */

/* Hide on mobile */
@media (max-width: 575px) {
  .d-none-mobile {
    display: none !important;
  }
}

/* Show only on mobile */
.d-mobile-only {
  display: none !important;
}

@media (max-width: 575px) {
  .d-mobile-only {
    display: block !important;
  }

  .d-mobile-inline {
    display: inline !important;
  }

  .d-mobile-inline-block {
    display: inline-block !important;
  }

  .d-mobile-flex {
    display: flex !important;
  }
}

/* Full width on mobile */
@media (max-width: 575px) {
  .w-mobile-100 {
    width: 100% !important;
  }
}

/* Text alignment mobile utilities */
@media (max-width: 575px) {
  .text-mobile-center {
    text-align: center !important;
  }

  .text-mobile-start {
    text-align: left !important;
  }

  .text-mobile-end {
    text-align: right !important;
  }
}

/* Margin and padding mobile utilities */
@media (max-width: 575px) {
  .p-mobile-0 { padding: 0 !important; }
  .p-mobile-1 { padding: 0.25rem !important; }
  .p-mobile-2 { padding: 0.5rem !important; }
  .p-mobile-3 { padding: 1rem !important; }

  .m-mobile-0 { margin: 0 !important; }
  .m-mobile-1 { margin: 0.25rem !important; }
  .m-mobile-2 { margin: 0.5rem !important; }
  .m-mobile-3 { margin: 1rem !important; }

  .mb-mobile-0 { margin-bottom: 0 !important; }
  .mb-mobile-2 { margin-bottom: 0.5rem !important; }
  .mb-mobile-3 { margin-bottom: 1rem !important; }
  .mb-mobile-4 { margin-bottom: 1.5rem !important; }
}

/* ============================================
   ACCESSIBILITY - Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .chat-sidebar {
    transition: none !important;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .navbar,
  .footer,
  .btn,
  .chat-sidebar,
  .chat-toggle-btn {
    display: none !important;
  }

  .container {
    max-width: 100% !important;
  }

  .card {
    break-inside: avoid;
  }
}
