/* Mobile-First Responsive Styles for Football Manager */
/* Include this in all pages for consistent mobile optimization */

/* =================================
   BASE RESPONSIVE UTILITIES
   ================================= */

/* Ensure proper viewport scaling */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

/* =================================
   MOBILE NAVIGATION
   ================================= */

@media (max-width: 768px) {
  /* Responsive navigation - hide text, show icons only */
  .nav-text {
    display: none;
  }
  
  .nav-icon {
    font-size: 1.25rem;
  }
  
  /* Hamburger menu for main nav */
  .mobile-menu-button {
    display: block;
  }
  
  .desktop-nav {
    display: none;
  }
  
  .mobile-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
}

/* =================================
   RESPONSIVE TABLES
   ================================= */

@media (max-width: 768px) {
  /* Stack table rows as cards on mobile */
  .responsive-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .responsive-table table {
    min-width: 600px; /* Allow horizontal scroll */
  }
  
  /* Hide less important columns on mobile */
  .mobile-hide {
    display: none;
  }
  
  /* Reduce font size in tables */
  .responsive-table td,
  .responsive-table th {
    font-size: 0.75rem;
    padding: 0.5rem 0.25rem;
  }
}

/* Alternative: Card-based layout for mobile */
@media (max-width: 640px) {
  .table-card-mobile {
    display: block;
  }
  
  .table-card-mobile thead {
    display: none;
  }
  
  .table-card-mobile tbody {
    display: block;
  }
  
  .table-card-mobile tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    background: white;
  }
  
  .table-card-mobile td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border: none;
  }
  
  .table-card-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
  }
}

/* =================================
   RESPONSIVE GRIDS
   ================================= */

@media (max-width: 640px) {
  /* Force single column on small screens */
  .grid-responsive {
    grid-template-columns: 1fr !important;
  }
  
  /* 2 columns for medium grids */
  .grid-responsive-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* =================================
   RESPONSIVE MODALS
   ================================= */

@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 1rem;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-header {
    padding: 1rem;
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .modal-footer {
    padding: 1rem;
    flex-direction: column;
  }
  
  .modal-footer button {
    width: 100%;
    margin: 0.25rem 0;
  }
}

/* =================================
   RESPONSIVE BUTTONS
   ================================= */

@media (max-width: 640px) {
  /* Stack button groups vertically */
  .button-group-mobile {
    flex-direction: column;
    width: 100%;
  }
  
  .button-group-mobile button {
    width: 100%;
    margin: 0.25rem 0;
  }
  
  /* Reduce button padding on mobile */
  button, .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  /* Icon-only buttons on mobile */
  .btn-icon-only-mobile .btn-text {
    display: none;
  }
}

/* =================================
   RESPONSIVE CARDS
   ================================= */

@media (max-width: 768px) {
  .card {
    margin: 0.5rem;
    padding: 1rem;
  }
  
  .card-header {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .card-title {
    font-size: 1.25rem;
  }
  
  .card-actions {
    width: 100%;
    margin-top: 0.5rem;
  }
}

/* =================================
   RESPONSIVE FORMS
   ================================= */

@media (max-width: 640px) {
  /* Stack form inputs vertically */
  .form-row {
    flex-direction: column;
  }
  
  .form-group {
    width: 100%;
    margin-bottom: 1rem;
  }
  
  input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
  }
}

/* =================================
   RESPONSIVE TEXT
   ================================= */

@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.125rem; }
  h4 { font-size: 1rem; }
  
  .text-responsive-lg {
    font-size: 1rem;
  }
  
  .text-responsive-md {
    font-size: 0.875rem;
  }
  
  .text-responsive-sm {
    font-size: 0.75rem;
  }
}

/* =================================
   RESPONSIVE SPACING
   ================================= */

@media (max-width: 768px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .section-spacing {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
  }
  
  /* Reduce padding on mobile */
  .p-mobile-sm { padding: 0.5rem !important; }
  .p-mobile-md { padding: 1rem !important; }
  .px-mobile-sm { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
  .py-mobile-sm { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
  
  /* Reduce margins on mobile */
  .m-mobile-sm { margin: 0.5rem !important; }
  .mx-mobile-sm { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
  .my-mobile-sm { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
}

/* =================================
   TOUCH TARGETS
   ================================= */

/* Ensure all clickable elements are at least 44x44px (Apple HIG) */
@media (max-width: 768px) {
  button, a, input[type="checkbox"], input[type="radio"], .clickable {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Increase tap target for small icons */
  .icon-button {
    padding: 0.75rem;
  }
}

/* =================================
   RESPONSIVE STATS/BADGES
   ================================= */

@media (max-width: 768px) {
  .stat-card {
    padding: 1rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .stat-label {
    font-size: 0.75rem;
  }
  
  .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* =================================
   RESPONSIVE IMAGES
   ================================= */

@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
  }
  
  .player-image, .badge-image {
    max-width: 60px;
    max-height: 60px;
  }
}

/* =================================
   FIXED MOBILE NAVIGATION BAR
   ================================= */

@media (max-width: 768px) {
  /* Bottom navigation bar for mobile */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    z-index: 50;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  }
  
  .mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.75rem;
  }
  
  .mobile-bottom-nav a.active {
    color: #667eea;
  }
  
  .mobile-bottom-nav i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
  }
  
  /* Add padding to body to prevent content from being hidden by bottom nav */
  body.has-mobile-nav {
    padding-bottom: 70px;
  }
}

/* =================================
   RESPONSIVE OVERFLOW HANDLING
   ================================= */

@media (max-width: 768px) {
  /* Prevent horizontal overflow */
  .overflow-x-mobile {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Hide scrollbars but keep functionality */
  .overflow-x-mobile::-webkit-scrollbar {
    height: 4px;
  }
  
  .overflow-x-mobile::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
  }
}

/* =================================
   LANDSCAPE ORIENTATION
   ================================= */

@media (max-width: 768px) and (orientation: landscape) {
  /* Reduce header height in landscape */
  .gradient-bg {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  
  /* Smaller modals in landscape */
  .modal-content {
    max-height: 80vh;
  }
}

/* =================================
   SAFE AREA INSETS (iOS Notch)
   ================================= */

@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .mobile-bottom-nav {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
}

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

@media (max-width: 768px) {
  .loading-spinner {
    width: 40px;
    height: 40px;
  }
  
  .skeleton-loader {
    height: 60px;
    margin-bottom: 0.5rem;
  }
}

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

/* Larger focus indicators on mobile */
@media (max-width: 768px) {
  button:focus, a:focus, input:focus, select:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
  }
}

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

@media print {
  .mobile-bottom-nav,
  .gradient-bg,
  button,
  .no-print {
    display: none !important;
  }
  
  body {
    padding-bottom: 0;
  }
}

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

/* Hide on mobile */
.hidden-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hidden-mobile {
    display: initial;
  }
}

/* Show only on mobile */
.visible-mobile {
  display: initial;
}

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

/* Responsive flex direction */
@media (max-width: 768px) {
  .flex-col-mobile {
    flex-direction: column;
  }
  
  .flex-wrap-mobile {
    flex-wrap: wrap;
  }
}

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