@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    padding: 40px 24px;
}

.container { max-width: 1400px; margin: 0 auto; }

/* Login Screen */
.login-screen {
    max-width: 500px;
    margin: 80px auto;
    background: rgba(255,255,255,0.98);
    border-radius: 32px;
    padding: 48px 40px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-screen h1 {
    font-size: 42px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.login-screen h3 { color: #666; font-weight: 400; margin-bottom: 32px; }

.login-form input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    text-align: center;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.login-form button {
    width: 100%;
    padding: 16px;
    margin-top: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-form button:hover { transform: translateY(-2px); box-shadow: 0 10px 25px -5px rgba(102,126,234,0.4); }

.user-list { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e0e0e0; }
.user-list h4 { color: #888; margin-bottom: 16px; }
#existingUsers { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.user-btn {
    padding: 8px 20px;
    background: #f5f5f5;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-btn:hover { background: #667eea; color: white; }

/* Main Player */
#playerScreen { animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 28px;
    background: linear-gradient(135deg, #fff 0%, #a0aec0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255,255,255,0.1);
    padding: 8px 20px;
    border-radius: 40px;
}

#currentUserDisplay { color: white; font-weight: 500; }

.logout-btn {
    background: rgba(229,62,62,0.8);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 30px;
    cursor: pointer;
}

.logout-btn:hover { background: #e53e3e; }

.status-bar {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

#saveStatus { color: #a0aec0; font-size: 14px; }

.status-bar button, #installBtn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.status-bar button:hover, #installBtn:hover { background: rgba(255,255,255,0.3); transform: translateY(-1px); }
#installBtn { background: #48bb78; }

.add-section {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.add-section input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    background: rgba(255,255,255,0.95);
}

.add-section input:focus { outline: none; border-color: #667eea; }

.add-section button {
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.add-section button:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -5px rgba(102,126,234,0.4); }

#player { display: none; }

/* Search Section */
.search-section {
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    margin-bottom: 24px;
    overflow: hidden;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    color: white;
    font-weight: 500;
}

.search-header:hover { background: rgba(255,255,255,0.05); }

.search-arrow { transition: transform 0.3s; font-size: 12px; }
.search-arrow.open { transform: rotate(180deg); }

.search-panel { padding: 0 20px 20px 20px; }

.search-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    background: rgba(255,255,255,0.95);
}

.search-input-group button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
}

.search-results { max-height: 400px; overflow-y: auto; }

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin: 8px 0;
    background: rgba(255,255,255,0.08);
    border-radius: 14px;
    transition: all 0.2s;
}

.search-result-item:hover { background: rgba(255,255,255,0.15); transform: translateX(5px); }

.search-result-thumb {
    width: 80px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
}

.search-result-info { flex: 1; }
.search-result-title { color: white; font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.search-result-channel { color: #a0aec0; font-size: 12px; }

.search-result-add {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
}

.loading-results, .no-results { text-align: center; padding: 20px; color: #a0aec0; }

/* Player Controls */
.player-controls {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 28px;
    margin-bottom: 32px;
    border: 1px solid rgba(255,255,255,0.2);
}

.now-playing { text-align: center; margin-bottom: 24px; }
.now-playing span:first-child { font-size: 22px; font-weight: 700; color: white; display: block; margin-bottom: 6px; }
.now-playing span:last-child { color: #a0aec0; font-size: 15px; }

.progress-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.progress-bar span { color: white; font-size: 13px; min-width: 45px; }
.progress-bar input { flex: 1; height: 6px; border-radius: 10px; background: rgba(255,255,255,0.2); -webkit-appearance: none; }
.progress-bar input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: white; cursor: pointer; }

.buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.buttons button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 26px;
    cursor: pointer;
    transition: all 0.3s;
}

.buttons button:hover { transform: scale(1.08); }
#repeatBtn.active, #shuffleBtn.active { background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); }

.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.volume-control span { color: white; font-size: 18px; }
.volume-control input { flex: 1; height: 5px; border-radius: 5px; background: rgba(255,255,255,0.2); -webkit-appearance: none; }
.volume-control input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: white; cursor: pointer; }

/* Playlist */
.playlist-section {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 24px;
}

.playlist-section h3 { display: inline-block; color: white; font-size: 20px; margin-bottom: 20px; }
#playlistCount { font-size: 14px; color: #a0aec0; }
.clear-btn { float: right; background: rgba(229,62,62,0.8); color: white; border: none; padding: 8px 18px; border-radius: 12px; cursor: pointer; }
.clear-btn:hover { background: #e53e3e; }

#playlist {
    list-style: none;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 20px;
}

#playlist::-webkit-scrollbar { width: 6px; }
#playlist::-webkit-scrollbar-track { background: rgba(255,255,255,0.1); border-radius: 10px; }
#playlist::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 10px; }

#playlist li {
    padding: 16px;
    margin: 8px 0;
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#playlist li:hover { background: rgba(255,255,255,0.15); transform: translateX(8px); }
#playlist li.active { background: linear-gradient(135deg, rgba(102,126,234,0.3) 0%, rgba(118,75,162,0.3) 100%); border-left: 4px solid #667eea; }

.song-info { flex: 1; }
.song-title { font-weight: 600; color: white; display: block; margin-bottom: 4px; }
.song-artist { font-size: 13px; color: #a0aec0; }
.delete-song { background: rgba(229,62,62,0.8); color: white; border: none; padding: 8px 14px; border-radius: 12px; cursor: pointer; }
.delete-song:hover { background: #e53e3e; }

.load-more-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 10px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.load-more-btn:hover { background: rgba(255,255,255,0.3); transform: translateY(-2px); }

/* Scroll Top Button */
.scroll-top-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.scroll-top-btn:active { transform: scale(0.9); }

/* Modal */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    margin: auto;
    padding: 30px 25px;
    border-radius: 32px;
    width: 85%;
    max-width: 360px;
    color: white;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.2);
    animation: fadeInUp 0.3s ease;
    position: relative;
}

.modal-close {
    position: absolute;
    left: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #a0aec0;
    transition: 0.2s;
}

.modal-close:hover { color: white; }

.instruction-step {
    text-align: right;
    background: rgba(255,255,255,0.08);
    padding: 12px 16px;
    border-radius: 16px;
    margin: 12px 0;
}

.instruction-step strong {
    color: #667eea;
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.instruction-step p {
    margin: 5px 0;
    font-size: 14px;
    color: #cbd5e0;
}

.instruction-icon {
    font-size: 56px;
    margin: 10px 0;
}

.install-btn-quick {
    background: #48bb78;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 40px;
    font-size: 16px;
    font-weight: bold;
    margin-top: 15px;
    cursor: pointer;
    width: 100%;
}

.install-btn-quick:hover { background: #38a169; transform: scale(1.02); }

/* Mobile Responsive */
@media (max-width: 768px) {
    body { padding: 12px; }
    .container { padding: 0; }
    .login-screen { margin: 20px auto; padding: 24px 20px; }
    .login-screen h1 { font-size: 28px; }
    .header { flex-direction: column; text-align: center; gap: 12px; margin-bottom: 20px; }
    .header h1 { font-size: 24px; }
    .user-info { padding: 6px 16px; font-size: 14px; }
    .status-bar { padding: 10px 12px; font-size: 12px; }
    #saveStatus { font-size: 11px; }
    .status-bar button, #installBtn { padding: 6px 12px; font-size: 11px; }
    .add-section { flex-direction: column; gap: 8px; }
    .add-section input { padding: 12px; font-size: 14px; }
    .add-section button { padding: 12px; font-size: 14px; width: 100%; }
    .search-header { padding: 12px 16px; font-size: 14px; }
    .search-input-group { flex-direction: column; gap: 8px; }
    .search-input-group input { padding: 10px 12px; font-size: 14px; }
    .search-input-group button { padding: 10px; width: 100%; }
    .search-result-item { padding: 8px; gap: 8px; }
    .search-result-thumb { width: 60px; height: 34px; }
    .search-result-title { font-size: 12px; }
    .search-result-channel { font-size: 10px; }
    .search-result-add { padding: 4px 10px; font-size: 11px; }
    .player-controls { padding: 16px; margin-bottom: 20px; }
    .now-playing span:first-child { font-size: 16px; }
    .now-playing span:last-child { font-size: 13px; }
    .progress-bar { gap: 10px; }
    .progress-bar span { font-size: 11px; min-width: 35px; }
    .buttons { gap: 12px; }
    .buttons button { width: 55px; height: 55px; font-size: 22px; }
    .buttons button:active { transform: scale(0.95); }
    .volume-control { margin-top: 10px; }
    .playlist-section { padding: 16px; }
    .playlist-section h3 { font-size: 18px; margin-bottom: 12px; }
    .clear-btn { padding: 6px 14px; font-size: 12px; }
    #playlist li { padding: 12px; margin: 6px 0; }
    .song-title { font-size: 14px; }
    .song-artist { font-size: 11px; }
    .delete-song { padding: 6px 12px; font-size: 12px; }
    .load-more-btn { padding: 8px 20px; font-size: 12px; }
    .scroll-top-btn { width: 45px; height: 45px; font-size: 20px; bottom: 15px; left: 15px; }
}

@media (max-width: 480px) {
    .buttons button { width: 48px; height: 48px; font-size: 20px; }
    .search-result-thumb { width: 50px; height: 28px; }
    .player-controls { padding: 12px; }
    .now-playing span:first-child { font-size: 14px; }
    .playlist-section { padding: 12px; }
    .modal-content { width: 92%; padding: 20px 16px; border-radius: 24px; }
    .instruction-icon { font-size: 48px; }
    .instruction-step strong { font-size: 14px; }
    .instruction-step p { font-size: 12px; }
    .install-btn-quick { padding: 12px 20px; font-size: 14px; }
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {
    button, .search-result-item, #playlist li, .user-btn, .clear-btn, .delete-song, .load-more-btn {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(102,126,234,0.3);
    }
    button:active, .search-result-item:active, #playlist li:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    #playlist li { position: relative; }
    #playlist li::after {
        content: "💡 לחיצה ארוכה למחיקה";
        position: absolute;
        bottom: -20px;
        right: 10px;
        font-size: 9px;
        color: #a0aec0;
        opacity: 0;
        transition: opacity 0.3s;
    }
    #playlist li:active::after { opacity: 1; }
}

#playlist, .search-results {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}