/* ============================================
   GLOBAL STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: #1e1e1e;
    color: #e0e0e0;
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
    width: 50px;
    height: 28px;
    background-color: #ccc;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s ease;
    padding: 0;
    display: flex;
    align-items: center;
    min-height: auto;
}

.theme-toggle::after {
    content: '☀️';
    position: absolute;
    left: 6px;
    font-size: 14px;
    transition: left 0.3s ease;
}

body.dark-mode .theme-toggle {
    background-color: #444;
}

body.dark-mode .theme-toggle::after {
    content: '🌙';
    left: 28px;
}

/* ============================================
   COMMON STYLES
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    margin-bottom: 30px;
    color: #333;
    font-size: 32px;
    font-weight: 600;
}

body.dark-mode h1 {
    color: #ffffff;
}

h2 {
    color: #333;
    font-size: 20px;
    margin: 0;
}

body.dark-mode h2 {
    color: #e0e0e0;
}

h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

body.dark-mode h3 {
    color: #e0e0e0;
}

/* ============================================
   BUTTONS
   ============================================ */
button {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    font-weight: 600;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: #0d6efd;
    color: white;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.25);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.35);
}

body.dark-mode .btn-primary {
    background-color: #0d6efd;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

body.dark-mode .btn-primary:hover {
    background-color: #0b5ed7;
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.4);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.25);
}

.btn-danger:hover {
    background-color: #bb2d3b;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.35);
}

body.dark-mode .btn-danger {
    background-color: #dc3545;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

body.dark-mode .btn-danger:hover {
    background-color: #bb2d3b;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

body.dark-mode .btn-secondary {
    background-color: #545b62;
}

body.dark-mode .btn-secondary:hover {
    background-color: #3a3f44;
}

.btn-play {
    padding: 10px 14px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-play:hover {
    background-color: #218838;
}

body.dark-mode .btn-play {
    background-color: #1e7e2d;
}

body.dark-mode .btn-play:hover {
    background-color: #155e23;
}

.btn-remove {
    padding: 10px 14px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background-color: #c82333;
}

body.dark-mode .btn-remove {
    background-color: #a91e2d;
}

body.dark-mode .btn-remove:hover {
    background-color: #7a161f;
}

.btn-add {
    background-color: #28a745;
    color: white;
    font-size: 14px;
    padding: 10px 12px;
    min-height: auto;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.25);
}

.btn-add:hover {
    background-color: #218838;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.35);
}

body.dark-mode .btn-add {
    background-color: #1e7e2d;
}

body.dark-mode .btn-add:hover {
    background-color: #155e23;
}

/* ============================================
   BREADCRUMBS
   ============================================ */
.breadcrumb {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

body.dark-mode .breadcrumb {
    color: #b0b0b0;
}

.breadcrumb a {
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
}

body.dark-mode .breadcrumb a {
    color: #66b3ff;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ============================================
   HEADER STYLES
   ============================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

body.dark-mode .header {
    border-bottom: 2px solid #333;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 10px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ============================================
   QUEUE LIST STYLES
   ============================================ */
.queue-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.queue-card {
    background: white;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    border: 1px solid #e8e8e8;
}

body.dark-mode .queue-card {
    background: #333333;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    border: 1px solid #444444;
}

.queue-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

body.dark-mode .queue-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
}

.queue-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #1a1a1a;
    word-break: break-word;
    line-height: 1.4;
}

body.dark-mode .queue-name {
    color: #ffffff;
}

.queue-meta {
    font-size: 15px;
    color: #999;
    margin-bottom: 18px;
}

body.dark-mode .queue-meta {
    color: #b0b0b0;
}

.queue-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================
   FORM STYLES
   ============================================ */
.form-card {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .form-card {
    background: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

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

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 16px;
}

body.dark-mode label {
    color: #e0e0e0;
}

input[type="text"],
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

body.dark-mode input[type="text"],
body.dark-mode select {
    background: #333;
    color: #e0e0e0;
    border: 1px solid #444;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

body.dark-mode input[type="text"]:focus,
body.dark-mode select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.error {
    color: #dc3545;
    font-size: 14px;
    margin-top: 6px;
}

body.dark-mode .error {
    color: #ff9a9e;
}

.back-button-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.back-button-container button {
    margin: 0;
}

/* ============================================
   SEARCH STYLES
   ============================================ */
.search-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .search-section {
    background: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.search-controls {
    display: flex;
    gap: 12px;
}

.search-status {
    margin-top: 12px;
    font-size: 13px;
    color: #666;
}

body.dark-mode .search-status {
    color: #b0b0b0;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.active {
    display: block;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

body.dark-mode .spinner {
    border: 3px solid #444;
    border-top: 3px solid #007bff;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   RESULTS & VIDEOS SECTION
   ============================================ */
.results-section {
    margin-top: 30px;
}

.results-header {
    margin-bottom: 20px;
}

.results-header h2 {
    color: #333;
    font-size: 20px;
    margin-bottom: 4px;
}

body.dark-mode .results-header h2 {
    color: #e0e0e0;
}

.results-count,
.videos-count {
    color: #999;
    font-size: 14px;
}

body.dark-mode .results-count,
body.dark-mode .videos-count {
    color: #b0b0b0;
}

.results-list,
.videos-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.videos-list {
    gap: 12px;
    padding-left: 50px;
}

.videos-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

body.dark-mode .videos-section {
    background: #252525;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
    border: 1px solid #333;
}

.videos-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.videos-header h2 {
    color: #333;
    font-size: 18px;
    margin: 0;
}

body.dark-mode .videos-header h2 {
    color: #e0e0e0;
}

/* ============================================
   VIDEO ITEM STYLES
   ============================================ */
.video-item {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 16px;
}

body.dark-mode .video-item {
    background: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.queue-detail .video-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    user-select: none;
    flex: 1;
}

body.dark-mode .queue-detail .video-item {
    background: #333333;
    border: 2px solid #454545;
}

.queue-detail .video-item.dragging {
    opacity: 0.6;
    background: #e8e8e8;
}

.queue-detail .video-item.drag-over {
    border-color: #0d6efd;
    background: #f0f7ff;
}

.queue-detail .video-item:hover {
    background: #f0f0f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: #0d6efd;
}

body.dark-mode .queue-detail .video-item:hover {
    background: #3a3a3a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: #0d6efd;
}

.watch-history .video-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

body.dark-mode .watch-history .video-item {
    background: #333333;
    border: 2px solid #454545;
}

.watch-history .video-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #0d6efd;
}

body.dark-mode .watch-history .video-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: #66b3ff;
}

.video-thumbnail {
    flex-shrink: 0;
    width: 120px;
    height: 67px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

body.dark-mode .video-thumbnail {
    background: #555;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.video-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 16px;
    line-height: 1.5;
    word-break: break-word;
}

body.dark-mode .video-title {
    color: #e0e0e0;
}

.video-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: #666;
    flex-wrap: wrap;
}

body.dark-mode .video-meta {
    color: #b0b0b0;
}

.video-duration {
    font-size: 14px;
    color: #999;
}

body.dark-mode .video-duration {
    color: #b0b0b0;
}

.video-channel {
    color: #666;
    font-size: 13px;
    margin-bottom: 0;
}

body.dark-mode .video-channel {
    color: #b0b0b0;
}

.video-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-item-wrapper {
    position: relative;
    display: flex;
    align-items: flex-start;
}

.drag-handle {
    position: absolute;
    left: -45px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: #999;
    transition: color 0.2s ease, opacity 0.2s ease;
    opacity: 0.5;
}

.drag-handle:hover {
    color: #0d6efd;
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

body.dark-mode .drag-handle {
    color: #666;
}

body.dark-mode .drag-handle:hover {
    color: #66b3ff;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

body.dark-mode .empty-state {
    color: #b0b0b0;
}

.empty-state h2,
.empty-state h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

body.dark-mode .empty-state h2,
body.dark-mode .empty-state h3 {
    color: #ffffff;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ============================================
   VIDEO PLAYER STYLES
   ============================================ */
.player-section {
    display: flex;
    flex-direction: column;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
    grid-column: 1 / -1;
}

.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.player-wrapper-inner {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.player-controls {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    justify-content: flex-end;
}

.btn-fullscreen {
    background-color: #007bff;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-fullscreen:hover {
    background-color: #0056b3;
}

body.dark-mode .btn-fullscreen {
    background-color: #0056b3;
}

body.dark-mode .btn-fullscreen:hover {
    background-color: #003d82;
}

.player-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

.fullscreen-active body {
    overflow: hidden;
}

.video-details {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .video-details {
    background: #1a1a1a;
}

.video-details h1 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #fff;
}

.btn-back {
    background-color: #007bff;
    color: white;
}

.btn-back:hover {
    background-color: #0056b3;
}

body.dark-mode .btn-back {
    background-color: #0056b3;
}

body.dark-mode .btn-back:hover {
    background-color: #003d82;
}

/* ============================================
   FILTER SECTION
   ============================================ */
.filter-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .filter-section {
    background: #252525;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
    border: 1px solid #333;
}

.filter-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.filter-controls select,
.filter-controls input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #333;
    height: 44px;
    min-width: auto;
}

.filter-controls select {
    min-width: 140px;
}

.filter-controls input {
    width: 130px;
}

.filter-controls .btn-primary {
    min-width: 120px;
    white-space: nowrap;
}

body.dark-mode .filter-controls select,
body.dark-mode .filter-controls input {
    background: #333;
    border: 1px solid #555;
    color: #e0e0e0;
}

/* ============================================
   TOAST CONTAINER
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

body.dark-mode .toast {
    background: #333;
    color: #e0e0e0;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .header-row {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 24px;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions button {
        width: 100%;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 24px;
        gap: 16px;
    }

    .queue-list {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 18px;
    }

    .queue-card {
        padding: 22px;
    }

    .queue-name {
        font-size: 18px;
        margin-bottom: 14px;
    }

    .queue-meta {
        font-size: 15px;
        margin-bottom: 18px;
    }

    .queue-actions {
        flex-direction: column;
        gap: 12px;
    }

    button {
        min-width: unset;
        width: 100%;
        padding: 14px 16px;
    }

    .form-card {
        padding: 20px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions button {
        width: 100%;
    }

    .results-list {
        gap: 14px;
    }

    .video-item {
        flex-direction: column;
    }

    .videos-list {
        padding-left: 0;
    }

    .video-item-wrapper {
        flex-direction: column;
    }

    .drag-handle {
        position: static;
        transform: none;
        width: 100%;
        height: auto;
        margin-bottom: 10px;
        padding: 0;
    }

    .videos-section {
        padding: 20px;
    }

    .filter-controls {
        flex-direction: column;
    }

    .filter-controls select,
    .filter-controls input,
    .filter-controls button {
        width: 100%;
    }

    .toast-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    h1 {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .queue-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .queue-card {
        padding: 18px;
    }

    .queue-name {
        font-size: 17px;
        margin-bottom: 12px;
    }

    .queue-meta {
        font-size: 14px;
        margin-bottom: 16px;
    }

    button {
        padding: 12px 14px;
        font-size: 14px;
    }

    .video-item {
        padding: 12px;
    }

    .video-thumbnail {
        width: 100px;
        height: 56px;
    }

    .video-title {
        font-size: 14px;
    }

    .video-meta {
        gap: 8px;
        font-size: 12px;
    }
}
