/**
 * mobile.css - Estilos responsive para dispositivos móviles
 * Cantoral RESUCITÓ - Camino Neocatecumenal
 * 
 * Breakpoints:
 * - 1024px: Tablets landscape
 * - 768px:  Tablets portrait
 * - 480px:  Móviles grandes
 * - 375px:  Móviles estándar
 * - 320px:  Móviles pequeños
 */

/* =====================================================
   VARIABLES MÓVILES
   ===================================================== */
:root {
    --mobile-header-height: 60px;
    --mobile-player-height: 70px;
    --mobile-sidebar-width: 280px;
    --mobile-touch-target: 44px;
    --mobile-padding: 16px;
    --mobile-gap: 12px;
}

/* =====================================================
   UTILIDADES MÓVILES
   ===================================================== */

/* Ocultar en móvil */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Mostrar solo en móvil */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: flex !important;
    }
}

/* Touch targets mínimos */
@media (max-width: 768px) {
    .touch-target {
        min-width: var(--mobile-touch-target);
        min-height: var(--mobile-touch-target);
    }
}

/* =====================================================
   SIDEBAR MÓVIL - COLAPSABLE
   ===================================================== */

/* Botón hamburguesa */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Botón cerrar sidebar - oculto por defecto */
.sidebar-close-btn {
    display: none;
}

/* Overlay del sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }
    
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }
    
    .sidebar-overlay.active {
        pointer-events: auto;
    }
    
    /* Sidebar colapsable */
    aside.sidebar,
    .sidebar {
        position: fixed !important;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--mobile-sidebar-width) !important;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999 !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    aside.sidebar.open,
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Ajustar main cuando sidebar está cerrado */
    main {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Botón cerrar sidebar */
    .sidebar-close-btn {
        display: flex;
        position: absolute;
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        border-radius: 50%;
        color: var(--text-primary);
        font-size: 18px;
        cursor: pointer;
        z-index: 10;
    }
}

/* =====================================================
   HEADER MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    .top-header {
        padding: 10px var(--mobile-padding);
        height: var(--mobile-header-height);
    }
    
    .top-header-container {
        gap: var(--mobile-gap);
    }
    
    .header-search-container {
        flex: 1;
        max-width: none;
    }
    
    .header-search-input {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .header-login-btn,
    .header-user-info {
        min-width: auto;
        padding: 10px 14px;
        font-size: 13px;
    }
    
    /* Ocultar texto en botón login, solo icono */
    .header-login-btn span {
        display: none;
    }
    
    .header-login-btn i {
        margin: 0;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .top-header {
        padding: 8px 12px;
    }
    
    .header-search-input {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* =====================================================
   PLAYER MÓVIL OPTIMIZADO
   ===================================================== */
@media (max-width: 768px) {
    .player {
        padding: 8px 16px;
        width: calc(100% - 24px);
        max-width: none;
        border-radius: 20px;
        bottom: 12px;
        left: 12px;
        right: 12px;
    }
    
    .player-horizontal {
        gap: 10px;
    }
    
    /* Info de la canción más compacta */
    .player-left {
        max-width: 35%;
        gap: 8px;
    }
    
    .track-artwork {
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 10px;
    }
    
    .track-info {
        min-width: 0;
    }
    
    .track-title {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .track-artist {
        font-size: 11px;
    }
    
    /* Like button */
    .track-like {
        display: none; /* Ocultar en móvil, mover a menú */
    }
    
    /* Controles centrales */
    .player-center {
        flex: 1;
        padding: 6px 12px;
        gap: 6px;
    }
    
    .player-controls {
        gap: 4px;
    }
    
    /* Botones de control más grandes para touch */
    .control-btn.small {
        width: var(--mobile-touch-target);
        height: var(--mobile-touch-target);
        font-size: 14px;
    }
    
    .control-btn.primary {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Ocultar controles secundarios */
    .control-btn.small:has(.fa-random),
    .control-btn.small:has(.fa-shuffle),
    .control-btn.small:has(.fa-redo),
    .control-btn.small:has(.fa-repeat),
    #shuffleBtn,
    #repeatBtn {
        display: none;
    }
    
    /* Barra de progreso */
    .progress-section {
        gap: 6px;
    }
    
    .time-display {
        font-size: 10px;
        min-width: 32px;
    }
    
    .progress-track {
        height: 6px; /* Más grueso para mejor touch */
    }
    
    .progress-thumb {
        width: 16px;
        height: 16px;
    }
    
    /* Panel derecho - ocultar volumen */
    .player-right {
        max-width: 80px;
        gap: 8px;
    }
    
    .volume-control {
        display: none;
    }
    
    /* Mostrar solo botón de karaoke y cola */
    .player-right .control-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .player {
        padding: 6px 12px;
        bottom: 8px;
        left: 8px;
        right: 8px;
        width: calc(100% - 16px);
        border-radius: 16px;
    }
    
    .player-left {
        max-width: 30%;
    }
    
    .track-artwork {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .track-title {
        font-size: 12px;
    }
    
    .track-artist {
        font-size: 10px;
    }
    
    .control-btn.primary {
        width: 46px;
        height: 46px;
        font-size: 18px;
    }
    
    .control-btn.small {
        width: 38px;
        height: 38px;
    }
    
    /* Ocultar prev/next en móviles muy pequeños */
    #prevBtn,
    #nextBtn {
        display: none;
    }
    
    .player-right {
        max-width: 60px;
    }
}

/* =====================================================
   CONTENIDO PRINCIPAL MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    main {
        padding: var(--mobile-padding);
        padding-top: calc(var(--mobile-header-height) + 16px);
        padding-bottom: calc(var(--mobile-player-height) + 24px);
    }
    
    /* Grid de canciones */
    .song-grid,
    .results-grid {
        grid-template-columns: 1fr;
        gap: var(--mobile-gap);
    }
    
    /* Cards de canciones */
    .song-card {
        padding: 12px;
        border-radius: 12px;
    }
    
    .song-card-cover {
        width: 50px;
        height: 50px;
    }
    
    .song-card-title {
        font-size: 14px;
    }
    
    .song-card-artist {
        font-size: 12px;
    }
}

/* =====================================================
   BIENVENIDA MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    .welcome-section {
        padding: var(--mobile-padding);
        padding-bottom: calc(var(--mobile-player-height) + 32px);
    }
    
    .welcome-container {
        gap: 16px;
        max-width: 100%;
    }
    
    .welcome-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
        line-height: 1.2;
    }
    
    .welcome-subtitle {
        font-size: clamp(0.9rem, 3vw, 1.1rem);
    }
    
    .welcome-features {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .feature-card {
        padding: 14px 12px;
    }
    
    .feature-icon {
        font-size: 24px;
    }
    
    .feature-title {
        font-size: 12px;
    }
    
    /* Botón login grande */
    .welcome-login-btn {
        padding: 14px 28px;
        font-size: 15px;
        min-height: var(--mobile-touch-target);
    }
}

@media (max-width: 480px) {
    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .feature-card {
        padding: 12px 10px;
    }
    
    .feature-icon {
        font-size: 20px;
    }
    
    .feature-title {
        font-size: 11px;
    }
}

/* =====================================================
   KARAOKE MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    .karaoke-fullscreen {
        padding: 16px;
    }
    
    .karaoke-header {
        padding: 12px 16px;
    }
    
    .karaoke-title {
        font-size: 18px;
    }
    
    .karaoke-artist {
        font-size: 14px;
    }
    
    /* Letras más grandes */
    .karaoke-lyrics-container {
        font-size: 20px;
        line-height: 1.6;
        padding: 20px;
    }
    
    .karaoke-current-line {
        font-size: 26px;
        font-weight: 600;
    }
    
    /* Controles de karaoke */
    .karaoke-controls {
        padding: 12px;
        gap: 8px;
    }
    
    .karaoke-control-btn {
        min-width: var(--mobile-touch-target);
        min-height: var(--mobile-touch-target);
        font-size: 14px;
    }
    
    /* Cerrar karaoke */
    .close-karaoke {
        width: var(--mobile-touch-target);
        height: var(--mobile-touch-target);
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .karaoke-lyrics-container {
        font-size: 18px;
        padding: 16px;
    }
    
    .karaoke-current-line {
        font-size: 22px;
    }
}

/* Orientación horizontal para karaoke */
@media (max-width: 768px) and (orientation: landscape) {
    .karaoke-fullscreen {
        padding: 8px 16px;
    }
    
    .karaoke-header {
        padding: 8px 12px;
    }
    
    .karaoke-cover {
        width: 60px;
        height: 60px;
    }
    
    .karaoke-lyrics-container {
        font-size: 22px;
    }
}

/* =====================================================
   MODALES Y OVERLAYS MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    /* Login overlay */
    .login-overlay-content,
    .modal-content {
        width: 90%;
        max-width: 360px;
        padding: 24px 20px;
        border-radius: 20px;
        margin: auto;
    }
    
    .login-overlay input,
    .modal input {
        padding: 14px 16px;
        font-size: 16px; /* Previene zoom en iOS */
        border-radius: 12px;
    }
    
    .login-overlay button,
    .modal button {
        padding: 14px 24px;
        font-size: 15px;
        min-height: var(--mobile-touch-target);
        border-radius: 12px;
    }
    
    /* Transport modal */
    .transport-modal-content {
        width: 95%;
        max-width: 340px;
    }
    
    /* Queue panel */
    .queue-panel {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        bottom: 0;
        right: 0;
        left: 0;
        max-height: 70vh;
    }
}

/* =====================================================
   RESULTADOS DE BÚSQUEDA MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    .search-results {
        padding: var(--mobile-padding);
    }
    
    .results-title {
        font-size: 18px;
        margin-bottom: 16px;
    }
    
    /* Vista de lista en móvil */
    .results-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .result-card {
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 12px;
        gap: 12px;
        border-radius: 12px;
    }
    
    .result-card-cover {
        width: 50px;
        height: 50px;
        min-width: 50px;
        border-radius: 8px;
    }
    
    .result-card-info {
        flex: 1;
        min-width: 0;
    }
    
    .result-card-title {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .result-card-artist {
        font-size: 12px;
    }
    
    .result-card-play {
        width: var(--mobile-touch-target);
        height: var(--mobile-touch-target);
        font-size: 16px;
    }
}

/* =====================================================
   SIDEBAR CONTENT MÓVIL
   ===================================================== */
@media (max-width: 1024px) {
    .sidebar-content {
        padding: 16px;
        padding-top: 60px; /* Espacio para botón cerrar */
    }
    
    .sidebar-section {
        margin-bottom: 20px;
    }
    
    .sidebar-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    /* Tags más grandes para touch */
    .tag-item {
        padding: 10px 16px;
        font-size: 13px;
        min-height: var(--mobile-touch-target);
        display: flex;
        align-items: center;
    }
    
    /* Recently played */
    .recently-played-item {
        padding: 10px;
        min-height: 56px;
    }
    
    .recently-played-cover {
        width: 44px;
        height: 44px;
    }
    
    .recently-played-title {
        font-size: 13px;
    }
    
    .recently-played-category {
        font-size: 11px;
    }
    
    .recently-played-play {
        width: 36px;
        height: 36px;
    }
}

/* =====================================================
   FEATURED CARD MÓVIL
   ===================================================== */
@media (max-width: 768px) {
    .featured-top-card {
        padding: 16px;
        border-radius: 16px;
        margin-bottom: 16px;
    }
    
    .featured-content {
        gap: 12px;
    }
    
    .featured-image {
        width: 80px;
        height: 80px;
        border-radius: 12px;
    }
    
    .featured-title {
        font-size: 16px;
    }
    
    .featured-subtitle {
        font-size: 12px;
    }
    
    .featured-btn {
        padding: 10px 20px;
        font-size: 13px;
        min-height: var(--mobile-touch-target);
    }
}

/* =====================================================
   ANIMACIONES REDUCIDAS PARA MÓVIL
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Reducir animaciones en móvil para mejor rendimiento */
@media (max-width: 768px) {
    .sidebar,
    .player,
    .modal-content,
    .login-overlay-content {
        transition-duration: 0.2s;
    }
    
    /* Deshabilitar backdrop-filter en móviles de gama baja */
    @supports not (backdrop-filter: blur(10px)) {
        .player,
        .sidebar,
        .modal-content {
            background: rgba(30, 30, 30, 0.98);
        }
    }
}

/* =====================================================
   SAFE AREAS (NOTCH, HOME INDICATOR)
   ===================================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .player {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        bottom: 0;
    }
    
    @media (max-width: 768px) {
        .player {
            bottom: env(safe-area-inset-bottom);
        }
        
        main {
            padding-bottom: calc(var(--mobile-player-height) + 24px + env(safe-area-inset-bottom));
        }
    }
}

/* =====================================================
   LANDSCAPE MODE ADJUSTMENTS
   ===================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-container {
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    
    .welcome-features {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .player {
        padding: 4px 16px;
    }
    
    .track-artwork {
        width: 36px;
        height: 36px;
    }
    
    .control-btn.primary {
        width: 40px;
        height: 40px;
    }
}

/* =====================================================
   DARK MODE ADJUSTMENTS FOR MOBILE
   ===================================================== */
@media (max-width: 768px) {
    /* Mejorar contraste en móvil */
    .track-title,
    .song-card-title,
    .result-card-title {
        color: #ffffff;
    }
    
    .track-artist,
    .song-card-artist,
    .result-card-artist {
        color: rgba(255, 255, 255, 0.7);
    }
}
