/* =====================================================
   Music Library – Front-End Player
   ===================================================== */

/* ---- Track Grid ---- */
.ml-library { font-family: inherit; }

.ml-track-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    padding-bottom: 100px; /* space for sticky bar */
}

@media (max-width: 1100px) {
    .ml-track-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 820px) {
    .ml-track-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}

.ml-track-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
}
.ml-track-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,.13);
}
.ml-track-card.ml-active {
    box-shadow: 0 0 0 3px #6c63ff, 0 6px 20px rgba(108,99,255,.25);
}

/* Cover art */
.ml-card-cover {
    position: relative;
    aspect-ratio: 1;
    background: #1a1a2e;
    overflow: hidden;
}
.ml-card-cover img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity .3s;
}
.ml-card-cover:hover img { opacity: .75; }

.ml-cover-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 56px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
    color: rgba(255,255,255,.3);
}

.ml-card-play-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.8);
    opacity: 0;
    width: 52px; height: 52px;
    border-radius: 50%;
    border: none;
    background: rgba(108,99,255,.9);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: opacity .2s, transform .2s;
    display: flex; align-items: center; justify-content: center;
    padding-left: 3px;
}
.ml-track-card:hover .ml-card-play-btn,
.ml-track-card.ml-active .ml-card-play-btn {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Pause icon when playing */
.ml-track-card.ml-playing .ml-card-play-btn::before { content: '⏸'; font-size: 18px; padding-left: 0; }

/* Card info */
.ml-card-info {
    padding: 14px;
}
.ml-card-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 3px;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    line-height: 1.3;
}
.ml-card-artist {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ml-card-meta {
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
}
.ml-card-desc {
    font-size: 12px;
    color: #777;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.ml-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #6c63ff;
    text-decoration: none;
    border: 1.5px solid #6c63ff;
    border-radius: 20px;
    padding: 4px 14px 4px 10px;
    transition: background .2s, color .2s;
    line-height: 1.4;
}
.ml-download-btn::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg) translate(2px, -2px);
    flex-shrink: 0;
}
.ml-download-btn:hover {
    background: #6c63ff;
    color: #fff;
    text-decoration: none;
}

/* ---- Sticky Player Bar ---- */
.ml-player-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 72px;
    background: #16213e;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0,0,0,.35);
}

.ml-player-cover {
    width: 48px; height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #0f3460;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    color: rgba(255,255,255,.3);
}
.ml-player-cover img { width: 100%; height: 100%; object-fit: cover; }
.ml-bar-cover-placeholder { display: none; }

.ml-player-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 160px;
    flex-shrink: 0;
}
.ml-bar-title {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ml-bar-artist {
    font-size: 12px;
    color: rgba(255,255,255,.6);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ml-player-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.ml-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background .15s;
    line-height: 1;
}
.ml-btn:hover { background: rgba(255,255,255,.1); }
.ml-play-pause { font-size: 22px; }

.ml-progress-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.ml-time {
    font-size: 12px;
    color: rgba(255,255,255,.6);
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}
.ml-progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}
.ml-progress-fill {
    height: 100%;
    background: #6c63ff;
    border-radius: 2px;
    width: 0;
    pointer-events: none;
}
.ml-progress-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    background: #fff;
    border-radius: 50%;
    left: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}
.ml-progress-bar:hover .ml-progress-thumb { opacity: 1; }

.ml-volume-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.ml-vol-icon { font-size: 16px; }
#ml-volume { width: 80px; accent-color: #6c63ff; cursor: pointer; }

@media (max-width: 600px) {
    .ml-track-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .ml-player-info, .ml-volume-wrap { display: none; }
    .ml-player-bar { gap: 10px; padding: 0 12px; }
    #ml-volume { width: 60px; }
}

/* ---- Auth Bar (sign-in status, shown at top of the library) ---- */
.ml-auth-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    background: #f7f4ef;
    border: 1px solid #e8e2d6;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
}

.ml-auth-status {
    font-size: 13px;
    color: #444;
}

.ml-auth-link {
    font-size: 12px;
    font-weight: 600;
    color: #6c63ff;
    text-decoration: none;
}
.ml-auth-link:hover { text-decoration: underline; }

#ml-google-btn-inline { min-height: 40px; }

/* ---- Google Sign-In Gate Modal ---- */
.ml-gate-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.55);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ml-gate-modal {
    background: #fff;
    border-radius: 14px;
    padding: 32px 28px 28px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
}

.ml-gate-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 4px;
}
.ml-gate-close:hover { color: #333; }

.ml-gate-modal h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.ml-gate-modal p {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 18px;
}

#ml-google-btn-modal {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

.ml-gate-status {
    margin-top: 12px !important;
    font-size: 12px;
    min-height: 16px;
}

@media (max-width: 600px) {
    .ml-auth-bar { flex-direction: column; align-items: flex-start; }
}
