﻿/* ========================================
   SITE.CSS - CONSOLIDATED VERSION (DUPLICATES REMOVED)
   Table of Contents:
   1. Base Styles
   2. Common UI Elements  
   3. Flex Layouts
   4. Typography
   5. Header & Footer
   6. Modals (General)
   7. Utilities
   8. Device Cards System
   9. Server Media Modal
   10. Device Settings Modal
   11. Other UI Components
   12. Toggle Switches
   13. Trackbar Controls
   14. Animations
   ======================================== */

/* ========================================
   1. BASE STYLES
   ======================================== */
/* Hide scrollbars on html and body only */
html, body {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

    html::-webkit-scrollbar,
    body::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
        width: 0 !important;
    }

body {
    padding-top: 85px;
    padding-bottom: 77px;
    position: relative;
    min-height: 100vh;
}

/* Tablets/desktop (768px and up) */
@media screen and (min-width: 768px) {
    body {
        padding-bottom: 97px;
    }

    .jumbotron {
        margin-top: 20px;
    }

    .body-content {
        padding: 0;
    }
}

.dl-horizontal dt {
    white-space: normal;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="select"] {
    max-width: 100%;
}

/* ========================================
   2. COMMON UI ELEMENTS
   ======================================== */
.ProfileBtn {
    width: 45px;
    height: 45px;
    cursor: pointer;
    margin-bottom: 30px;
    margin-left: 20px;
}

.DimButtons {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-right: 5px;
}

#BackBtn {
    cursor: pointer;
}

.LightWhiteBack {
    background-color: #F8F8F8;
}

.MediumWhiteBack {
    background-color: #efeff4;
}

/* ========================================
   3. FLEX LAYOUTS
   ======================================== */
.FlexDisplay {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: space-between;
    align-items: center;
    height: 45px;
}

.FlexOptions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: flex-end;
    align-items: center;
    height: 45px;
}

.FlexHeight {
    height: 65px;
    padding-top: 22px;
}

.LayoutHeight {
    padding-top: 10px;
    height: 60px;
}

.FlexMargin {
    padding-left: 20px;
    padding-right: 20px;
}

.FlexBorder {
    border-top: 2px solid #EFEFF4;
    border-bottom: 2px solid #EFEFF4;
    padding-top: 8px;
}

/* ========================================
   4. TYPOGRAPHY
   ======================================== */
.pageLabel {
    font-size: 36px;
    font-weight: bold;
    top: 0;
    left: 0;
    color: black;
    margin-bottom: 30px;
}

.PageDiv {
    padding-left: 20px;
    padding-right: 20px;
}

.NameDiv {
    padding-left: 10px;
    padding-right: 10px;
}

.InfoLabel {
    font-family: Roboto, sans-serif;
    font-weight: 500;
    font-size: 17px;
    color: #8E8E93;
    margin: 15px;
}

.InfoLayout {
    color: #9A9A9F;
    font-family: Roboto, sans-serif;
    font-weight: 500;
    font-size: large;
    margin: 16px;
}

.InfoDiv {
    background: #D1D1D6;
}

.LightLargeLabel {
    font-family: Roboto, sans-serif;
    font-size: large;
    color: black;
}

.LighterLargeLabel {
    font-family: Roboto, sans-serif;
    font-size: large;
    font-weight: bold;
    color: #707174;
}

.DarkMedLabel {
    font-family: Roboto, sans-serif;
    font-size: medium;
    font-weight: bold;
    color: black;
}

.DarkLargeLabel {
    font-family: Roboto, sans-serif;
    font-size: 21px;
    font-weight: bold;
    color: black;
}

/* ========================================
   5. HEADER & FOOTER
   ======================================== */
.MHeader {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding-left: 6px;
    background: #F8F8F8;
}

.BTNback {
    color: #F4364C;
    font-weight: 500;
    font-size: large;
    margin-left: 4px;
    cursor: pointer;
}

.IMGback {
    margin-bottom: 4px;
    width: 15px;
    height: 20px;
    cursor: pointer;
}

.PHeader {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-content: center;
    flex-wrap: nowrap;
    cursor: pointer;
    justify-content: space-between;
    background: #F8F8F8;
    padding-top: 5px;
}

#header {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 85px;
    z-index: 1030 !important; /* Below modal backdrop (1040) */
    background-color: #F8F8F8;
    border-bottom: 2px solid #EFEFF4;
}

#footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #fff;
    color: #000;
    text-align: center;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 2px solid #EFEFF4;
    z-index: 1030 !important; /* Below modal backdrop (1040) */
}

.menuButtons {
    width: 95px;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

    .menuButtons:hover {
        opacity: 0.7;
    }

@media (max-width: 767px) {
    .menuButtons {
        width: 75px;
    }
}

/* ========================================
   6. MODALS (General)
   ======================================== */
#btnAlertOK {
    cursor: pointer;
}

.AModal {
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.modal {
    z-index: 101000 !important; /* Highest */
    pointer-events: none !important; /* Let clicks pass through to backdrop */
}

.modal-dialog {
    pointer-events: auto !important; /* But catch clicks on the actual modal box */
}

.modal-backdrop {
    z-index: 100000 !important; /* Above header/footer (99999) */
    pointer-events: auto !important; /* Backdrop catches clicks (for closing modal) */
}

    .modal-backdrop.show {
        opacity: 0.5 !important;
    }

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px !important;
    border-bottom: 1px solid #e0e0e0;
}

    .modal-header .btn {
        flex-shrink: 0;
    }

    .modal-header .form-control {
        flex: 1;
        width: auto;
    }

/* ========================================
   7. UTILITIES
   ======================================== */
.centerAll {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: auto;
    width: 100%;
}

.hide {
    display: none;
}

.fullHeight {
    margin-top: 68px;
    margin-bottom: 74px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.multiline-ellipsis {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   8. DEVICE CARDS SYSTEM
   ======================================== */
:root {
    --thumb-size: 140px;
    --card-padding: 1.5rem;
    --swipe-left: calc(var(--thumb-size) * 3);
    --swipe-right: calc(var(--thumb-size) * 2);
    --button-font-size: .9rem;
    --label-font-size: 1.4rem;
    --reveal-percent: 50%;
}

#sortable,
#playlists,
#slideSortable {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Device Card Container */
.device-item {
    position: relative;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    transition: border-color .3s ease, box-shadow .3s ease;
}

    .device-item:hover {
        border-color: #90caf9;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

/* Swipe Panels */
.swipe-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #B7D1FB;
    pointer-events: none;
    z-index: 0;
}

/* Action Zones */
.device-actions-left,
.device-actions-right {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    pointer-events: none;
    z-index: 1;
}

.device-actions-left {
    left: 0;
    width: 50%;
}

.device-actions-right {
    right: 0;
    width: 50%;
}

    .device-actions-left.active-panel,
    .device-actions-right.active-panel {
        z-index: 2;
        pointer-events: auto;
    }

    /* Action Buttons */
    .device-actions-left button,
    .device-actions-right button {
        flex: 1;
        border: none;
        display: flex;
        height: 100%;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: var(--button-font-size);
        cursor: pointer;
        white-space: nowrap;
        touch-action: manipulation;
    }

.device-actions-left .shutdown {
    order: 1;
    background: #f0f0f0;
    color: #666;
}

.device-actions-left .restart {
    order: 2;
    background: #ccc;
    color: #666;
}

.device-actions-left .location {
    order: 3;
    background: #ff6600;
    color: #fff;
}

.device-actions-right .settings {
    background: #ccc;
    color: #fff;
}

.device-actions-right .trash {
    background: #c00;
    color: #fff;
}

/* Device Main Card */
.device-main {
    position: relative;
    z-index: 0;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    user-select: none;
    cursor: grab;
    touch-action: pan-y;
}

    .device-main.closed {
        transform: translateX(0);
    }

    .device-main.open-left {
        transform: translateX(var(--swipe-left));
    }

    .device-main.open-right {
        transform: translateX(calc(-1 * var(--swipe-right)));
    }

    .device-main.active {
        background-color: #bbd9f9;
    }

/* Device Thumbnail */
.device-thumb {
    flex-shrink: 0;
    width: var(--thumb-size);
    height: var(--thumb-size);
    object-fit: cover;
    border-radius: 0;
}

/* Status Dot */
.status-dot {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    margin-right: 1rem;
    border-radius: 50%;
    background: #6c757d;
}

    .status-dot.online {
        background: #28a745;
    }

/* Device Label */
.device-label {
    flex: 1 1 auto;
    font-weight: bold;
    font-size: var(--label-font-size);
    min-width: 0;
    white-space: normal;
    word-wrap: break-word;
    margin-right: 2.5rem;
}

/* Drag Handle */
.drag-handle {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    cursor: grab;
    z-index: 2;
}

    .drag-handle i {
        font-size: 1.2rem;
    }

/* Activate New Device Card */
.activate-wrapper {
    margin-bottom: 1rem;
}

    .activate-wrapper .device-item.activate-only {
        cursor: pointer;
    }

    .activate-wrapper .activate-square {
        width: var(--thumb-size);
        height: var(--thumb-size);
        background: #f44336;
        border-radius: 8px 0 0 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .activate-wrapper .plus-icon {
        font-size: 2.5rem;
        color: #fff;
        pointer-events: none;
    }

/* Playlist Card 2x2 Grid */
#playlists .device-item.playlist-item .device-thumb {
    display: grid !important;
    gap: 1px;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

    #playlists .device-item.playlist-item .device-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

/* ========================================
   9. SERVER MEDIA MODAL
   ======================================== */

/* CSS Variables for responsive sizing */
#serverMediaModal {
    --cell-min: 180px;
    --card-height: 240px;
    --thumb-size: 160px;
    --thumb-radius: 8px;
    --thumb-bg: #f1f3f5;
    --grid-gap: 16px;
    --border-color: #e9ecef;
    --text-muted: #6c757d;
}

    /* Modal Structure */
    #serverMediaModal .modal-dialog {
        max-width: min(1200px, 94vw);
        display: flex;
        align-items: center;
        min-height: calc(100vh - 2rem);
        margin: 1rem auto;
    }

    #serverMediaModal .modal-content {
        border-radius: 12px;
        overflow: hidden;
        max-height: 70vh;
        margin: auto;
    }

    #serverMediaModal .modal-header {
        background: #ffffff;
        color: #212529;
        border-bottom: 1px solid #dee2e6;
        padding: 0.75rem 1rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-height: auto;
    }

    /* Header elements */
    #serverMediaModal #serverMediaUpload {
        height: 38px;
        padding: 0 1rem;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    #serverMediaModal #serverMediaSearch {
        height: 38px;
        padding: 0.375rem 0.75rem;
        flex: 1;
        max-width: none;
    }

        #serverMediaModal #serverMediaSearch::placeholder {
            color: #6c757d;
            opacity: 1;
        }

    #serverMediaModal .modal-header .btn-close {
        width: 38px;
        height: 38px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        flex-shrink: 0;
        margin: 0;
        opacity: 0.5;
        background-color: transparent;
    }

        #serverMediaModal .modal-header .btn-close:hover {
            opacity: 0.75;
            background-color: rgba(0, 0, 0, 0.05);
        }

    #serverMediaModal .modal-body {
        max-height: 60vh;
        min-height: 400px;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1rem;
    }

    #serverMediaModal .modal-footer {
        border-top: 1px solid var(--border-color);
        padding: 0.75rem 1rem;
    }

        #serverMediaModal .modal-footer .btn {
            padding: 0.375rem 0.75rem;
            font-size: 0.875rem;
        }

/* Grid Layout */
#serverMediaGrid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(var(--cell-min), 1fr));
    gap: var(--grid-gap);
}

    /* Media Card with Left Toolbar */
    #serverMediaGrid .mcard {
        position: relative;
        height: var(--card-height);
        border: 1px solid #dee2e6;
        border-radius: 10px;
        background: white;
        overflow: hidden;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        padding: 0;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

        #serverMediaGrid .mcard:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            transform: translateY(-1px);
            border-color: #d0d5db;
        }

        /* Disable transform and overflow when popups are shown */
        #serverMediaGrid .mcard.show-pop,
        #serverMediaGrid .mcard.show-editor {
            transform: none !important;
            overflow: visible !important;
        }

            #serverMediaGrid .mcard.show-pop:hover,
            #serverMediaGrid .mcard.show-editor:hover {
                transform: none !important;
            }

        /* Left Toolbar */
        #serverMediaGrid .mcard .toolbar {
            width: 38px;
            background: linear-gradient(180deg, #f8f9fa 0%, #f1f3f5 100%);
            border-right: 1px solid #e9ecef;
            display: flex;
            flex-direction: column;
            padding: 6px 4px;
            gap: 4px;
            flex-shrink: 0;
        }

        /* Toolbar Buttons */
        #serverMediaGrid .mcard .toolbar-btn {
            width: 30px;
            height: 30px;
            background: transparent;
            border: 1px solid transparent;
            border-radius: 6px;
            color: #6c757d;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.15s ease;
            padding: 0;
            margin: 0;
        }

            /* Remove button */
            #serverMediaGrid .mcard .toolbar-btn.remove-btn:hover {
                background: rgba(220, 53, 69, 0.1);
                border-color: rgba(220, 53, 69, 0.2);
                color: #dc3545;
            }

            /* Edit button */
            #serverMediaGrid .mcard .toolbar-btn.edit-meta-btn:hover {
                background: rgba(52, 152, 219, 0.1);
                border-color: rgba(52, 152, 219, 0.2);
                color: #3498db;
            }

            /* Toolbar icons */
            #serverMediaGrid .mcard .toolbar-btn i {
                font-size: 13px;
                pointer-events: none;
            }

        /* Card Content */
        #serverMediaGrid .mcard .card-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 12px;
            min-width: 0;
            gap: 8px;
        }

        /* Thumbnail */
        #serverMediaGrid .mcard .thumb-wrap {
            width: 100%;
            max-width: var(--thumb-size);
            height: var(--thumb-size);
            background: #f8f9fa;
            border-radius: 8px;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            position: relative;
            cursor: pointer;
            transition: all 0.2s ease;
            border: 1px solid #e9ecef;
        }

            #serverMediaGrid .mcard .thumb-wrap:hover {
                transform: scale(1.03);
                box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
                border-color: #dee2e6;
            }

            #serverMediaGrid .mcard .thumb-wrap img,
            #serverMediaGrid .mcard .thumb-wrap video {
                width: 100%;
                height: 100%;
                object-fit: cover;
                display: block;
            }

        /* Video thumbnails always play */
        #serverMediaGrid .mcard video {
            pointer-events: none;
        }

        /* Metadata */
        #serverMediaGrid .mcard .meta {
            width: 100%;
            padding: 4px 2px;
            text-align: center;
            min-height: 0;
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            gap: 2px;
        }

            #serverMediaGrid .mcard .meta .title {
                font-size: 13px;
                font-weight: 500;
                color: #2c3e50;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                line-height: 1.4;
            }

            #serverMediaGrid .mcard .meta .desc {
                font-size: 11px;
                color: #6c757d;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                line-height: 1.3;
                opacity: 0.9;
            }

        /* Popups */

        /* Confirmation Popup */
        #serverMediaGrid .mcard .confirm-pop {
            position: fixed !important;
            top: 50% !important;
            left: 50% !important;
            transform: translate(-50%, -50%) !important;
            background: white !important;
            border: none !important;
            border-radius: 16px !important;
            padding: 32px !important;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
            z-index: 1050 !important;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: opacity 0.2s ease, visibility 0s 0.2s !important;
            min-width: 320px !important;
            max-width: 90% !important;
            text-align: center;
            clip-path: none !important;
            will-change: opacity;
        }

        #serverMediaGrid .mcard.show-pop .confirm-pop {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transition: opacity 0.2s ease !important;
        }

        #serverMediaGrid .mcard.show-pop .confirm-pop {
            opacity: 1;
            pointer-events: auto;
        }

        #serverMediaGrid .mcard .confirm-pop .fname {
            color: #dc3545;
            word-break: break-word;
            font-weight: 600;
        }

        #serverMediaGrid .mcard .confirm-pop p {
            font-size: 16px;
            color: #1e293b;
            margin-bottom: 24px;
            line-height: 1.5;
        }

        #serverMediaGrid .mcard .confirm-pop .btn {
            padding: 10px 24px !important;
            font-size: 14px !important;
            border-radius: 8px !important;
            font-weight: 600 !important;
            min-width: 100px;
            transition: all 0.2s ease;
        }

        #serverMediaGrid .mcard .confirm-pop .btn-secondary {
            background: #ffffff !important;
            color: #6c757d !important;
            border: 2px solid #dee2e6 !important;
        }

            #serverMediaGrid .mcard .confirm-pop .btn-secondary:hover {
                background: #f8f9fa !important;
                border-color: #adb5bd !important;
                transform: translateY(-1px);
            }

        #serverMediaGrid .mcard .confirm-pop .btn-danger {
            background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
            border: none !important;
            box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
        }

            #serverMediaGrid .mcard .confirm-pop .btn-danger:hover {
                background: linear-gradient(135deg, #c82333 0%, #bd2130 100%) !important;
                transform: translateY(-1px);
                box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
            }

        /* Edit Metadata Popup */
        #serverMediaGrid .mcard .edit-meta-pop {
            position: fixed !important;
            top: 50% !important;
            left: 50% !important;
            transform: translate(-50%, -50%) !important;
            width: 90% !important;
            max-width: 440px !important;
            background: #ffffff !important;
            border: none !important;
            border-radius: 16px !important;
            padding: 32px !important;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
            display: none;
            visibility: hidden;
            z-index: 1050 !important;
            clip-path: none !important;
            will-change: opacity;
        }

        #serverMediaGrid .mcard.show-editor .edit-meta-pop {
            display: block;
            visibility: visible;
            animation: fadeIn 0.2s ease;
        }

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#serverMediaGrid .mcard.show-editor .edit-meta-pop {
    display: block;
}

/* Edit popup header - REMOVED */
#serverMediaGrid .mcard .edit-meta-pop::before {
    content: '';
    display: none;
}

/* Hide labels - using placeholders instead */
#serverMediaGrid .mcard .edit-meta-pop label {
    display: none;
}

/* Input fields */
#serverMediaGrid .mcard .edit-meta-pop input,
#serverMediaGrid .mcard .edit-meta-pop textarea {
    width: 100% !important;
    background: #f8fafc !important;
    color: #1e293b !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 12px 16px !important;
    margin-bottom: 16px !important;
    font-size: 15px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    resize: vertical;
    box-sizing: border-box;
    transition: all 0.2s ease !important;
}

    #serverMediaGrid .mcard .edit-meta-pop input::placeholder,
    #serverMediaGrid .mcard .edit-meta-pop textarea::placeholder {
        color: #adb5bd;
        opacity: 1;
    }

    #serverMediaGrid .mcard .edit-meta-pop input:focus,
    #serverMediaGrid .mcard .edit-meta-pop textarea:focus {
        outline: none !important;
        background: #ffffff !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
    }

#serverMediaGrid .mcard .edit-meta-pop textarea {
    min-height: 80px !important;
    max-height: 150px !important;
    overflow-y: auto;
    line-height: 1.6;
}

/* Action buttons */
#serverMediaGrid .mcard .edit-meta-pop .actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

    #serverMediaGrid .mcard .edit-meta-pop .actions button {
        padding: 12px 28px !important;
        border-radius: 10px !important;
        font-size: 15px !important;
        font-weight: 600 !important;
        border: none !important;
        cursor: pointer;
        transition: all 0.2s ease !important;
        min-width: 110px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

        #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="cancel-meta"] {
            background: #ffffff;
            color: #6c757d;
            border-color: #dee2e6;
        }

            #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="cancel-meta"]:hover {
                background: #f8f9fa;
                border-color: #adb5bd;
                transform: translateY(-1px);
            }

        #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="save-meta"] {
            background: #3498db;
            color: white;
            border-color: #3498db;
        }

            #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="save-meta"]:hover {
                background: #2980b9;
                border-color: #2980b9;
                transform: translateY(-1px);
                box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
            }

/* Full-screen backdrop when popups are open */
#serverMediaGrid .mcard.show-editor::before,
#serverMediaGrid .mcard.show-pop::before {
    content: '' !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 1040 !important;
    border-radius: 0 !important;
    clip-path: none !important;
    width: 100vw !important;
    height: 100vh !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
}

/* Loading state */
#serverMediaGrid .mcard.loading {
    opacity: 0.5;
    pointer-events: none;
}

    #serverMediaGrid .mcard.loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 24px;
        height: 24px;
        border: 2px solid #f3f4f6;
        border-top-color: #3498db;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
    }

/* Media Modal Footer */
.media-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

    .media-modal-footer .footer-left {
        display: flex;
        align-items: center;
        gap: 15px;
        margin-right: auto;
    }

    .media-modal-footer .pagination-info,
    .media-modal-footer .media-count {
        font-size: 14px;
        color: #666;
        margin: 0;
    }

    .media-modal-footer .pagination-controls {
        display: flex;
        gap: 8px;
    }

/* Responsive Design */
@media (max-width: 768px) {
    #serverMediaModal {
        --cell-min: 150px;
        --card-height: 210px;
        --thumb-size: 120px;
    }

        #serverMediaModal #serverMediaUpload span {
            display: none;
        }

        #serverMediaModal #serverMediaUpload {
            padding: 6px 10px;
        }

    #serverMediaGrid .mcard .toolbar {
        width: 34px;
        padding: 4px 3px;
    }

    #serverMediaGrid .mcard .toolbar-btn {
        width: 28px;
        height: 28px;
    }

        #serverMediaGrid .mcard .toolbar-btn i {
            font-size: 12px;
        }

    #serverMediaGrid .mcard .card-content {
        padding: 10px;
    }

    #serverMediaGrid .mcard .edit-meta-pop {
        width: 90%;
    }
}

/* ========================================
   SMOOTH LOADING & IMPROVED CARD STYLING
   ======================================== */

/* Smooth loading overlay for grid */
#serverMediaGrid.loading {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.loading-overlay {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1000 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 24px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Smooth card entrance animation */
#serverMediaGrid .mcard {
    animation: cardFadeIn 0.3s ease;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* IMPROVED CARD STYLING */

/* Better gradient for toolbar */
#serverMediaGrid .mcard .toolbar {
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 50%, #f1f3f5 100%) !important;
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.04);
}

/* Cleaner card hover effect */
#serverMediaGrid .mcard {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border: 1px solid #e5e7eb !important;
}

    #serverMediaGrid .mcard:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06) !important;
        transform: translateY(-3px) !important;
        border-color: #cbd5e1 !important;
    }

    /* Better thumbnail styling with subtle border */
    #serverMediaGrid .mcard .thumb-wrap {
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
        border: 2px solid #e5e7eb !important;
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
    }

        #serverMediaGrid .mcard .thumb-wrap:hover {
            transform: scale(1.05) !important;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
            border-color: #cbd5e1 !important;
        }

        /* Add a subtle play icon overlay for videos */
        #serverMediaGrid .mcard .thumb-wrap video::after {
            content: '▶';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 32px;
            color: rgba(255, 255, 255, 0.9);
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        #serverMediaGrid .mcard .thumb-wrap:hover video::after {
            opacity: 1;
        }

    /* Better text styling */
    #serverMediaGrid .mcard .meta .title {
        font-weight: 600 !important;
        color: #1e293b !important;
        letter-spacing: -0.01em;
    }

    #serverMediaGrid .mcard .meta .desc {
        color: #64748b !important;
        line-height: 1.5 !important;
    }

    /* Improved toolbar button hover effects */
    #serverMediaGrid .mcard .toolbar-btn {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

        #serverMediaGrid .mcard .toolbar-btn:hover {
            transform: scale(1.1);
        }

        #serverMediaGrid .mcard .toolbar-btn.remove-btn:hover {
            background: rgba(239, 68, 68, 0.12) !important;
            border-color: rgba(239, 68, 68, 0.24) !important;
            color: #ef4444 !important;
        }

        #serverMediaGrid .mcard .toolbar-btn.edit-meta-btn:hover {
            background: rgba(59, 130, 246, 0.12) !important;
            border-color: rgba(59, 130, 246, 0.24) !important;
            color: #3b82f6 !important;
        }

    /* Better popup styling */
    #serverMediaGrid .mcard .confirm-pop {
        background: #ffffff !important;
        border: none !important;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    }

    #serverMediaGrid .mcard .edit-meta-pop {
        background: #ffffff !important;
        border: none !important;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    }

    /* Improved popup overlay */
    #serverMediaGrid .mcard.show-editor::before,
    #serverMediaGrid .mcard.show-pop::before {
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(4px) !important;
    }

/* Better footer styling */
.media-modal-footer {
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%) !important;
    border-top: 1px solid #e5e7eb !important;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}

    .media-modal-footer .pagination-info {
        font-weight: 500;
        color: #475569 !important;
    }

    /* Better pagination button styling */
    .media-modal-footer .pagination-controls button {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
        font-weight: 500 !important;
    }

        .media-modal-footer .pagination-controls button:hover:not(:disabled) {
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            border-color: #94a3b8 !important;
            background: #f8fafc !important;
        }

        .media-modal-footer .pagination-controls button:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

/* Add subtle grid background pattern */
#serverMediaGrid {
    background-image: linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
    padding: 4px;
}

    /* Stagger animation for cards on page load */
    #serverMediaGrid .mcard:nth-child(1) {
        animation-delay: 0.05s;
    }

    #serverMediaGrid .mcard:nth-child(2) {
        animation-delay: 0.1s;
    }

    #serverMediaGrid .mcard:nth-child(3) {
        animation-delay: 0.15s;
    }

    #serverMediaGrid .mcard:nth-child(4) {
        animation-delay: 0.2s;
    }

    #serverMediaGrid .mcard:nth-child(5) {
        animation-delay: 0.25s;
    }

    #serverMediaGrid .mcard:nth-child(6) {
        animation-delay: 0.3s;
    }

    #serverMediaGrid .mcard:nth-child(7) {
        animation-delay: 0.35s;
    }

    #serverMediaGrid .mcard:nth-child(8) {
        animation-delay: 0.4s;
    }

    /* Rest of cards fade in together */
    #serverMediaGrid .mcard:nth-child(n+9) {
        animation-delay: 0.45s;
    }


/* ========================================
   10. DEVICE SETTINGS MODAL
   ======================================== */
#deviceSettingsModal .modal-dialog {
    max-width: min(750px, 94vw);
}

#deviceSettingsModal .modal-content {
    --pad: clamp(14px, 2vw, 22px);
    --gap: clamp(12px, 1.6vw, 18px);
    --rad: 12px;
    --thumb-cap: 260px;
}

#deviceSettingsModal .modal-body {
    padding-inline: var(--pad);
    padding-bottom: clamp(6px, 0.8vw, 10px);
}

/* Name Field */
#deviceSettingsModal .ds-name {
    grid-column: 1 / -1;
    margin-bottom: clamp(12px, 1.6vw, 18px);
}

    #deviceSettingsModal .ds-name .form-floating > .form-control {
        --ctrl-h: clamp(48px, 6.4vh, 56px);
        --ctrl-fs: clamp(16px, 1.05vw, 18px);
        height: var(--ctrl-h);
        font-size: var(--ctrl-fs);
    }

/* Two Column Layout */
#deviceSettingsModal .device-settings-top {
    display: grid;
    grid-template-columns: clamp(200px, 28vw, var(--thumb-cap)) minmax(360px, 1fr);
    align-items: stretch;
    column-gap: var(--gap);
    row-gap: var(--gap);
}

/* Preview Thumbnail Container */
#deviceSettingsModal .ds-thumb,
#deviceSettingsModal .thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--rad);
    overflow: hidden;
    background: #0b0b0b;
    border: 1px solid #e5e7eb;
    cursor: pointer;
}

    #deviceSettingsModal .thumb-wrap img,
    #deviceSettingsModal .thumb-wrap video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

/* Edit Icon Overlay */
#deviceSettingsModal .thumb-edit-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    z-index: 5;
}

/* Edit Icon Container */
#deviceSettingsModal .edit-icon-container {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

    #deviceSettingsModal .edit-icon-container i {
        color: rgba(255, 255, 255, 0.9);
        font-size: 14px;
    }

    #deviceSettingsModal .edit-icon-container .edit-text {
        color: rgba(255, 255, 255, 0.9);
        font-size: 12px;
        font-weight: 500;
        margin: 0;
        line-height: 1;
    }

/* Hover Effects */
#deviceSettingsModal .thumb-wrap:hover .thumb-edit-overlay {
    background: rgba(0, 0, 0, 0.2);
}

#deviceSettingsModal .thumb-wrap:hover .edit-icon-container {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

/* Right Column */
#deviceSettingsModal .ds-right {
    align-self: stretch;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
}


/* Toggles */
#deviceSettingsModal .ds-toggles {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    gap: calc(var(--gap) * 0.85);
}

#deviceSettingsModal .toggle-row {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 14px;
    min-height: 42px;
}

#deviceSettingsModal .toggle-text {
    font-size: clamp(16px, 1.2vw, 20px);
    line-height: 1.35;
    user-select: none;
    color: #495057;
    margin-right: auto;
    margin-top: 7px;
}

/* Version */
#deviceSettingsModal .ds-version {
    margin-top: auto;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 12px;
    font-weight: 600;
    font-size: clamp(16px, 1vw, 18px);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    #deviceSettingsModal .device-settings-top {
        grid-template-columns: 1fr;
    }

    #deviceSettingsModal .ds-thumb {
        max-width: 260px;
        margin: 0 auto;
    }

    #deviceSettingsModal .ds-right {
        height: auto;
    }
}

/* ========================================
   11. OTHER UI COMPONENTS
   ======================================== */

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

    #loading-overlay.hidden {
        display: none;
    }

.spinner {
    width: 60px;
    height: 60px;
    border: 8px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Notification */
#ajax_result {
    position: absolute;
    z-index: 1001;
    bottom: 0;
    left: 0;
    right: 0;
    background: red;
    font-weight: bold;
    color: white;
    text-align: center;
    line-height: 3.5;
    overflow: hidden;
    -webkit-box-shadow: 0 0 5px black;
    -moz-box-shadow: 0 0 5px black;
    box-shadow: 0 0 5px black;
}

/* Thumb Flash Animation */
.thumb-wrap.flash {
    animation: thumbFlash 700ms ease-out 1;
}

/* Zone Modal */
.zone-modal .modal-dialog {
    max-width: 640px;
}

.zone-modal .modal-content {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    overflow: hidden;
}

.zone-modal .field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.zone-modal .zone-full {
    grid-column: 1 / -1;
}

/* Zone Container */
#ZoneContainer svg g.zone-group {
    cursor: pointer;
}

/* iOS Style Lists */
.content-wrapper {
    padding: 0 16px;
}

.ios-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

    .ios-list li {
        border-bottom: 1px solid #ccc;
        margin: 0 -16px;
        padding: 0 16px;
    }

.ios-input {
    width: 100%;
    border: none;
    padding: 16px 0;
    font-size: 17px;
    background: transparent;
    box-sizing: border-box;
    outline: none;
    -webkit-appearance: none;
}

    .ios-input::placeholder {
        color: #888;
        font-weight: 500;
    }

/* Action Buttons */
.action-row .action-btn {
    width: 100%;
    padding: 16px 0;
    font-size: 18px;
    font-weight: 600;
    border-radius: 0;
    border: none;
}

.btn-success.action-btn {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.btn-danger.action-btn {
    background-color: rgba(192, 0, 0, 0.1);
    color: #c00;
}

/* About Section */
.about-section {
    margin: 24px 0 16px;
    padding: 0;
}

    .about-section h2 {
        font-size: 20px;
        font-weight: bold;
        margin-bottom: 12px;
        color: #000;
    }

.about-links {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}

    .about-links li {
        margin-bottom: 6px;
        font-size: 15px;
    }

    .about-links a {
        text-decoration: none;
        color: #007aff;
    }

/* Account Management */
.remove-account-container {
    text-align: left;
    margin-bottom: 8px;
}

.remove-account-link {
    font-size: 14px;
    color: #c00;
    text-decoration: none;
}

.ios-list li.action-row:last-child {
    border-bottom: none !important;
}

.action-btn,
#btnConfirm,
#btnLogout {
    box-shadow: none !important;
}

/* Layout States */
.list-group-item.selected-card {
    background-color: #f4364c !important;
    color: white !important;
}

    .list-group-item.selected-card .SortableLabel,
    .list-group-item.selected-card .LayoutStatus,
    .list-group-item.selected-card img {
        color: white !important;
        filter: brightness(0) invert(1) !important;
    }

.list-group-item .LayoutStatus.playing-label {
    color: #f4364c !important;
}

.disabled-btn {
    opacity: 0.4 !important;
}

/* Audience Monitor Modal */
#audienceMonitorModal .modal-content {
    background: #fff;
    border: 1px solid rgba(0,0,0,.06);
    box-shadow: 0 14px 28px rgba(0,0,0,.22), 0 10px 10px rgba(0,0,0,.12);
}

#audienceMonitorList .list-group-item {
    background: #fff;
    border-color: #e9ecef;
}

    #audienceMonitorList .list-group-item.active,
    #audienceMonitorList .list-group-item.active:hover,
    #audienceMonitorList .list-group-item.active:focus {
        background: #0d6efd;
        color: #fff;
        border-color: #0d6efd;
        box-shadow: 0 0 0 3px rgba(13,110,253,.2) inset;
    }

        #audienceMonitorList .list-group-item.active .fa-check {
            color: #fff !important;
            opacity: 1 !important;
        }

    #audienceMonitorList .list-group-item:not(.active):hover {
        background: #f8fafc;
    }

/* Select Wrappers */
.select-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

    .select-wrapper select {
        appearance: none;
        width: 100%;
        background: transparent;
        border: none;
        padding-right: 24px;
        font-size: 1rem;
        color: #888;
        text-align: right;
        cursor: pointer;
    }

        .select-wrapper select:focus {
            outline: none;
        }

    .select-wrapper .arrow {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        font-size: 1rem;
        color: #ccc;
    }

/* Login Elements */
#btnLogin {
    cursor: pointer;
    font-size: 28px;
    font-weight: bold;
    color: white;
}

/* Background Elements */
.img {
    height: 512px;
    left: 50%;
    margin-top: -256px;
    margin-left: -256px;
    position: absolute;
    top: 45%;
    width: 512px;
    z-index: -9998;
}

.background {
    min-height: 100%;
    min-width: 1024px;
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
    z-index: -9999;
}

/* ========================================
   12. TOGGLE SWITCHES (CONSOLIDATED)
   ======================================== */

/* Toggle Container */
.toggle-container {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    vertical-align: middle;
}

    /* Hide the actual checkbox */
    .toggle-container input[type="checkbox"] {
        opacity: 0;
        width: 0;
        height: 0;
        position: absolute;
        pointer-events: none;
    }

    /* The toggle background/track */
    .toggle-container label {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        width: 51px;
        height: 31px;
        background-color: #e5e5ea;
        border-radius: 15.5px;
        transition: background-color 0.3s;
        margin: 0;
        padding: 0;
    }

        /* The white sliding knob */
        .toggle-container label::before {
            position: absolute;
            content: "";
            height: 27px;
            width: 27px;
            left: 2px;
            top: 2px;
            background-color: white;
            border-radius: 50%;
            transition: transform 0.3s;
            box-shadow: 0 3px 1px 0 rgba(0, 0, 0, 0.04), 0 3px 8px 0 rgba(0, 0, 0, 0.12);
        }

    /* Checked state - green background */
    .toggle-container input[type="checkbox"]:checked + label {
        background-color: #4CD964;
    }

        /* Checked state - knob slides right */
        .toggle-container input[type="checkbox"]:checked + label::before {
            transform: translateX(20px);
        }

    /* Hover effect */
    .toggle-container:hover label {
        box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
    }

    /* Disabled state */
    .toggle-container input[type="checkbox"]:disabled + label {
        opacity: 0.5;
        cursor: not-allowed;
    }

        .toggle-container input[type="checkbox"]:disabled + label::before {
            box-shadow: none;
        }

    /* Remove any conflicting styles from specific IDs */
    .toggle-container #IsAuto,
    .toggle-container #DuckingSwitch,
    .toggle-container #flexSwitchDriverMic,
    .toggle-container #flexSwitchPassengerMic,
    .toggle-container #DriverMute,
    .toggle-container #PassengerMute,
    .toggle-container #MicMute {
        opacity: 0;
        width: 0;
        height: 0;
        position: absolute;
    }

    /* Ensure no ::before or ::after on the checkboxes themselves */
    .toggle-container input[type="checkbox"]::before,
    .toggle-container input[type="checkbox"]::after {
        content: none !important;
        display: none !important;
    }

/* Ensure proper flex alignment when toggle is in a flex container */
.FlexDisplay .toggle-container,
.FlexBorder .toggle-container {
    margin: 0;
    align-self: center;
}

/* Fix any label text near toggles */
.toggle-container + .DarkLargeLabel,
.DarkLargeLabel + .toggle-container {
    margin: 0 10px;
}

/* Ensure z-index doesn't cause issues */
.toggle-container,
.toggle-container * {
    z-index: auto;
}

/* Mobile responsiveness */
@media (max-width: 767px) {
    .toggle-container {
        width: 51px;
        height: 31px;
    }

        .toggle-container label {
            width: 51px;
            height: 31px;
        }
}

/* ========================================
   13. TRACKBAR CONTROLS (CONSOLIDATED)
   ======================================== */

/* Main Trackbar Container - Universal */
.trackbar,
#MaxDay,
#MinNight,
#ManAdj,
#DriverVolume,
#PassengerVolume,
#MicVolume {
    position: relative !important;
    width: 100%;
    height: 30px;
    background-color: #e3e3e8;
    border-radius: 15px;
    cursor: pointer;
    overflow: visible;
    margin: 0;
}

/* Track Line (if present - used in Brightness page) */
.track-line {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: transparent;
    border-radius: 15px;
    pointer-events: none;
}

/* Trackbar Fill (Red Progress Bar) */
.track-selector {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background-color: #F4364C;
    border-radius: 15px;
    transition: width 0.1s ease-out;
    pointer-events: none;
    z-index: 1;
}

/* Trackbar Knob/Button */
.track-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) translateX(-50%);
    width: 36px;
    height: 36px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 3px 8px 0 rgba(0, 0, 0, 0.15), 0 1px 1px 0 rgba(0, 0, 0, 0.16), 0 3px 1px -2px rgba(0, 0, 0, 0.1);
    cursor: grab;
    transition: left 0.1s ease-out;
    pointer-events: none;
    z-index: 2;
}

/* Floating Percentage Tooltip (Speech Bubble Style) */
.track-percentage {
    position: absolute !important;
    top: -45px;
    left: 0;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: block;
}

    /* Arrow pointing down to the knob */
    .track-percentage::after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-top: 8px solid rgba(0, 0, 0, 0.9);
    }

/* Static Level Label (Brightness page) - Preserve existing functionality */
.FlexDisplay .track-level,
label.track-level {
    position: static !important;
    background: none !important;
    color: #8E8E93 !important;
    font-size: 17px !important;
    padding: 0 !important;
    border-radius: 0 !important;
    opacity: 1 !important;
    display: block !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    text-align: right;
    min-width: 50px;
    font-weight: 500;
    margin: 0;
}

/* Floating tooltip for track-level when inside trackbar */
.trackbar .track-level:not(label) {
    position: absolute !important;
    top: -40px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    padding: 5px 10px !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: block !important;
}

/* Show floating tooltips on interaction */
.track-percentage.active,
.trackbar:hover .track-percentage,
.trackbar:active .track-percentage,
.trackbar.dragging .track-percentage,
#MaxDay:hover .track-percentage,
#MaxDay:active .track-percentage,
#MinNight:hover .track-percentage,
#MinNight:active .track-percentage,
#ManAdj:hover .track-percentage,
#ManAdj:active .track-percentage,
#DriverVolume:hover .track-percentage,
#DriverVolume:active .track-percentage,
#PassengerVolume:hover .track-percentage,
#PassengerVolume:active .track-percentage,
#MicVolume:hover .track-percentage,
#MicVolume:active .track-percentage,
.trackbar:active .trackbar .track-level,
.trackbar:hover .trackbar .track-level,
.trackbar.dragging .track-percentage {
    opacity: 1 !important;
}

/* Hover state for desktop */
.trackbar:hover .track-percentage,
.trackbar:hover .trackbar .track-level {
    opacity: 0.8;
}

/* Active/Dragging States */
.trackbar:active .track-button,
.trackbar.dragging .track-button {
    cursor: grabbing;
    transform: translateY(-50%) translateX(-50%) scale(1.05);
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.25);
}

.trackbar.dragging .track-selector {
    transition: none;
}

/* Volume/Brightness Control Icons */
.track-decr,
.track-incr {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a8a8e;
    padding: 0;
    z-index: 10;
}

.track-decr {
    left: -40px;
}

.track-incr {
    right: -40px;
}

.track-decr::before {
    content: "🔉";
    font-size: 22px;
}

.track-incr::before {
    content: "🔊";
    font-size: 22px;
}

/* Disabled State */
.disabled-trackbar {
    opacity: 0.5;
}

    .disabled-trackbar .track-selector {
        background-color: #c7c7cc !important;
    }

    .disabled-trackbar .track-button {
        cursor: not-allowed;
    }

    .disabled-trackbar:active .track-button {
        cursor: not-allowed;
        transform: translateY(-50%) translateX(-50%);
    }

/* Ensure proper layering */
.trackbar > * {
    position: absolute;
}

.trackbar .track-line {
    z-index: 0;
}

.trackbar .track-selector {
    z-index: 1;
}

.trackbar .track-button {
    z-index: 2;
}

.trackbar .track-percentage,
.trackbar .track-level:not(label) {
    z-index: 100;
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .trackbar,
    #MaxDay,
    #MinNight,
    #ManAdj,
    #DriverVolume,
    #PassengerVolume,
    #MicVolume {
        height: 30px;
    }

    .track-button {
        width: 36px;
        height: 36px;
    }

    .track-percentage,
    .trackbar .track-level:not(label) {
        font-size: 12px;
        padding: 4px 8px;
        top: -38px;
    }
}

/* ========================================
   14. ANIMATIONS (CONSOLIDATED)
   ======================================== */

/* Spin Animation (single definition) */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Thumb Flash Animation */
@keyframes thumbFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(76,175,80,0);
        transform: scale(1);
    }

    35% {
        box-shadow: 0 0 0 12px rgba(76,175,80,.35);
        transform: scale(1.02);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76,175,80,0);
        transform: scale(1);
    }
}


/* ========================================
   UPDATED SERVER MEDIA MODAL STYLES
   Add these to your Site.css file
   ======================================== */

/* Updated Toolbar - Split into two sections */
#serverMediaGrid .mcard .toolbar {
    width: 38px;
    background: transparent;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    flex-shrink: 0;
    height: 100%;
}

/* Toolbar Sections */
/* REMOVED - No longer using toolbar-section divs */

/* Updated Toolbar Buttons - Full-width colored tabs */
#serverMediaGrid .mcard .toolbar-btn {
    width: 40px !important;
    height: 50% !important; /* Each button takes half the toolbar height */
    background: rgba(255, 255, 255, 0.8);
    border: none !important;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
}

    /* Remove button styling - RED gradient tab */
    #serverMediaGrid .mcard .toolbar-btn.remove-btn {
        background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%) !important;
        color: white !important;
        border-radius: 10px 0 0 0 !important; /* Rounded top-left corner only */
        border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    }

        #serverMediaGrid .mcard .toolbar-btn.remove-btn:hover {
            background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%) !important;
            transform: scale(1.05) !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 6px rgba(220, 53, 69, 0.3) !important;
        }

        /* Remove button icon */
        #serverMediaGrid .mcard .toolbar-btn.remove-btn i {
            color: white !important;
            font-size: 18px !important;
            filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
        }


    /* Edit button styling - BLUE gradient tab */
    #serverMediaGrid .mcard .toolbar-btn.edit-meta-btn {
        background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%) !important;
        color: white !important;
        border-radius: 0 0 0 10px !important; /* Rounded bottom-left corner only */
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    }

        #serverMediaGrid .mcard .toolbar-btn.edit-meta-btn:hover {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
            transform: scale(1.05) !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 6px rgba(52, 152, 219, 0.3) !important;
        }

        /* Edit button icon */
        #serverMediaGrid .mcard .toolbar-btn.edit-meta-btn i {
            color: white !important;
            font-size: 18px !important;
            filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
        }


/* Ensure Square Thumbnails */
#serverMediaGrid .mcard .thumb-wrap {
    width: 100%;
    max-width: var(--thumb-size);
    aspect-ratio: 1 / 1; /* Force square aspect ratio */
    height: auto; /* Remove fixed height */
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
}

    /* Ensure media fills the square container */
    #serverMediaGrid .mcard .thumb-wrap img,
    #serverMediaGrid .mcard .thumb-wrap video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover; /* Crop to fill square */
        display: block;
    }

/* Remove any video controls and overlays */
#serverMediaGrid .mcard video {
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

    /* Hide all video controls */
    #serverMediaGrid .mcard video::-webkit-media-controls {
        display: none !important;
    }

    #serverMediaGrid .mcard video::-webkit-media-controls-start-playback-button {
        display: none !important;
    }

    #serverMediaGrid .mcard video::-webkit-media-controls-overlay-play-button {
        display: none !important;
    }

/* Add Border to Metadata Section */
#serverMediaGrid .mcard .meta {
    width: 100%;
    padding: 8px;
    text-align: center;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    background: #fafbfc;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    margin-top: 8px;
}

    /* Metadata Title */
    #serverMediaGrid .mcard .meta .title {
        font-size: 13px;
        font-weight: 600;
        color: #24292e;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
    }

    /* Metadata Description */
    #serverMediaGrid .mcard .meta .desc {
        font-size: 11px;
        color: #586069;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.4;
        opacity: 0.9;
    }

        /* Empty description state */
        #serverMediaGrid .mcard .meta .desc:empty {
            display: none;
        }

/* Card hover effect adjustment */
#serverMediaGrid .mcard:hover .meta {
    border-color: #c8d1db;
    background: #f6f8fa;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #serverMediaGrid .mcard .toolbar {
        width: 36px;
    }

    #serverMediaGrid .mcard .toolbar-section {
        padding: 4px 3px;
    }

    #serverMediaGrid .mcard .toolbar-btn {
        width: 28px;
        height: 28px;
    }

    #serverMediaGrid .mcard .meta {
        padding: 6px;
        font-size: 12px;
    }
}
/* ========================================
   FIX: Edit Details Popup Styling
   ======================================== */

/* Better popup positioning and sizing */
#serverMediaGrid .mcard .edit-meta-pop {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90% !important;
    max-width: 440px !important;
    padding: 32px !important;
    border-radius: 16px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    z-index: 1050 !important;
    border: none !important;
}

    /* Header styling - REMOVED */
    #serverMediaGrid .mcard .edit-meta-pop::before {
        content: '';
        display: none !important;
    }

    /* Input fields */
    #serverMediaGrid .mcard .edit-meta-pop input,
    #serverMediaGrid .mcard .edit-meta-pop textarea {
        width: 100% !important;
        background: #f8fafc !important;
        border: 2px solid #e2e8f0 !important;
        border-radius: 10px !important;
        padding: 10px 14px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        color: #1e293b !important;
        margin-bottom: 12px !important;
        transition: all 0.2s ease !important;
    }

        #serverMediaGrid .mcard .edit-meta-pop input:focus,
        #serverMediaGrid .mcard .edit-meta-pop textarea:focus {
            background: #ffffff !important;
            border-color: #3b82f6 !important;
            box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
            outline: none !important;
        }

    #serverMediaGrid .mcard .edit-meta-pop textarea {
        min-height: 60px !important;
        max-height: 90px !important;
        resize: vertical !important;
        font-family: inherit !important;
    }

        /* Placeholder text */
        #serverMediaGrid .mcard .edit-meta-pop input::placeholder,
        #serverMediaGrid .mcard .edit-meta-pop textarea::placeholder {
            color: #94a3b8 !important;
            font-weight: 400 !important;
        }

    /* Action buttons container */
    #serverMediaGrid .mcard .edit-meta-pop .actions {
        display: flex;
        justify-content: center !important;
        gap: 12px !important;
        margin-top: 12px !important;
        padding-top: 0 !important;
    }

        /* Cancel button */
        #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="cancel-meta"] {
            background: #ffffff !important;
            color: #6c757d !important;
            border: 2px solid #dee2e6 !important;
            border-radius: 10px !important;
            padding: 12px 28px !important;
            font-size: 15px !important;
            font-weight: 600 !important;
            cursor: pointer;
            transition: all 0.2s ease !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            text-align: center !important;
            min-width: 110px !important;
        }

            #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="cancel-meta"]:hover {
                background: #f8f9fa !important;
                border-color: #adb5bd !important;
                transform: translateY(-1px) !important;
            }

        /* Save button */
        #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="save-meta"] {
            background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
            color: white !important;
            border: none !important;
            border-radius: 10px !important;
            padding: 12px 32px !important;
            font-size: 15px !important;
            font-weight: 600 !important;
            cursor: pointer;
            transition: all 0.2s ease !important;
            box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4) !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            text-align: center !important;
            min-width: 110px !important;
        }

            #serverMediaGrid .mcard .edit-meta-pop .actions button[data-action="save-meta"]:hover {
                background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
                transform: translateY(-2px) !important;
                box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5) !important;
            }

/* Full-screen backdrop when edit popup is open */
#serverMediaGrid .mcard.show-editor::before {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 1040 !important;
    border-radius: 0 !important;
}


/* ========================================
   GLOBAL MODALS (Direct children of body)
   ======================================== */

/* Delete Confirmation Modal */
body > .confirm-pop {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: white !important;
    border: none !important;
    border-radius: 16px !important;
    padding: 32px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    z-index: 1050 !important;
    min-width: 320px !important;
    max-width: 90% !important;
    text-align: center;
    pointer-events: auto !important;
}

    body > .confirm-pop p {
        font-size: 16px;
        color: #1e293b;
        margin-bottom: 24px;
        line-height: 1.5;
    }

    body > .confirm-pop .fname {
        color: #dc3545;
        font-weight: 600;
    }

    body > .confirm-pop .btn {
        padding: 10px 24px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
        font-weight: 600 !important;
        min-width: 100px;
    }

    body > .confirm-pop .btn-secondary {
        background: #ffffff !important;
        color: #6c757d !important;
        border: 2px solid #dee2e6 !important;
    }

    body > .confirm-pop .btn-danger {
        background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
        border: none !important;
    }

/* Edit Details Modal */
body > .edit-meta-pop {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90% !important;
    max-width: 440px !important;
    background: #ffffff !important;
    border: none !important;
    border-radius: 16px !important;
    padding: 32px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    z-index: 1050 !important;
}

    body > .edit-meta-pop input,
    body > .edit-meta-pop textarea {
        width: 100% !important;
        background: #f8fafc !important;
        color: #1e293b !important;
        border: 2px solid #e2e8f0 !important;
        border-radius: 10px !important;
        padding: 12px 16px !important;
        margin-bottom: 16px !important;
        font-size: 15px !important;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        resize: vertical;
        box-sizing: border-box;
    }

    body > .edit-meta-pop textarea {
        min-height: 80px !important;
        max-height: 150px !important;
        line-height: 1.6;
    }

        body > .edit-meta-pop input:focus,
        body > .edit-meta-pop textarea:focus {
            outline: none !important;
            background: #ffffff !important;
            border-color: #3b82f6 !important;
            box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
        }

    body > .edit-meta-pop .actions {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin-top: 20px;
    }

        body > .edit-meta-pop .actions button {
            padding: 12px 28px !important;
            border-radius: 10px !important;
            font-size: 15px !important;
            font-weight: 600 !important;
            cursor: pointer;
            min-width: 110px;
            border: none;
        }

            body > .edit-meta-pop .actions button[data-action="cancel-meta"] {
                background: #ffffff !important;
                color: #6c757d !important;
                border: 2px solid #dee2e6 !important;
            }

            body > .edit-meta-pop .actions button[data-action="save-meta"] {
                background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
                color: white !important;
                box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4) !important;
            }

/* Modal Backdrop */
body > .modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1040 !important;
}

/* ========================================
   PLAYLIST MANAGER (Video Editor Style)
   ======================================== */

/* Filter buttons */
[data-filter] {
    transition: all 0.3s ease !important;
    border: none !important;
}

    [data-filter]:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
    }

    [data-filter].active {
        background: #3b82f6 !important;
        color: white !important;
    }

/* Media & Sources Grid - EXACT Copy of Global Picker */
#playlistMediaGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px;
    align-items: start;
    /* Subtle grid background pattern - EXACT from global picker */
    background-image: linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
}

    /* Cards - EXACT Global Picker Styling with FIXED HEIGHT */
    #playlistMediaGrid .mcard {
        position: relative;
        height: 250px; /* FIXED HEIGHT for consistency */
        border: 1px solid #dee2e6;
        border-radius: 10px;
        background: white;
        overflow: hidden;
        display: flex;
        flex-direction: row; /* Horizontal: toolbar left, content right */
        align-items: stretch;
        padding: 0;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

        #playlistMediaGrid .mcard:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            transform: translateY(-1px);
            border-color: #d0d5db;
        }

        /* Disable transform when popups shown */
        #playlistMediaGrid .mcard.show-pop,
        #playlistMediaGrid .mcard.show-editor {
            transform: none !important;
            overflow: visible !important;
        }

            #playlistMediaGrid .mcard.show-pop:hover,
            #playlistMediaGrid .mcard.show-editor:hover {
                transform: none !important;
            }

        /* Left Toolbar - GRADIENT STYLE matching Global Picker */
        #playlistMediaGrid .mcard .toolbar {
            width: 40px;
            display: flex;
            flex-direction: column;
            padding: 0;
            flex-shrink: 0;
            background: transparent;
            border-right: none;
        }

        /* Toolbar Buttons - GRADIENT STYLE from Global Picker */
        #playlistMediaGrid .mcard .toolbar-btn {
            width: 40px;
            height: 50%; /* Each button takes half the toolbar height */
            background: rgba(255, 255, 255, 0.8);
            border: none;
            border-radius: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
            padding: 0;
            margin: 0;
            flex-shrink: 0;
        }

            /* Remove button - PINK/RED gradient tab */
            #playlistMediaGrid .mcard .toolbar-btn.remove-btn {
                background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%) !important;
                color: white !important;
                border-radius: 10px 0 0 0 !important; /* Rounded top-left only */
                border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;
                box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
            }

                #playlistMediaGrid .mcard .toolbar-btn.remove-btn:hover {
                    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%) !important;
                    transform: scale(1.05) !important;
                    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 6px rgba(220, 53, 69, 0.3) !important;
                }

                #playlistMediaGrid .mcard .toolbar-btn.remove-btn i {
                    color: white !important;
                    font-size: 18px !important;
                    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
                }

            /* Edit button - BLUE gradient tab */
            #playlistMediaGrid .mcard .toolbar-btn.edit-meta-btn {
                background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%) !important;
                color: white !important;
                border-radius: 0 0 0 10px !important; /* Rounded bottom-left only */
                box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
            }

                #playlistMediaGrid .mcard .toolbar-btn.edit-meta-btn:hover {
                    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
                    transform: scale(1.05) !important;
                    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 6px rgba(52, 152, 219, 0.3) !important;
                }

                #playlistMediaGrid .mcard .toolbar-btn.edit-meta-btn i {
                    color: white !important;
                    font-size: 18px !important;
                    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
                }

            /* Add button - Keep at bottom for now (will be removed later) */
            #playlistMediaGrid .mcard .toolbar-btn.add-btn {
                background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%) !important;
                color: white !important;
            }

                #playlistMediaGrid .mcard .toolbar-btn.add-btn:hover {
                    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%) !important;
                    transform: scale(1.05) !important;
                }

                #playlistMediaGrid .mcard .toolbar-btn.add-btn i {
                    color: white !important;
                    font-size: 18px !important;
                    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
                }

            /* Toolbar icons */
            #playlistMediaGrid .mcard .toolbar-btn i {
                pointer-events: none;
            }

        /* Card Content - FILLS REMAINING SPACE */
        #playlistMediaGrid .mcard .card-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-between; /* Space out thumbnail and metadata */
            padding: 12px;
            min-width: 0;
            gap: 8px;
        }

        /* Thumbnail - FIXED SIZE */
        #playlistMediaGrid .mcard .thumb-wrap {
            width: 100%;
            height: 140px; /* FIXED HEIGHT */
            max-width: none; /* Remove max-width constraint */
            background: #f8f9fa;
            border-radius: 8px;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            position: relative;
            cursor: pointer;
            transition: all 0.2s ease;
            border: 1px solid #e9ecef;
        }

            #playlistMediaGrid .mcard .thumb-wrap:hover {
                transform: scale(1.03);
                box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
                border-color: #dee2e6;
            }

            #playlistMediaGrid .mcard .thumb-wrap img,
            #playlistMediaGrid .mcard .thumb-wrap video {
                width: 100%;
                height: 100%;
                object-fit: cover;
                display: block;
            }

        /* Video thumbnails */
        #playlistMediaGrid .mcard video {
            pointer-events: none;
        }

        /* Metadata - CONSISTENT HEIGHT */
        #playlistMediaGrid .mcard .meta {
            width: 100%;
            padding: 8px 4px;
            text-align: center;
            min-height: 60px; /* FIXED minimum height */
            max-height: 80px; /* FIXED maximum height */
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            gap: 4px;
            overflow: hidden;
        }

            #playlistMediaGrid .mcard .meta .title {
                font-size: 13px;
                font-weight: 500;
                color: #2c3e50;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                line-height: 1.4;
            }

            #playlistMediaGrid .mcard .meta .desc {
                font-size: 11px;
                color: #6c757d;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                line-height: 1.3;
                opacity: 0.9;
            }

        /* Confirmation Popup */
        #playlistMediaGrid .mcard .confirm-pop {
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: white;
            border-radius: 10px;
            padding: 20px;
            z-index: 20;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }

        #playlistMediaGrid .mcard.show-pop .confirm-pop {
            display: flex;
        }

        #playlistMediaGrid .mcard .confirm-pop p {
            text-align: center;
            margin: 0 0 15px 0;
            font-size: 14px;
            color: #333;
        }

        #playlistMediaGrid .mcard .confirm-pop .fname {
            font-weight: 600;
            color: #dc3545;
        }

        /* Edit Popup */
        #playlistMediaGrid .mcard .edit-meta-pop {
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: white;
            border-radius: 10px;
            padding: 16px;
            z-index: 20;
            flex-direction: column;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }

        #playlistMediaGrid .mcard.show-editor .edit-meta-pop {
            display: flex;
        }

        #playlistMediaGrid .mcard .edit-meta-pop .actions {
            margin-top: 12px;
            display: flex;
            gap: 8px;
            justify-content: center;
        }

/* Timeline - At Top of Modal (15% height) - Mobile Friendly */
#playlistTimelineWrapper {
    position: relative;
    height: 100%;
}

/* Sources Panel Resize Handle */
#sourcesResizeHandle {
    position: relative;
    transition: background 0.2s ease !important;
}

    #sourcesResizeHandle:hover {
        background: rgba(59, 130, 246, 0.3) !important;
    }

    #sourcesResizeHandle.resizing {
        background: #3b82f6 !important;
    }

/* Media and Sources Sections */
#playlistMediaSection {
    transition: flex 0.1s ease-out;
}

#playlistSourcesSection {
    transition: flex 0.1s ease-out;
    min-width: 150px; /* Minimum width in pixels */
}

#playlistTimeline {
    cursor: grab;
    scrollbar-width: none !important; /* Hide scrollbar Firefox */
    -ms-overflow-scrolling: none !important; /* Hide scrollbar IE/Edge */
    -webkit-overflow-scrolling: touch !important; /* iOS momentum scrolling */
    height: 100%;
    padding: 8px 16px;
    touch-action: pan-x !important; /* Allow horizontal touch scrolling */
}

    #playlistTimeline.grabbing {
        cursor: grabbing !important;
        user-select: none;
    }

    /* Hide scrollbar for WebKit (Chrome, Safari) */
    #playlistTimeline::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

/* Timeline slides - Compact for top placement */
.timeline-slide {
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    min-height: 80px;
    max-height: 100px;
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
}

    .timeline-slide:active {
        cursor: grabbing;
    }

    .timeline-slide:hover {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 0 6px 16px rgba(0,0,0,0.15);
        z-index: 10;
    }

    .timeline-slide.sortable-chosen {
        opacity: 0.5;
        cursor: grabbing !important;
    }

    .timeline-slide.sortable-ghost {
        opacity: 0.3;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: 2px dashed #3b82f6;
    }

    .timeline-slide.sortable-drag {
        cursor: grabbing !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.25);
        transform: rotate(2deg);
        opacity: 1 !important;
        z-index: 10000 !important;
    }

/* Sortable fallback drag element */
/* Auto-save status */
#autoSaveStatus {
    font-size: 13px;
    font-weight: 500;
    transition: color 0.3s ease;
}


/* ========================================
   PUBLISH BUTTON - Modern Outline Style
   ======================================== */

#publishPlaylistChanges {
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.2);
}

    #publishPlaylistChanges:hover {
        background-color: #218838 !important;
        border-color: #1e7e34 !important;
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
    }

    #publishPlaylistChanges:active {
        transform: translateY(0);
        box-shadow: 0 2px 6px rgba(40, 167, 69, 0.2);
    }

    #publishPlaylistChanges .fa-paper-plane {
        transition: transform 0.2s ease;
    }

    #publishPlaylistChanges:hover .fa-paper-plane {
        transform: translateX(3px);
    }

/* ========================================
   ADD TO TIMELINE MODAL IMPROVEMENTS
   ======================================== */

/* Modal backdrop - darker for better focus */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

/* Floating delete button on preview */
#deleteFromModal {
    transition: all 0.2s ease;
}

    #deleteFromModal:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4) !important;
    }

/* Delete confirmation modal styling */
#deleteMediaConfirmModal .modal-content {
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#deleteMediaConfirmModal .modal-header {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
}

#deleteMediaConfirmModal .text-danger {
    color: #dc3545 !important;
}

/* Ensure modal and backdrop z-index is ABOVE header/footer (99999) */
#manageSlidesModal {
    z-index: 100001 !important;
}

    #manageSlidesModal .modal-dialog {
        z-index: 100002 !important;
    }

.modal-backdrop {
    z-index: 100000 !important;
}

/* Second level modals (add to timeline, delete confirm) */
#addToTimelineModal,
#deleteMediaConfirmModal {
    z-index: 100010 !important;
}

    #addToTimelineModal + .modal-backdrop,
    #deleteMediaConfirmModal + .modal-backdrop {
        z-index: 100009 !important;
    }

/* ========================================
   PLAYLIST MEDIA/SOURCE GRID - Loading State
   (Matching Global Picker Exactly)
   ======================================== */

/* Grid loading state - dim existing content */
#playlistMediaGrid.loading {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.2s ease;
    position: relative;
    min-height: 400px;
}

/* Loading overlay - matches global picker exactly */
#playlistMediaGrid .loading-overlay {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1000 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 24px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

    #playlistMediaGrid .loading-overlay .spinner-border {
        width: 2rem !important;
        height: 2rem !important;
        border-width: 0.25em !important;
        color: #007bff !important;
    }

    #playlistMediaGrid .loading-overlay .loading-text {
        margin-top: 12px !important;
        color: #495057 !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        white-space: nowrap !important;
    }

/* Media and Sources Container - Same hash pattern as global picker */
#playlistMediaContainer,
#playlistSourcesContainer {
    background-image: linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
}

/* Prevent text selection during timeline drag */
#playlistTimeline.dragging-timeline {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Ensure scrolling is enabled (programmatic) */
    overflow-x: auto !important;
    /* Prevent touch-based scrolling (but allow programmatic scrolling) */
    touch-action: none !important;
    overscroll-behavior: none !important;
}

/* Timeline slide cursor states */
.timeline-slide {
    cursor: grab !important;
}

    .timeline-slide:active {
        cursor: grabbing !important;
    }

    /* Visual feedback during hold delay - NO TEXT */
    .timeline-slide.sortable-chosen {
        cursor: grabbing !important;
        border-color: #667eea !important;
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.4) !important;
        opacity: 0.6 !important;
        animation: pickup-pulse 0.3s ease-out !important;
    }

@keyframes pickup-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }

    50% {
        transform: scale(0.98);
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0.2);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.4);
    }
}

/* Drag element that follows cursor - DRAMATIC POPOUT! */
/* Drag element that follows cursor - DRAMATIC POPOUT! */
.sortable-fallback {
    /* CRITICAL: Make absolutely sure it's visible! */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    cursor: grabbing !important;
    z-index: 100000 !important;
    /* Professional popout effect */
    transform: scale(1.1) translateY(-10px) !important;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6), 0 0 0 3px rgba(102, 126, 234, 0.5) !important;
    border: 3px solid rgba(102, 126, 234, 1) !important;
    /* Smooth animation */
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    /* Enhance visibility */
    filter: brightness(1.1) contrast(1.05) !important;
    background: inherit !important;
    pointer-events: none !important;
}

    /* Ensure timeline slides inside fallback are visible */
    .sortable-fallback .timeline-slide {
        opacity: 1 !important;
        visibility: visible !important;
    }

/* Remove the animation that was conflicting with JavaScript transform */

/* Ghost placeholder where slide will drop */
.timeline-slide.sortable-ghost {
    opacity: 0.6 !important; /* More visible (was 0.4) */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: 4px dashed #667eea !important; /* Thicker border (was 3px) */
    animation: ghost-pulse 0.8s ease-in-out infinite !important; /* Faster pulse (was 1s) */
    transform: scale(1.02) !important; /* Slightly larger */
}

@keyframes ghost-pulse {
    0%, 100% {
        opacity: 0.6; /* Higher opacity */
        border-color: #667eea;
    }

    50% {
        opacity: 0.8; /* Even more visible at peak */
        border-color: #764ba2;
    }
}

}

50% {
    opacity: 0.6;
    border-color: #764ba2;
}

}

/* Currently dragging element */
.timeline-slide.sortable-drag {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: scale(1.1) translateY(-10px) !important;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6), 0 0 0 3px rgba(102, 126, 234, 0.5) !important;
    filter: brightness(1.1) contrast(1.05) !important;
    border: 3px solid rgba(102, 126, 234, 1) !important;
    z-index: 100000 !important;
    cursor: grabbing !important;
}

/* Buttons should not have grab cursor */
.timeline-slide button,
.timeline-slide .btn {
    cursor: pointer !important;
}

/* ========================================
   Modal Backdrop Fix - Cover Header & Footer
   ======================================== */

/* Make modal backdrop cover everything including header and footer */
.modal-backdrop {
    z-index: 1040 !important; /* Above header/footer (usually z-index: 1000) */
}

/* Modal itself above backdrop */
.modal {
    z-index: 1050 !important; /* Above backdrop */
}

/* Ensure header stays below modal */
header,
.site-header,
.navbar {
    z-index: 1000 !important;
}

/* Ensure footer stays below modal */
footer,
.site-footer {
    z-index: 1000 !important;
}
