/* --- 1. GLOBAL VARIABLES --- */
:root {
    --pm-gold: #d4af37;        
    --pm-black: #111111;       
    --pm-border: #e0e0e0;      
    --pm-gray: #f9f9f9;        
    --button-radius: 40px;     
}

/* --- 2. FLAT THEME BUTTONS --- */
.pomantra-play-btn, .pomantra-lib-btn, .pomantra-dl-btn, .pomantra-login-btn, .pm-danger-btn {
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    width: auto;
    padding: 12px 1.5rem !important; 
    border-radius: var(--button-radius) !important; 
    border: none !important;
    box-shadow: none !important;
    font-size: 14px; 
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
    line-height: 1.2;
}

.pomantra-play-btn:active, .pomantra-lib-btn:active { transform: scale(0.97); }

.pomantra-play-btn, .pomantra-login-btn {
    background-color: var(--pm-black); 
    color: #fff !important;
}
.pomantra-play-btn:hover, .pomantra-login-btn:hover {
    opacity: 0.9; 
    color: var(--pm-gold) !important;
}

.pomantra-lib-btn, .pomantra-dl-btn {
    background-color: #f4f4f4; 
    color: #333;
}
.pomantra-lib-btn:hover, .pomantra-dl-btn:hover {
    background-color: #eaeaea; 
    color: #000;
}

.pm-danger-btn {
    background-color: #ffeaea; color: #d63638; padding: 6px 12px !important; font-size: 11px;
}
.pm-danger-btn:hover { background-color: #ffdada; color: #b00; }


/* --- 3. INLINE POST CONTROLS --- */
.pomantra-controls {
    display: flex; flex-wrap: wrap; gap: 15px; margin: 25px 0; padding: 25px;
    background: #fff; border: 1px solid #eee; border-radius: 8px;
}


/* --- 4. MODERN PLAYLIST DESIGN (APPLE STYLE) --- */
.pomantra-playlist-modern {
    font-family: inherit;
    max-width: 100% !important;
    width: 100%;
    box-sizing: border-box;
    border: none;
    box-shadow: none;
    background: transparent;
}

/* Controls Only Mode (Top) */
.pomantra-playlist-modern.controls-only {
    margin: 0;
    padding: 0;
}

/* List Only Mode (Bottom) */
.pomantra-playlist-modern.list-only {
    margin-top: 20px;
}

/* Minimal Controls (Top Bar) */
.ppm-minimal-controls {
    display: flex;
    gap: 12px;
    padding: 0;
    border: none;
}

/* Track List Container */
.ppm-list {
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
}

/* Individual Track Row */
.ppm-track-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px; 
    border-bottom: 1px solid #f9f9f9; 
    cursor: pointer;
    transition: background 0.2s;
}

/* Remove last border */
.ppm-track-row:last-child { border-bottom: none; }

/* Hover Effect */
.ppm-track-row:hover { 
    background: #fafafa; 
}

.ppm-track-left {
    display: flex; align-items: center; gap: 15px; flex-grow: 1;
}

/* Track Image */
.ppm-track-img {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    object-fit: cover;
    background: #eee;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Info Text */
.ppm-info {
    display: flex; flex-direction: column; gap: 2px;
}

.ppm-track-title {
    font-size: 14px; 
    font-weight: 600; 
    color: #333; 
    line-height: 1.3;
}

.ppm-track-artist {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ppm-track-row:hover .ppm-track-title { color: #000; }

.ppm-track-right {
    display: flex; align-items: center; justify-content: flex-end; width: 40px;
}

/* Play Icon */
.ppm-play-icon { 
    font-size: 20px; 
    color: #ddd; 
    transition: color 0.2s, transform 0.2s; 
    border: 1px solid transparent;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ppm-track-row:hover .ppm-play-icon { 
    color: var(--pm-gold); 
    background: #fffdf0;
}

/* Active State */
.ppm-track-row.active-track .ppm-play-icon { display: none; }
.ppm-track-row.active-track .ppm-equalizer { display: flex; }

.ppm-track-row.active-track .ppm-track-title { 
    color: var(--pm-gold); 
    font-weight: 700; 
}

.ppm-track-row.active-track { 
    background: #fffdf9; 
}

/* Equalizer Animation */
.ppm-equalizer {
    display: none; align-items: flex-end; height: 16px; gap: 3px;
}
.ppm-equalizer span {
    width: 3px; background: var(--pm-gold); animation: eq-bounce 1s infinite ease-in-out;
}
.ppm-equalizer span:nth-child(2) { animation-delay: 0.2s; height: 60%; }
.ppm-equalizer span:nth-child(3) { animation-delay: 0.4s; height: 30%; }
@keyframes eq-bounce { 0%, 100% { height: 20%; } 50% { height: 100%; } }


/* --- 5. FOOTER PLAYER --- */
#pomantra-player {
    position: fixed;
    bottom: -100px;
    left: 0;
    width: 100%;
    height: 70px;
    background: #1a1a1a; 
    color: #fff;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    box-shadow: 0 -5px 30px rgba(0,0,0,0.4);
    border-top: 1px solid #333;
    transition: bottom 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-sizing: border-box;
    backdrop-filter: blur(10px);
}
#pomantra-player.active { bottom: 0; }

.pp-bar-wrap {
    position: absolute; top: 0; left: 0; width: 100%; height: 3px;
    background: rgba(255,255,255,0.1); cursor: pointer; z-index: 10;
}
.pp-bar { height: 100%; background: var(--pm-gold); width: 0%; box-shadow: 0 0 10px var(--pm-gold); }
.pp-bar-wrap:hover { height: 6px; }

/* REPEAT BADGE - Default for Desktop */
#pp-repeat-status {
    color: var(--pm-gold); font-size: 11px; font-weight: 700; margin-top: 2px; display: none;
}

/* Left: Info */
.pp-info { 
    display: flex; align-items: center; gap: 15px; width: 30%; 
    overflow: hidden; height: 100%; 
}
.pp-info img {
    width: 46px; height: 46px; border-radius: 6px; object-fit: cover;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    background: #000;
}
#pp-title { 
    font-size: 14px; font-weight: 600; color: #fff; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
}

/* Center: Controls */
.pp-ctrls { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 25px; 
    flex-grow: 1; 
    height: 100%; 
}
.pp-ctrls span { 
    color: #bbb; 
    font-size: 22px; 
    cursor: pointer; 
    transition: 0.2s; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    height: 100%;
}
.pp-ctrls span:hover, .pp-ctrls span.active { color: #fff; text-shadow: 0 0 8px rgba(255,255,255,0.4); }

#pp-toggle { font-size: 38px; color: #fff; }
#pp-toggle:hover { color: var(--pm-gold); transform: scale(1.1); }

/* Right: Menu */
.pp-menu-area { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
    width: 30%; 
    justify-content: flex-end; 
    height: 100%; 
}
.pp-menu-area span { 
    font-size: 20px; 
    color: #999; 
    cursor: pointer; 
    display: inline-flex; 
    align-items: center; 
    height: 100%;
}
.pp-menu-area span:hover { color: #fff; }


/* --- 6. QUEUE DRAWER --- */
#pomantra-queue {
    position: fixed; bottom: -60vh; left: 0; width: 100%; height: 50vh;
    background: #fff; z-index: 999990; transition: bottom 0.3s ease;
    box-shadow: 0 -10px 50px rgba(0,0,0,0.2); border-radius: 20px 20px 0 0;
    display: flex; flex-direction: column;
}
#pomantra-queue.open { bottom: 70px; } 

.pq-header { padding: 15px 25px; background: #fff; border-bottom: 1px solid #f0f0f0; border-radius: 20px 20px 0 0; font-weight: 700; display:flex; justify-content:space-between; color:#333; }
#pq-list { overflow-y: auto; flex-grow: 1; padding: 0; }
.pq-item { display: flex; justify-content: space-between; padding: 12px 25px; border-bottom: 1px solid #f9f9f9; align-items: center; font-size:13px; color:#555; }
.pq-item:hover { background: #fcfcfc; }
.pq-item.active { color: var(--pm-gold); font-weight: 600; background: #fffdf5; }
.pq-left { cursor:pointer; flex-grow:1; display:flex; align-items:center; gap:10px; }
.pq-actions { display:flex; gap:10px; }
.pq-btn { cursor:pointer; color:#ccc; }
.pq-btn:hover { color:#333; }


/* --- 7. POPUP MENU --- */
#pp-menu-popup {
    position: absolute; bottom: 80px; right: 25px; width: 160px;
    background: #222; border-radius: 8px; display: none;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4); border: 1px solid #333; overflow: hidden;
}
#pp-menu-popup div {
    padding: 12px 15px; border-bottom: 1px solid #333; font-size: 13px;
    color: #ccc; cursor: pointer;
}
#pp-menu-popup div:hover { background: #333; color: var(--pm-gold); }


/* --- 8. LIBRARY GRID --- */
.pomantra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.pom-grid-item {
    background: #fff; border: 1px solid #eee; border-radius: 8px; overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.pom-grid-item:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(0,0,0,0.08); }
.pg-img { 
    width: 100%; aspect-ratio: 1/1; background-size: cover; 
    background-position: center 20%; position: relative; cursor: pointer; 
}
.pg-img::after {
    content: '\f522'; font-family: 'dashicons'; position: absolute; inset: 0; 
    background: rgba(0,0,0,0.3); color: #fff; display: flex; align-items: center; 
    justify-content: center; font-size: 40px; opacity: 0; transition: opacity 0.3s;
}
.pom-grid-item:hover .pg-img::after { opacity: 1; }
.pg-meta { padding: 12px; text-align: center; }
.pg-meta h4 { margin: 0 0 8px; font-size: 13px; white-space: normal; overflow: visible; text-overflow: ellipsis; color: #333; }


/* --- 9. RESTRICTED BOX --- */
.pomantra-restricted-box {
    background: #fff; border: 1px solid #eee; border-left: 4px solid var(--pm-gold);
    border-radius: 8px; 
    padding: 40px; 
    text-align: center; 
    margin: 30px 0;
    display: flex; flex-direction: column; align-items: center; gap: 15px;
}
.pomantra-restricted-box .dashicons {
    font-size: 40px; width: 40px; height: 40px; color: var(--pm-gold); display: block; margin-bottom: 5px;
}
.pomantra-restricted-box h3 { margin: 0; color: #222; font-size: 20px; line-height: 1.3; }
.pomantra-restricted-box p { margin: 0 0 10px 0; color: #666; }


/* --- 10. USER PLAYLIST MANAGER --- */
.pomantra-user-playlists { display: flex; flex-direction: column; gap: 20px; }
.pom-playlist-card {
    background: #fff; border: 1px solid #f0f0f0; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04); overflow: hidden; margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.pom-playlist-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
.pp-header { padding: 18px 25px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.pp-header-left { display: flex; align-items: center; gap: 15px; }
.pp-icon {
    font-size: 24px; color: var(--pm-gold); background: #fffdf0; padding: 10px; border-radius: 50%;
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
}
.pp-pl-title { font-size: 15px; font-weight: 700; color: #222; }
.pp-pl-meta { font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 0.5px; }
.pp-header-actions { display: flex; align-items: center; gap: 10px; }
.pp-play-all {
    padding: 8px 16px !important; font-size: 11px !important; 
    border-radius: 4px; background: #222; color: #fff; border:none;
}
.pm-icon-btn {
    background: transparent; border: 1px solid #eee; color: #ccc; width: 32px; height: 32px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.pm-icon-btn.delete:hover { background: #fff0f0; border-color: #ffcccc; color: #d63638; }
.pp-body { display: none; border-top: 1px solid #f0f0f0; background: #fdfdfd; }
.pp-track-row {
    padding: 10px 20px; border-bottom: 1px solid #f5f5f5;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; color: #555;
}
.pp-track-left { display: flex; align-items: center; gap: 12px; }
.pp-small-play {
    width: 28px; height: 28px; background: #fff; border: 1px solid #e0e0e0; border-radius: 50%;
    color: #444; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 14px; transition: all 0.2s;
}
.pp-small-play:hover { background: var(--pm-gold); border-color: var(--pm-gold); color: #fff; }
.pp-remove-track { color: #ddd; cursor: pointer; font-size: 16px; }
.pp-remove-track:hover { color: #d63638; }


/* --- 11. CUSTOM REPEAT INPUT (IMPROVED UI & RESPONSIVENESS) --- */
.pm-repeat-wrapper {
    display: flex; align-items: center; gap: 8px; margin-left: auto; 
    border-left: 1px solid var(--pm-border); padding-left: 15px;
}

/* Make label text adapt to theme (light/dark mode) */
.pm-repeat-label { 
    font-size: 13px; font-weight: 600; color: inherit; opacity: 0.8; 
}

.pm-custom-repeat-input, .pm-disabled-input {
    width: 90px; padding: 6px 10px; border: 1px solid #ccc; border-radius: 4px; 
    font-size: 13px; background: #fff; color: #333; outline: none; transition: border-color 0.2s;
}

.pm-custom-repeat-input:focus { 
    border-color: var(--pm-gold) !important; 
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.3); 
}

/* Members Only Styling */
.pm-disabled-input { 
    background: #f0f0f0; color: #888; cursor: not-allowed; text-align: center; 
}

/* Reset Button Style */
.pm-reset-repeat-btn {
    background: transparent; border: none; color: #999; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; padding: 4px; 
    border-radius: 50%; transition: 0.2s;
}

.pm-reset-repeat-btn:hover { 
    color: var(--pm-gold); background: rgba(212, 175, 55, 0.1); 
}

/* Hide arrows in number input */
.pm-custom-repeat-input::-webkit-outer-spin-button,
.pm-custom-repeat-input::-webkit-inner-spin-button { 
    -webkit-appearance: none; margin: 0; 
}

.pm-custom-repeat-input[type=number] { 
    -moz-appearance: textfield; 
}


/* --- 12. RESPONSIVE FIXES --- */

/* MOBILE ONLY FIXES (MAX-WIDTH: 768px) */
@media (max-width: 768px) {
    /* Playlist Header Stacking */
    .ppm-header-content { flex-direction: column; align-items: center; text-align: center; }
    .ppm-meta { margin-bottom: 10px; min-width: auto; }
    
    /* Adjust Track Row for Mobile */
    .ppm-track-row { padding: 10px 10px; }
    .ppm-track-img { width: 36px; height: 36px; }
    .ppm-track-title { font-size: 13px; }
    
    /* MOBILE PLAYER: Center Icons, No Vertical Border */
    #pomantra-player { 
        height: 65px !important; 
        padding: 0 10px !important; 
        bottom: -200px; 
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: rgba(26,26,26,0.98);
        gap: 0;
    }
    
    .pp-info { 
        width: auto !important; 
        flex: 0 0 auto !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
    }
    
    .pp-info img {
        width: 42px !important; 
        height: 42px !important;
        margin: 0 8px 0 0 !important;
        padding: 0 !important;
        display: block !important;
    }
    
    #pp-title { display: none !important; }
    
    /* CENTER THE CONTROLS */
    .pp-ctrls {
        flex-grow: 1;
        justify-content: center !important; 
        padding: 0 !important;
        margin: 0 !important;
        gap: 15px !important;
        display: flex !important;
        align-items: center !important;
    }
    
    /* Right Menu - REMOVED BORDER */
    .pp-menu-area { 
        width: auto !important;
        justify-content: flex-end !important;
        gap: 10px !important;
        padding-left: 5px;
        margin: 0 !important;
        border-left: none !important; 
        display: flex !important;
        align-items: center !important;
    }
    
    .pp-ctrls span, .pp-menu-area span { font-size: 26px !important; display: inline-flex !important; }
    #pp-toggle { font-size: 34px !important; }

    #pomantra-queue.open { bottom: 0; height: 80vh; z-index: 9999999; }
    
    .woocommerce-MyAccount-navigation, 
    .woocommerce-MyAccount-content { width: 100% !important; float: none !important; margin-right: 0 !important; }
    .woocommerce table.shop_table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }

    /* MOBILE INLINE REPEAT BOX: Fixes spacing by pushing items to the left (flex-start) */
    .pm-repeat-wrapper {
        margin-left: 0 !important; 
        border-left: none !important; 
        padding-left: 0 !important; 
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
        border-top: 1px solid var(--pm-border); 
        padding-top: 15px; 
        margin-top: 10px;
    }
    
    /* MOBILE REPEAT STATUS: Floating Gold Badge above player */
    /* BUG FIX: Removed 'display: block !important' so JavaScript can hide it when not in use! */
    #pp-repeat-status {
        position: absolute;
        top: -24px;
        left: 50%;
        transform: translateX(-50%);
        background: #111;
        border: 1px solid var(--pm-gold);
        padding: 3px 12px;
        border-radius: 12px 12px 0 0;
        font-size: 10px;
        letter-spacing: 0.5px;
        color: var(--pm-gold);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    }
}

@media (min-width: 769px) {
    #pomantra-player { display: flex !important; flex-wrap: nowrap !important; }
    .pp-info, .pp-ctrls, .pp-menu-area { display: flex !important; opacity: 1 !important; visibility: visible !important; }
    #pp-title { display: block !important; }
    
    .pp-ctrls span, .pp-menu-area span {
        font-size: 22px !important;
        color: #bbb !important;
        display: inline-flex !important;
    }
    #pp-toggle { font-size: 38px !important; color: #fff !important; }
    .pp-ctrls span:hover, .pp-menu-area span:hover { color: #fff !important; }
}

/* Fix Global Horizontal Scroll */
body, .boxed-wrap { overflow-x: hidden; }
h1, h2, h3, h4, h5, h6, .entry-title { word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; }

/* --- LIBRARY PAGE STYLES --- */

.pm-lib-heading {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.pg-type-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    letter-spacing: 1px;
}

/* --- QUEUE BUTTON --- */
.pomantra-queue-btn {
    background-color: #f4f4f4; 
    color: #333;
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    width: auto;
    padding: 12px 1.5rem !important; 
    border-radius: var(--button-radius) !important; 
    border: none !important;
    font-size: 14px; 
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pomantra-queue-btn:hover {
    background-color: #e0e0e0;
    color: #000;
    transform: translateY(-1px);
}

.pomantra-queue-btn:active {
    transform: scale(0.97);
}

/* --- TOAST NOTIFICATION --- */
#pm-toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 50px;
    padding: 16px;
    position: fixed;
    z-index: 9999999;
    left: 50%;
    bottom: 90px; 
    transform: translateX(-50%);
    font-size: 14px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
}

#pm-toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 100px; 
}