:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --primary-color: #bb86fc;
    --secondary-color: #03dac6;
    --error-color: #cf6679;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding-top: 60px;
    /* Space for fixed navbar */
}

/* Layout */
.layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--card-bg);
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid #333;
    z-index: 100;
}

.sidebar-btn {
    box-sizing: border-box;
    /* Crucial for matching button and anchor widths */
    background-color: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 8px;
    width: 90%;
    height: 50px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    text-decoration: none;
}

.sidebar-btn .icon {
    font-size: 1.4rem;
    margin-bottom: 0;
    line-height: 1;
}

.sidebar-btn:hover {
    transform: scale(1.02);
    background-color: #9965f4;
}

.logout-btn {
    background-color: rgba(207, 102, 121, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(207, 102, 121, 0.2);
    text-decoration: none;
    margin-bottom: 20px;
    margin-top: 20px;
}

.logout-btn:hover {
    background-color: var(--error-color) !important;
    color: #fff;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    margin-left: 270px;
    /* Match sidebar width */
    padding: 20px;
    max-width: 900px;
    margin-right: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.visible {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal.visible .modal-content {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: #fff;
}


/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--card-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 900;
    box-sizing: border-box;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.navbar-controls {
    display: flex;
    gap: 15px;
}

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger span {
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 10px;
    transition: all 0.3s linear;
}

.nav-btn {
    border: none;
    color: #000;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform 0.1s, opacity 0.2s;
}

.nav-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-btn.play {
    background-color: var(--secondary-color);
}

.nav-btn.pause {
    background-color: #ffb74d;
}

.nav-btn.restart {
    background-color: #4fc3f7;
}

.nav-btn.next {
    background-color: var(--primary-color);
}

.nav-btn:disabled,
.sidebar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
    transform: none !important;
}


.container {
    width: 100%;
    max-width: 800px;
    /* Slightly wider */
    background-color: transparent;
    /* Seamless look */
    padding: 0 20px;
    border-radius: 12px;
    box-shadow: none;
    /* Removed box shadow for cleaner look */
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
}

/* Add Form */
.add-video-form {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #333;
    border-radius: 6px;
    background-color: #2c2c2c;
    color: var(--text-color);
    box-sizing: border-box;
    outline: 2px solid var(--primary-color);
    border-color: transparent;
    margin-bottom: 20px;
}


button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background-color: var(--primary-color);
    color: #000;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #9965f4;
}

button:active {
    background-color: #9965f4;
}

/* Download Progress Bars */
.download-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.download-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--secondary-color);
}

#message {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    min-width: 250px;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    animation: fadeIn 0.3s ease-in-out;
}

#message.show {
    display: block;
}

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

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

.success {
    background-color: rgba(3, 218, 198, 0.2);
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.error {
    background-color: rgba(207, 102, 121, 0.2);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.playlist {
    margin-top: 0px;
}

.playlist h2 {
    font-size: 1.2rem;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

#playlist-items {
    list-style: none;
    padding: 0;
    /*overflow-y: auto;*/
}

#playlist-items li {
    background-color: #2c2c2c;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s;
    position: relative;
}

.empty-queue-item {
    text-align: center;
    padding: 20px;
    color: #888;
    width: 100%;
}

.status-badge {
    cursor: help;
    margin-left: 5px;
}

.active-track {
    background-color: #383838 !important;
    /* Lighter background */
    border-left: 5px solid var(--secondary-color) !important;
    /* Teal accent - forced to stay even in reorder mode */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.video-thumbnail {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 15px;
    flex-shrink: 0;
}

.video-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.video-title {
    font-weight: 500;
    line-height: 1.2;
}

.video-id {
    font-size: 0.8rem;
    color: #888;
}

.controls-container {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.control-btn {
    flex: 1;
    padding: 15px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-btn.play {
    background-color: var(--secondary-color);
    color: #000;
}

.control-btn.pause {
    background-color: #ffb74d;
    /* Orange for pause */
    color: #000;
}

.control-btn.restart {
    background-color: #4fc3f7;
    /* Light Blue for restart */
    color: #000;
}

.control-btn.next {
    background-color: var(--primary-color);
    color: #000;
}

.control-btn:active {
    transform: scale(0.98);
}

.actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.play-icon {
    color: var(--secondary-color);
}

.play-icon:hover {
    background-color: rgba(3, 218, 198, 0.1);
}

.remove-icon {
    color: var(--error-color);
}


.remove-icon:hover {
    background-color: rgba(207, 102, 121, 0.1);
}


.reorder-btn {
    background-color: var(--secondary-color);
    margin-top: 15px;
}

.reorder-btn:hover {
    background-color: #03c4b1 !important;
}

.reorder-btn.active {
    background-color: #ff9800;
    color: #fff;
}

/* Drag and Drop Styles */
.reorder-active-item {
    cursor: grab !important;
    border-left: 4px dashed var(--primary-color);
    user-select: none;
    /* Prevent text selection during drag */
    -webkit-user-select: none;
}

.reorder-active-item:active {
    cursor: grabbing !important;
}

.playlist-item.dragging {
    opacity: 0.5;
    background-color: #333 !important;
}

.drag-placeholder {
    border: 2px dashed var(--secondary-color);
    background-color: rgba(3, 218, 198, 0.05);
    height: 80px;
    /* Base height for placeholder */
    margin: 10px 0;
    border-radius: 8px;
    list-style: none;
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        box-sizing: border-box;
        width: 100%;
        height: 70px;
        top: auto;
        bottom: 0;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
        /* Space from edges */
        border-right: none;
        border-top: 1px solid #333;
    }

    .sidebar-btn {
        width: 100%;
        max-width: 150px;
        height: 50px;
        flex-direction: row;
        gap: 10px;
    }

    .reorder-btn,
    #optionsBtn {
        width: 50px !important;
        min-width: 50px;
        padding: 0 !important;
        margin-top: 0 !important;
        border-radius: 8px;
    }

    .reorder-btn .btn-text,
    #optionsBtn .btn-text {
        display: none;
    }

    .logout-btn {
        width: 50px !important;
        min-width: 50px;
        padding: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        border-radius: 8px;
    }

    .logout-btn .btn-text {
        display: none;
    }

    .sidebar-btn .icon {
        margin-bottom: 0;
    }

    .main-content {
        margin-left: 0;
        margin-bottom: 80px;
        /* Space for bottom bar */
    }

    #message {
        top: 70px;
        /* Adjust toast for mobile if needed */
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
    }

    .hamburger {
        display: flex;
    }

    .navbar-controls {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: var(--card-bg);
        padding: 15px;
        flex-direction: row;
        gap: 10px;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.5);
        z-index: 1000;
        box-sizing: border-box;
    }

    .navbar-controls.active {
        display: flex;
    }

    .nav-btn {
        flex: 1;
        padding: 12px 5px;
        font-size: 0.75rem;
        text-align: center;
        white-space: nowrap;
    }

    /* Small Mobile (< 500px) - Switch to 2x2 Grid to avoid overflow */
    @media (max-width: 500px) {
        .navbar-controls.active {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            padding: 15px;
        }

        .nav-btn {
            width: 100%;
            padding: 12px 5px;
            font-size: 0.9rem;
            /* Increase size as we have more vertical space */
            white-space: normal;
            /* Allow text wrapping if needed */
        }

        .nav-btn.next span {
            display: inline;
            /* Can show full text in grid layout */
        }
    }
}

.hidden {
    display: none !important;
}

/* Sidebar Submenu Styling */
.sidebar-options-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar-submenu {
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    z-index: 1050;
}

.sidebar-submenu.hidden {
    display: none;
    opacity: 0;
    transform: translateY(10px);
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s;
    border-bottom: 1px solid #333;
}

.submenu-item:last-child {
    border-bottom: none;
}

.submenu-item:hover {
    background-color: #383838;
    color: var(--primary-color);
}

.submenu-item.logout-item {
    color: var(--error-color);
}

.submenu-item.logout-item:hover {
    background-color: rgba(207, 102, 121, 0.1);
}

/* Specific Desktop Styles (Sidebar is fixed left) */
@media (min-width: 769px) {
    .sidebar-options-container {
        position: relative;
        width: 100%;
        margin-top: auto;
    }

    .sidebar-submenu {
        width: 100%;
        position: absolute;
        bottom: 60px;
        /* Above the options button */
        left: 0;
    }
}

/* Specific Mobile Styles (Sidebar is at bottom) */
@media (max-width: 768px) {
    .sidebar-options-container {
        width: 50px;
        min-width: 50px;
        position: relative;
    }

    .sidebar-submenu {
        position: absolute;
        bottom: 60px;
        right: 0;
        width: 180px;
        /* Wider for accessibility on mobile dropdown */
    }

    .options-toggle-btn {
        width: 50px !important;
        min-width: 50px;
        padding: 0 !important;
        margin-top: 0 !important;
        border-radius: 8px;
    }

    .options-toggle-btn .btn-text {
        display: none;
    }
}