/* Responsive Design */

/* Large Desktop */
@media (min-width: 1440px) {
    .main-container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Ajusté pour la taille réduite */
    }
    
    .player-panel {
        width: var(--player-width);
    }
    
    .nav-menu {
        width: var(--nav-width);
    }
}

/* Desktop */
@media (max-width: 1200px) {
    .player-panel {
        width: var(--player-min-width);
    }
    
    .nav-menu {
        width: 200px;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* Ajusté pour la taille réduite */
    }
    
    .track-list-header,
    .track-list-item {
        grid-template-columns: 40px 1fr 180px 180px 80px 40px;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }
}

/* Tablet Landscape */
@media (max-width: 1024px) {
    .header {
        padding: 0 1.5rem;
    }
    
    .search-section {
        max-width: 300px;
    }
    
    .player-panel {
        width: var(--player-min-width);
    }
    
    .nav-menu {
        width: 180px;
    }
    
    .content-area {
        padding: 1.5rem;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); /* Ajusté pour la taille réduite */
        gap: 0.75rem; /* Réduit */
    }
    
    .now-playing {
        padding: 1.5rem;
    }
    
    .player-controls {
        padding: 1.5rem;
    }
    
    .queue-section {
        padding: 1rem 1.5rem;
    }
    
    .track-list-header,
    .track-list-item {
        grid-template-columns: 40px 1fr 150px 60px 40px;
        gap: 0.5rem;
    }
    
    .track-album-list {
        display: none;
    }
}

/* Tablet Portrait & Mobile Landscape */
@media (max-width: 968px) {
    :root {
        --header-height: 70px;
    }
    
    .header {
        height: var(--header-height);
        padding: 0 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .logo-section {
        order: 1;
    }
    
    .user-section {
        order: 2;
    }
    
    .search-section {
        order: 3;
        width: 100%;
        max-width: none;
    }
    
    .user-name {
        display: none;
    }
    
    .upload-btn span {
        display: none;
    }
    
    .upload-btn {
        width: 44px;
        height: 44px;
        padding: 0;
        justify-content: center;
    }
    
    /* Main layout becomes vertical */
    .main-container {
        flex-direction: column;
        height: calc(100vh - var(--header-height) - 120px);
    }
    
    .nav-menu {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow-x: auto;
    }
    
    .nav-list {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        overflow-x: auto;
    }
    
    .nav-item {
        flex-shrink: 0;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 20px;
        white-space: nowrap;
        font-size: 0.9rem;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
    }
    
    .nav-item.active .nav-link {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }
    
    .nav-item.active .nav-link::before {
        display: none;
    }
    
    .content-area {
        padding: 1rem;
        height: 100%;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* Ajusté pour la taille réduite */
        gap: 0.5rem; /* Réduit */
    }
    
    .track-card {
        padding: 0.5rem; /* Réduit */
    }
    
    .track-card-cover {
        height: 80px; /* Réduit */
        aspect-ratio: 1;
    }
    
    /* Player becomes bottom bar */
    .player-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 120px;
        z-index: 1000;
        border-left: none;
        border-top: 1px solid var(--border-color);
        background: var(--surface-color);
        backdrop-filter: blur(10px);
    }
    
    .now-playing {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1rem;
        border-bottom: none;
        background: transparent;
        flex: 1;
    }
    
    .track-cover {
        width: 50px;
        height: 50px;
        margin: 0;
        border-radius: 6px;
    }
    
    .play-overlay,
    .play-btn-large {
        display: none;
    }
    
    .track-info {
        flex: 1;
        text-align: left;
        min-width: 0;
    }
    
    .track-title {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    .track-artist {
        font-size: 0.8rem;
    }
    
    .player-controls {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0 1rem;
        flex-shrink: 0;
    }
    
    .control-buttons {
        display: flex;
        gap: 0.5rem;
        margin: 0;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    .play-pause {
        width: 44px;
        height: 44px;
    }
    
    .progress-section {
        display: none;
    }
    
    .volume-section {
        display: none;
    }
    
    .queue-section {
        display: none;
    }
    
    /* Boutons favoris en mobile */
    .track-card-actions {
        opacity: 1; /* Toujours visible en mobile */
        top: 0.25rem;
        right: 0.25rem;
    }
    
    .favorite-btn {
        width: 20px;
        height: 20px;
    }
    
    .favorite-btn svg {
        width: 12px;
        height: 12px;
    }
    
    /* List view adjustments */
    .track-list-header {
        display: none;
    }
    
    .track-list-item {
        grid-template-columns: 40px 1fr 40px;
        gap: 1rem;
        padding: 1rem;
    }
    
    .track-album-list,
    .track-duration {
        display: none;
    }
    
    .track-actions {
        display: flex;
    }
}

/* Mobile Portrait */
@media (max-width: 640px) {
    .header {
        padding: 0 0.75rem;
    }
    
    .brand-name {
        font-size: 1.25rem;
    }
    
    .search-bar {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
    
    .content-area {
        padding: 0.75rem;
    }
    
    .content-title {
        font-size: 1.5rem;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); /* Ajusté pour la taille réduite */
        gap: 0.5rem;
    }
    
    .track-card {
        padding: 0.5rem;
    }
    
    .track-card-cover {
        height: 70px; /* Réduit */
        aspect-ratio: 1;
    }
    
    .track-card-title {
        font-size: 0.8rem; /* Réduit */
    }
    
    .track-card-artist,
    .track-card-album {
        font-size: 0.7rem; /* Réduit */
    }
    
    .now-playing {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .track-cover {
        width: 44px;
        height: 44px;
    }
    
    .track-title {
        font-size: 0.85rem;
    }
    
    .track-artist {
        font-size: 0.75rem;
    }
    
    .player-controls {
        padding: 0 0.75rem;
        gap: 0.75rem;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
    }
    
    .play-pause {
        width: 40px;
        height: 40px;
    }
    
    .player-panel {
        height: 110px;
    }
    
    .main-container {
        height: calc(100vh - var(--header-height) - 110px);
    }
    
    /* Boutons favoris très petits en mobile */
    .track-card-actions {
        top: 0.2rem;
        right: 0.2rem;
    }
    
    .favorite-btn {
        width: 18px;
        height: 18px;
    }
    
    .favorite-btn svg {
        width: 10px;
        height: 10px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* Ajusté pour la taille réduite */
    }
    
    .track-card-cover {
        height: 60px; /* Réduit */
        aspect-ratio: 1;
    }
    
    .track-card-title {
        font-size: 0.75rem; /* Réduit */
    }
    
    .track-card-artist,
    .track-card-album {
        font-size: 0.65rem; /* Réduit */
    }
    
    .nav-link svg {
        display: none;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state svg {
        width: 48px;
        height: 48px;
    }
    
    .empty-state h3 {
        font-size: 1.25rem;
    }
    
    .empty-state p {
        font-size: 0.9rem;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 968px) and (orientation: landscape) {
    .header {
        height: 60px;
        --header-height: 60px;
    }
    
    .main-container {
        height: calc(100vh - 60px - 100px);
    }
    
    .player-panel {
        height: 100px;
    }
    
    .now-playing {
        padding: 0.5rem 1rem;
    }
    
    .track-cover {
        width: 40px;
        height: 40px;
    }
    
    .player-controls {
        padding: 0 1rem;
    }
    
    .control-btn {
        width: 30px;
        height: 30px;
    }
    
    .play-pause {
        width: 36px;
        height: 36px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .cover-image,
    .track-card-cover img,
    .album-card-cover img,
    .queue-item-cover img,
    .user-avatar {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .playing-bar {
        animation: none !important;
    }
    
    .loading-card {
        animation: none !important;
    }
}

/* Dark mode adjustments for better contrast on mobile */
@media (max-width: 968px) {
    .player-panel {
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .nav-link {
        backdrop-filter: blur(8px);
    }
    
    .track-card {
        backdrop-filter: blur(8px);
    }
}

/* Print styles */
@media print {
    .header,
    .player-panel,
    .nav-menu,
    .modal-overlay {
        display: none !important;
    }
    
    .main-container {
        flex-direction: column;
    }
    
    .content-area {
        padding: 0;
        width: 100%;
    }
    
    .track-card,
    .album-card {
        break-inside: avoid;
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .content-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}