/* ===================================
   MOBILE RESPONSIVE STYLES
   =================================== */

/* Tablet and Small Desktop (768px - 1024px) */
@media (max-width: 1024px) {
  .container {
    max-width: 100%;
    padding: 0 16px;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

/* Mobile Landscape and Tablet Portrait (max-width: 768px) */
@media (max-width: 768px) {
  /* General Layout */
  .container {
    padding: 0 16px;
  }
  
  .page-content {
    padding: 16px 0;
  }
  
  .page-container {
    padding: 16px;
  }
  
  /* Navigation */
  .navbar-container {
    height: 56px;
    padding: 0 16px;
  }
  
  .navbar-brand {
    font-size: 1.1rem;
  }
  
  .navbar-menu {
    display: none;
  }
  
  .navbar-mobile-menu {
    display: block;
  }
  
  /* Page Header */
  .page-header {
    margin-bottom: 20px;
    padding-left: 12px;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .page-header-title {
    margin-bottom: 8px;
  }
  
  .page-header h1 {
    font-size: 1.5rem;
  }
  
  .page-header-icon {
    font-size: 28px;
    margin-right: 12px;
  }
  
  .page-header-subtitle {
    margin-left: 0;
    font-size: 0.875rem;
  }
  
  .header-icon {
    width: 48px;
    height: 48px;
    margin-right: 12px;
  }
  
  .header-icon .material-icons {
    font-size: 24px;
  }
  
  .header-text h1 {
    font-size: 1.3rem;
  }
  
  .header-text p {
    font-size: 0.85rem;
  }
  
  /* Search Card - CORRETTO */
  .search-card {
    padding: 20px;
    margin-bottom: 24px;
  }
  
  .search-inputs {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: 100%;
  }
  
  .search-field-container {
    width: 100%;
    position: relative;
  }
  
  .search-field {
    height: 52px;
    padding: 0 16px;
    width: 130%;
    border-radius: 10px;
    margin-left: -30px;
  }
  
  .search-field .material-icons {
    font-size: 20px;
    margin-right: 10px;
  }
  
  .search-field input {
    font-size: 1rem;
    width: 100%;
  }
  
  /* Custom Select Container */
  .custom-select-container {
    width: auto; 
    margin: 0 0 0 auto; 
    min-width: auto;
  }
  
  .selected-platform {
    width: auto;
    min-width: 120px; 
    height: 52px;
    margin: 0;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 10px;
  }
  
  .platform-text {
    font-size: 1rem;
  }
  
  .platform-options {
    left: 0;
    right: 0;
    width: 100%;
  }
  
  /* Search Button - CORRETTO */
  .search-button {
    width: 100%;
    height: 52px;
    margin: 0;
    border-radius: 10px;
    font-size: 1.1rem;
  }
  
  .search-button .material-icons {
    font-size: 24px;
  }
  
  /* Platform Select (se usato) */
  .platform-select-container {
    width: 100%;
    margin: 0;
  }
  
  .platform-select-container select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
  }
  
  /* Recent Searches Dropdown */
  .recent-searches-dropdown {
    max-height: 300px;
    margin-top: 8px;
    border-radius: 10px;
  }
  
  .dropdown-header {
    padding: 12px 16px;
    font-size: 0.85rem;
  }
  
  .recent-search-item {
    padding: 12px 16px;
  }
  
  .search-item-avatar {
    width: 40px;
    height: 40px;
    margin-right: 12px;
  }
  
  .search-item-name {
    font-size: 0.95rem;
  }
  
  .search-item-platform {
    font-size: 0.8rem;
  }
  
  .search-item-delete {
    width: 36px;
    height: 36px;
  }
  
  /* Player Info Card */
  .player-info-content {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
  }
  
  .player-profile {
    width: 100%;
    margin-bottom: 20px;
  }
  
  .player-avatar {
    width: 64px;
    height: 64px;
  }
  
  .player-avatar .material-icons {
    font-size: 32px;
  }
  
  .player-username {
    font-size: 1.4rem;
  }
  
  .player-platform {
    font-size: 0.9rem;
  }
  
  .player-rank {
    width: 100%;
    flex-direction: row;
    margin-left: 0;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
  }
  
  .rank-badge {
    width: 60px;
    height: 60px;
    margin-bottom: 0;
  }
  
  .rank-value {
    font-size: 1.3rem;
  }
  
  .player-stats-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 16px 20px;
  }
  
  .stat-label {
    font-size: 0.8rem;
  }
  
  .stat-value {
    font-size: 1.4rem;
  }
  
  /* Tabs */
  .tabs-container {
    margin-bottom: 20px;
  }
  
  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .tabs::-webkit-scrollbar {
    display: none;
  }
  
  .tab {
    padding: 14px 20px;
    white-space: nowrap;
    min-width: 120px;
    font-size: 0.95rem;
  }
  
  /* Cards */
  .card {
    margin-bottom: 16px;
  }
  
  .card-content {
    padding: 20px;
  }
  
  .card-title {
    font-size: 1.15rem;
  }
  
  .card-header {
    margin-bottom: 16px;
  }
  
  .card-header h3 {
    font-size: 1.15rem;
  }
  
  /* Grids */
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .rank-info-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  /* Chart */
  .chart-container {
    height: 320px;
  }
  
  #rank-chart-container {
    padding: 16px;
  }
  
  /* Matches List */
  .matches-list {
    max-height: 450px;
  }
  
  .match-item {
    padding: 16px;
    flex-wrap: nowrap;
  }
  
  .match-rank {
    margin-right: 12px;
  }
  
  .match-rank-icon {
    width: 48px;
    height: 48px;
  }
  
  .rank-placeholder {
    width: 48px;
    height: 48px;
  }
  
  .match-info {
    flex: 1;
    min-width: 0;
  }
  
  .match-rank-name {
    font-size: 1rem;
  }
  
  .match-timestamp {
    font-size: 0.85rem;
  }
  
  .match-mmr {
    text-align: right;
  }
  
  .match-mmr-value {
    font-size: 1rem;
  }
  
  .match-mmr-change {
    font-size: 0.85rem;
  }
  
  /* Dialogs */
  .dialog {
    width: 92%;
    max-width: none;
    margin: 16px;
  }
  
  .dialog-title {
    padding: 20px;
    font-size: 1.2rem;
  }
  
  .dialog-content {
    padding: 20px;
  }
  
  .dialog-actions {
    padding: 16px 20px;
    flex-direction: column-reverse;
    gap: 12px;
  }
  
  .dialog-actions .btn {
    width: 100%;
  }
  
  /* Buttons */
  .btn {
    padding: 12px 20px;
    font-size: 0.95rem;
    min-height: 48px;
  }
  
  .btn .material-icons {
    font-size: 20px;
  }
  
  /* Chips */
  .chip {
    font-size: 0.75rem;
    padding: 4px 10px;
  }
  
  /* Platform Items */
  .platform-item {
    padding: 16px;
  }
  
  .platform-icon {
    width: 40px;
    height: 40px;
  }
  
  .platform-name {
    font-size: 1rem;
  }
  
  .platform-type {
    font-size: 0.85rem;
  }
  
  /* Pagination */
  .pagination {
    gap: 6px;
  }
  
  .pagination-button {
    width: 36px;
    height: 36px;
  }
  
  .pagination-info {
    padding: 0 12px;
    font-size: 0.9rem;
  }
  
  /* Footer */
  .site-footer {
    padding: 20px 0;
  }
  
  .footer-text {
    font-size: 0.85rem;
  }
  
  /* Error Display */
  .error-message {
    padding: 16px;
    font-size: 0.9rem;
  }
  
  /* Loading */
  .loading-container {
    padding: 32px 0;
  }
  
  .loading-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
  }
}

/* Mobile Portrait (max-width: 480px) */
@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
  
  .page-container {
    padding: 12px;
  }
  
  /* Header */
  .page-header h1 {
    font-size: 1.3rem;
  }
  
  .page-header-icon {
    font-size: 24px;
    margin-right: 10px;
  }
  
  .header-icon {
    width: 40px;
    height: 40px;
  }
  
  .header-icon .material-icons {
    font-size: 20px;
  }
  
  .header-text h1 {
    font-size: 1.15rem;
  }
  
  .header-text p {
    font-size: 0.8rem;
  }
  
  /* Search Card */
  .search-card {
    padding: 16px;
  }
  
  .search-field {
    height: 48px;
    padding: 0 12px;
  }
  
  .search-field input {
    font-size: 0.95rem;
  }
  
  .selected-platform {
    height: 48px;
    padding: 0 12px;
    min-width: 110px;
  }
  
  .search-button {
    height: 48px;
  }
  
  /* Player Info */
  .player-info-content {
    padding: 16px;
  }
  
  .player-avatar {
    width: 56px;
    height: 56px;
  }
  
  .player-avatar .material-icons {
    font-size: 28px;
  }
  
  .player-username {
    font-size: 1.25rem;
  }
  
  .player-platform {
    font-size: 0.85rem;
  }
  
  .rank-badge {
    width: 52px;
    height: 52px;
  }
  
  .rank-value {
    font-size: 1.15rem;
  }
  
  .player-stats-summary {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 16px;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  /* Tabs */
  .tab {
    padding: 12px 16px;
    min-width: 100px;
    font-size: 0.9rem;
  }
  
  /* Cards */
  .card-content {
    padding: 16px;
  }
  
  .card-title {
    font-size: 1.05rem;
  }
  
  .card-header h3 {
    font-size: 1.05rem;
  }
  
  /* Chart */
  .chart-container {
    height: 280px;
  }
  
  #rank-chart-container {
    padding: 12px;
  }
  
  /* Matches */
  .match-item {
    padding: 12px;
  }
  
  .match-rank-icon {
    width: 40px;
    height: 40px;
  }
  
  .rank-placeholder {
    width: 40px;
    height: 40px;
  }
  
  .match-rank-name {
    font-size: 0.95rem;
  }
  
  .match-timestamp {
    font-size: 0.8rem;
  }
  
  .match-mmr-value {
    font-size: 0.95rem;
  }
  
  /* Buttons */
  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
  }
  
  /* Recent Searches */
  .recent-search-item {
    padding: 10px 12px;
  }
  
  .search-item-avatar {
    width: 36px;
    height: 36px;
  }
  
  .search-item-name {
    font-size: 0.9rem;
  }
  
  .search-item-platform {
    font-size: 0.75rem;
  }
  
  /* Dialog */
  .dialog {
    width: 94%;
    margin: 12px;
  }
  
  .dialog-title {
    padding: 16px;
    font-size: 1.1rem;
  }
  
  .dialog-content {
    padding: 16px;
  }
  
  .dialog-actions {
    padding: 12px 16px;
  }
}

/* Landscape Orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .page-content {
    padding: 12px 0;
  }
  
  .page-header {
    margin-bottom: 12px;
  }
  
  .search-card {
    padding: 12px;
    margin-bottom: 16px;
  }
  
  .player-info-content {
    padding: 12px;
  }
  
  .player-stats-summary {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .chart-container {
    height: 220px;
  }
  
  .matches-list {
    max-height: 280px;
  }
  
  .dialog {
    max-height: 95vh;
  }
}

/* Touch Device Enhancements */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .btn {
    min-height: 48px;
  }
  
  .tab {
    min-height: 48px;
  }
  
  .navbar-link {
    min-height: 48px;
  }
  
  .recent-search-item {
    min-height: 56px;
  }
  
  .platform-option {
    min-height: 52px;
  }
  
  .match-item {
    min-height: 64px;
  }
  
  /* Remove hover effects */
  .card:hover {
    transform: none;
    box-shadow: var(--shadow-md);
  }
  
  .btn:hover {
    transform: none;
  }
  
  .search-button:hover {
    transform: none;
  }
  
  /* Active states */
  .btn:active {
    transform: scale(0.97);
    opacity: 0.9;
  }
  
  .tab:active {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .recent-search-item:active {
    background-color: rgba(255, 255, 255, 0.12);
  }
  
  .search-button:active {
    transform: scale(0.96);
  }
}

/* iOS Safari Safe Area */
@supports (-webkit-touch-callout: none) {
  .mobile-menu {
    height: calc(100vh - 64px - env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .dialog {
    max-height: calc(90vh - env(safe-area-inset-bottom));
    margin-bottom: env(safe-area-inset-bottom);
  }
  
  .site-footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* OLED Dark Mode Optimization */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .app-background {
    background-color: #000;
  }
  
  .navbar {
    background-color: #0d0d0d;
  }
  
  .card {
    background-color: #121212;
  }
  
  .search-field {
    background-color: #0d0d0d;
  }
}
