/* ====================================
   Responsive Design
   Mobile & Tablet Optimizations
   ==================================== */

/* ========== Tablet (≤1024px) ========== */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
    }
    
    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .player-container {
        grid-template-columns: 0.8fr 2fr 0.8fr;
    }
}

/* ========== Tablet Small (≤768px) ========== */
@media (max-width: 768px) {
    /* Hide desktop sidebar */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    body.sidebar-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 99;
    }
    
    /* Adjust main content */
    .main-content {
        margin-left: 0;
        padding: var(--spacing-lg) var(--spacing-md);
        padding-bottom: calc(var(--player-height) + var(--bottom-nav-height) + var(--spacing-lg));
    }
    
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Hide desktop search on small screens */
    .navbar-search {
        display: none;
    }
    
    /* Adjust navbar */
    .navbar-container {
        padding: 0 var(--spacing-md);
        justify-content: space-between;
    }
    
    .navbar-brand {
        flex: 1;
    }
    
    .navbar-right {
        gap: var(--spacing-sm);
    }
    
    /* Hide some nav icons on mobile */
    .nav-icon-btn {
        display: none;
    }
    
    .user-menu .nav-icon-btn {
        display: flex;
    }
    
    /* Show bottom navigation */
    .bottom-nav {
        display: flex;
    }
    
    /* Hero banner adjustments */
    .hero-banner {
        padding: 40px 24px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-actions {
        flex-direction: column;
    }
    
    .btn-hero-primary,
    .btn-hero-outline {
        width: 100%;
        justify-content: center;
    }
    
    .hero-decoration {
        display: none;
    }
    
    /* Playlist grid */
    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--spacing-md);
    }
    
    /* Song table - hide some columns */
    .song-table th:nth-child(4), /* Album */
    .song-table td:nth-child(4) {
        display: none;
    }
    
    .song-table th:nth-child(6), /* Plays */
    .song-table td:nth-child(6) {
        display: none;
    }
    
    /* Adjust section headers */
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    /* Player adjustments */
    .player-container {
        grid-template-columns: 1fr;
        gap: 0;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .player-song-info {
        grid-row: 1;
        margin-bottom: var(--spacing-sm);
    }
    
    .player-controls {
        grid-row: 2;
        width: 100%;
    }
    
    .player-extras {
        display: none; /* Hide on mobile, show in fullscreen player */
    }
    
    .control-buttons {
        gap: var(--spacing-sm);
    }
    
    .btn-control {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .btn-play-pause {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .player-thumbnail img {
        width: 50px;
        height: 50px;
    }
    
    /* Scroll to top button */
    .scroll-top-btn {
        bottom: calc(var(--player-height) + var(--bottom-nav-height) + 10px);
        right: 10px;
        width: 42px;
        height: 42px;
    }
    
    /* Toast notifications */
    .toast {
        right: 10px;
        left: 10px;
        min-width: auto;
    }
}

/* ========== Mobile (≤480px) ========== */
@media (max-width: 480px) {
    /* Navbar */
    .navbar-brand a {
        font-size: 1.25rem;
    }
    
    .navbar-brand .brand-name {
        display: none;
    }
    
    /* Hero banner */
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
    }
    
    .btn-hero-primary,
    .btn-hero-outline {
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    /* Content sections */
    .content-section {
        margin-bottom: 32px;
    }
    
    .section-header {
        margin-bottom: var(--spacing-md);
    }
    
    .section-header h2 {
        font-size: 1.25rem;
    }
    
    /* Playlist grid */
    .playlist-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .playlist-card {
        padding: var(--spacing-sm);
    }
    
    /* Song table */
    .song-table th,
    .song-table td {
        padding: var(--spacing-sm);
        font-size: 0.85rem;
    }
    
    .song-table th:nth-child(1), /* Number */
    .song-table td:nth-child(1) {
        display: none;
    }
    
    .song-thumbnail img {
        width: 40px;
        height: 40px;
    }
    
    .song-title {
        font-size: 0.9rem;
    }
    
    .song-artist {
        font-size: 0.8rem;
    }
    
    .song-duration {
        font-size: 0.8rem;
    }
    
    .song-actions {
        gap: 4px;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    /* Horizontal scroll cards */
    .song-cards {
        gap: var(--spacing-md);
    }
    
    .song-card {
        flex: 0 0 140px;
        padding: var(--spacing-sm);
    }
    
    /* Player */
    .music-player {
        height: 80px;
    }
    
    .player-song-info {
        margin-bottom: 6px;
    }
    
    .player-thumbnail img {
        width: 44px;
        height: 44px;
    }
    
    .player-title {
        font-size: 0.85rem;
    }
    
    .player-artist {
        font-size: 0.75rem;
    }
    
    .control-buttons {
        gap: 8px;
    }
    
    .btn-control {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
    
    .btn-play-pause {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }
    
    .time-current,
    .time-duration {
        font-size: 0.7rem;
        min-width: 35px;
    }
    
    /* Bottom nav */
    .bottom-nav {
        height: 55px;
    }
    
    .bottom-nav-item {
        font-size: 0.65rem;
    }
    
    .bottom-nav-item i {
        font-size: 1.2rem;
    }
    
    /* Modals and dropdowns */
    .user-dropdown {
        right: -10px;
        min-width: 200px;
    }
    
    .dropdown-item {
        padding: 10px var(--spacing-md);
        font-size: 0.9rem;
    }
    
    /* Queue and lyrics panels */
    .queue-modal,
    .lyrics-panel {
        width: 100%;
        max-width: 100%;
        left: 0;
        border-radius: 0;
    }
}

/* ========== Landscape Mobile ========== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-banner {
        padding: 30px 24px;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: var(--spacing-md);
    }
    
    .music-player {
        height: 70px;
    }
    
    .player-song-info {
        margin-bottom: 4px;
    }
    
    .control-buttons {
        gap: 6px;
    }
}

/* ========== Large Desktop (≥1440px) ========== */
@media (min-width: 1440px) {
    .main-content {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
        padding-left: calc(var(--sidebar-width) + var(--spacing-xl));
    }
    
    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .hero-title {
        font-size: 3.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.35rem;
    }
}

/* ========== Print Styles ========== */
@media print {
    .navbar,
    .sidebar,
    .music-player,
    .bottom-nav,
    .scroll-top-btn,
    .toast {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* ========== High Contrast Mode ========== */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1A1A1A;
        --text-primary: #FFFFFF;
        --border-color: rgba(255, 255, 255, 0.3);
    }
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== Custom Scrollbar ========== */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-secondary);
}
