.sac-player-app {
    font-family: 'Almarai', sans-serif;
    max-width: 1200px;
    margin: 40px auto;
    background: #ffffff;
    color: #1e293b;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08);
    /* Premium soft shadow */
    display: flex;
    flex-direction: column;
    height: 85vh;
    border: 1px solid #f1f5f9;
}

/* Header & Search */
.sac-header {
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    gap: 20px;
}

.sac-title-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 54px;
    /* More padding for the button */
}


.sac-sidebar-toggle-grid {
    display: none;
    /* Hidden on desktop */
    background: #eff6ff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: #1a73e8;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

@media (max-width: 768px) {
    .sac-sidebar-toggle-grid {
        display: flex;
    }

    .sac-title-row {
        padding: 0;
        /* Reset padding */
    }
}

.sac-course-title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: #1a73e8;
    letter-spacing: -0.5px;
}

.sac-search-row {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.sac-search-box {
    position: relative;
    width: 100%;
}

.sac-search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    font-size: 18px;
}

.sac-search-input {
    background: #f8fafc;
    border: 2px solid transparent;
    color: #1e293b;
    padding: 14px 48px 14px 20px;
    border-radius: 14px;
    font-size: 16px;
    width: 100%;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.sac-search-input:focus {
    background: #fff;
    border-color: #1a73e8;
    box-shadow: 0 10px 25px rgba(26, 115, 232, 0.1);
}

.sac-search-input::placeholder {
    color: #94a3b8;
}

/* Layout */
.sac-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #fff;
}

/* Sidebar */
.sac-sidebar {
    width: 280px;
    min-width: 280px;
    background: #f8fafc;
    border-left: 1px solid #f1f5f9;
    overflow-y: auto;
    padding: 12px 0;
}

.sac-sidebar-header {
    padding: 16px 24px;
    margin-bottom: 8px;
}

.sac-sidebar-header h4 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    font-weight: 700;
}

.sac-tree-row {
    display: flex;
    align-items: center;
    padding: 10px 24px 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    gap: 12px;
    transition: all 0.2s ease;
    font-size: 14px;
    margin: 0 12px;
    color: #475569;
    font-weight: 500;
}

.sac-tree-row:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.sac-tree-row.active {
    background: #1a73e8;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.2);
}

.sac-tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    opacity: 0.6;
}

.sac-tree-row.active .sac-tree-toggle {
    color: #fff;
    opacity: 1;
}

.sac-tree-children {
    display: none;
    flex-direction: column;
    padding-right: 20px;
}

.sac-tree-children.expanded {
    display: flex;
}

.sac-tree-audio {
    display: flex;
    align-items: center;
    padding: 8px 16px 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    gap: 10px;
    transition: all 0.2s ease;
    font-size: 13px;
    margin: 2px 14px;
    color: #64748b;
    font-weight: 500;
}

.sac-tree-audio:hover {
    background: #f1f5f9;
    color: #1a73e8;
}

.sac-tree-audio.active {
    background: #eff6ff;
    color: #1a73e8;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.1);
}

.sac-tree-audio .sac-tree-icon {
    font-size: 14px;
    opacity: 0.8;
}

/* Main */
.sac-main {
    flex: 1;
    padding: 32px;
    padding-bottom: 150px; /* Space for popup player */
    overflow-y: auto;
    background: #ffffff;
}

.sac-breadcrumb span {
    cursor: pointer;
}

.sac-breadcrumb span:hover {
    background: #f1f3f4;
    border-radius: 4px;
}

/* Grid Layout for Main Content */
.sac-playlist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-items: start;
}

/* Grid Header (Labels like "Name") */
.sac-grid-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.sac-grid-label {
    gap: 4px;
}

/* Folder Card (Main Grid) */
.sac-folder-card {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border: 1.5px solid #f1f5f9;
    border-radius: 16px;
    cursor: pointer;
    gap: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 64px;
}

.sac-folder-card:hover {
    background: #ffffff;
    border-color: #1a73e8;
    transform: translateY(-4px);
    box-shadow: 0 10px 20px -5px rgba(26, 115, 232, 0.1);
}

.sac-folder-card .sac-icon {
    font-size: 24px;
    color: #ffd43b;
    /* Folder orange/yellow */
}

.sac-folder-card .sac-name {
    font-size: 15px;
    font-weight: 600;
    color: #334155;
}

/* Audio Item Card */
.sac-playlist-item {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1.5px solid #f1f5f9;
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sac-playlist-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.1);
    border-color: #1a73e8;
}

.sac-playlist-item.active {
    background: #eff6ff;
    border-color: #1a73e8;
    box-shadow: 0 10px 20px -5px rgba(26, 115, 232, 0.15);
}

.sac-playlist-thumb {
    height: 160px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.sac-playlist-thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(26, 115, 232, 0.05) 0%, transparent 70%);
}

.sac-playlist-thumb .sac-icon {
    font-size: 64px;
    color: #1a73e8;
    transition: transform 0.3s;
}

.sac-playlist-item:hover .sac-icon {
    transform: scale(1.1);
}

.sac-playlist-info {
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
}

.sac-playlist-title {
    font-size: 13px;
    color: #3c4043;
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sac-playlist-num,
.sac-playlist-playing {
    display: none;
    /* Hide in grid view */
}

/* Now Playing Popup Bar */
.sac-now-playing {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 20px 32px;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    z-index: 2500;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
    animation: sacPopupUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes sacPopupUp {
    from { transform: translate(-50%, 150%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.sac-player-controls {
    display: grid;
    /* Grid layout matching desktop with play button, info, and volume */
    grid-template-columns: 55px 1fr auto;
    gap: 24px;
    align-items: center;
    width: 100%;
}

.sac-play-btn {
    width: 55px;
    height: 55px;
    background: transparent;
    color: #1a73e8;
    border: none;
    font-size: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: none;
    padding: 0;
}

.sac-play-btn:hover {
    background: transparent;
    transform: scale(1.15);
    color: #1557b0;
    box-shadow: none;
}

.sac-player-info {
    flex: 1;
}

.sac-player-title {
    font-size: 14px;
    color: #202124;
    font-weight: 500;
}

.sac-seek-bar-container {
    flex: 2;
    padding: 0 20px;
}

.sac-seek-bar {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #dadce0;
    outline: none;
}

.sac-seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
}

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

/* Speed Controls in player bar */
.sac-speed-controls {
    display: flex;
    gap: 4px;
}

.sac-speed-btn {
    background: none;
    border: none;
    color: #5f6368;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.sac-speed-btn.active {
    color: #1a73e8;
    font-weight: 600;
}


@media (max-width: 768px) {
    .sac-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 2000;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
        background: #ffffff;
        border-right: 1px solid #f1f5f9;
        transform: translateX(-100%);
        /* Start off-screen */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        visibility: hidden;
    }

    .sac-sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
    }

    .sac-playlist {
        grid-template-columns: 1fr 1fr;
        /* 2 in a row */
        gap: 12px;
    }

    .sac-playlist-thumb {
        height: 120px;
        /* Shorter on mobile */
    }

    .sac-playlist-title {
        font-size: 13px;
        padding: 10px;
    }

    .sac-folder-card {
        padding: 12px;
        min-height: 50px;
        gap: 10px;
    }

    .sac-folder-card .sac-name {
        font-size: 13px;
    }

    /* Mobile Player Popup */
    .sac-main {
        padding-bottom: 220px;
        /* Space for popup */
    }

    .sac-now-playing {
        position: fixed;
        bottom: 20px;
        left: 15px;
        right: 15px;
        width: auto;
        transform: none;
        border-radius: 20px;
        padding: 20px 15px 15px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.5);
        display: flex;
        flex-direction: column;
        gap: 15px;
        z-index: 2500;
        animation: sacPopupUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    @keyframes sacPopupUp {
        from {
            transform: translateY(120%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .sac-player-controls {
        display: grid;
        grid-template-columns: 60px 1fr auto;
        gap: 12px;
        align-items: center;
        width: 100%;
        margin: 0;
    }

    .sac-play-btn {
        width: 60px;
        height: 60px;
        font-size: 52px;
        background: transparent;
        color: #1a73e8;
        box-shadow: none;
    }
    .sac-play-btn:hover {
        background: transparent;
        color: #1557b0;
        box-shadow: none;
        transform: scale(1.1);
    }

    .sac-player-info {
        display: flex;
        flex-direction: column;
        gap: 4px;
        overflow: hidden;
    }

    .sac-player-time {
        font-size: 13px;
        font-weight: 600;
        color: #1a73e8;
    }

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

    .sac-volume-icon {
        font-size: 14px;
        color: #94a3b8;
    }

    .sac-volume-slider {
        width: 50px;
    }

    .sac-seek-bar-container {
        padding: 0;
        margin-top: -5px;
    }

    .sac-speed-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        background: #f8fafc;
        border-radius: 12px;
        padding: 5px;
    }

    .sac-speed-label {
        font-size: 12px;
        font-weight: 700;
        color: #64748b;
        margin-left: 5px;
    }

    .sac-speed-btn {
        padding: 6px 4px;
        font-size: 13px;
        border-radius: 8px;
    }

    .sac-speed-btn.active {
        background: #fff;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    }
}

/* Login Page Standalone */
.sac-login-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    padding: 20px;
}

.sac-login-box {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.sac-login-logo {
    font-size: 48px;
    margin-bottom: 24px;
}

.sac-login-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1a73e8;
}

.sac-login-subtitle {
    color: #64748b;
    margin-bottom: 32px;
    font-size: 15px;
}

#sac-standalone-login-form .sac-field {
    text-align: right;
    margin-bottom: 20px;
}

#sac-standalone-login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

#sac-standalone-login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    background: #fcfcfc;
}

#sac-standalone-login-form input:focus {
    outline: none;
    border-color: #1a73e8;
    background: #fff;
}

.sac-login-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #f1f5f9;
}

.sac-login-footer p {
    font-size: 14px;
    color: #64748b;
}

.sac-login-footer a {
    color: #1a73e8;
    font-weight: 600;
    text-decoration: none;
}

.sac-login-footer a:hover {
    text-decoration: underline;
}

/* RTL Helpers */
[dir="rtl"] .sac-field {
    text-align: right;
}