/**
 * Frontend Styles for Codicts YouTube Jukebox
 * 
 * @package CodictsYouTubeJukebox
 */

/* Reset and base */
.codicts-ytj-player-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    max-width: 100%;
    margin: 0 auto;
}

.codicts-ytj-player-container * {
    box-sizing: border-box;
}

/* Player wrapper */
.codicts-ytj-player-wrapper {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
}

.codicts-ytj-player-wrapper iframe {
    width: 100%;
    height: 100%;
}

/* Unmute Overlay */
.ytj-unmute-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ytj-unmute-overlay.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.ytj-unmute-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--ytj-accent-1, #9333ea) 0%, var(--ytj-accent-2, #3b82f6) 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(147, 51, 234, 0.4);
    transition: all 0.2s ease;
    animation: ytj-pulse 2s infinite;
}

.ytj-unmute-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(147, 51, 234, 0.5);
}

.ytj-unmute-btn svg {
    flex-shrink: 0;
}

@keyframes ytj-pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(147, 51, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(147, 51, 234, 0.7);
    }
}

/* Now Playing */
.codicts-ytj-now-playing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    margin-bottom: 15px;
    color: #fff;
}

.now-playing-info {
    flex: 1;
    min-width: 0;
}

.now-playing-info .label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-bottom: 3px;
}

.now-playing-info strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playback-state .state-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-badge.state-playing {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.state-badge.state-paused {
    background: rgba(255, 193, 7, 0.9);
    color: #333;
}

.state-badge.state-stopped {
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
}

/* Crossfade Indicator - DJ Mode */
.crossfade-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ffa500 50%, #4ecdc4 100%);
    background-size: 200% 100%;
    color: #fff;
    animation: crossfade-gradient 2s ease infinite;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.4);
}

.crossfade-indicator.active {
    display: inline-flex;
}

.crossfade-indicator svg {
    width: 14px;
    height: 14px;
    animation: crossfade-pulse 1s ease-in-out infinite;
}

@keyframes crossfade-gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes crossfade-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
}

/* Controls */
.codicts-ytj-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
}

.codicts-ytj-dj-controls {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.ytj-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.codicts-ytj-listener-controls .ytj-btn {
    background: #e9ecef;
    color: #333;
}

.ytj-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

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

.ytj-btn-primary {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ytj-btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

.ytj-btn svg {
    width: 20px;
    height: 20px;
}

.ytj-btn-primary svg {
    width: 28px;
    height: 28px;
}

.ytj-btn-small {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.ytj-btn-small svg {
    width: 16px;
    height: 16px;
}

/* Chromecast Button */
.ytj-cast-btn {
    margin-left: 10px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
}

.ytj-cast-btn.hidden {
    display: none !important;
}

.ytj-cast-btn .cast-icon {
    display: block;
}

.ytj-cast-btn .cast-connected-icon {
    display: none;
}

.ytj-cast-btn.connected {
    background: #FC774A;
    color: #fff;
}

.ytj-cast-btn.connected .cast-icon {
    display: none;
}

.ytj-cast-btn.connected .cast-connected-icon {
    display: block;
}

.ytj-cast-btn.connecting {
    animation: ytj-cast-pulse 1.5s ease-in-out infinite;
}

.ytj-cast-btn:hover {
    background: rgba(252, 119, 74, 0.3);
}

.ytj-cast-btn.connected:hover {
    background: #e06640;
}

.codicts-ytj-listener-controls .ytj-cast-btn {
    background: #e9ecef;
    color: #666;
    margin-left: 15px;
}

.codicts-ytj-listener-controls .ytj-cast-btn:hover {
    background: #FC774A;
    color: #fff;
}

.codicts-ytj-listener-controls .ytj-cast-btn.connected {
    background: #FC774A;
    color: #fff;
}

@keyframes ytj-cast-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Volume */
.codicts-ytj-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.codicts-ytj-listener-controls .codicts-ytj-volume {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    justify-content: center;
}

.codicts-ytj-volume svg {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.7);
}

.codicts-ytj-listener-controls .codicts-ytj-volume svg {
    color: #666;
}

.codicts-ytj-volume input[type="range"] {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.codicts-ytj-listener-controls .codicts-ytj-volume input[type="range"] {
    background: #ccc;
}

.codicts-ytj-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.codicts-ytj-volume .volume-label {
    font-size: 12px;
    color: #666;
}

/* Add Form */
.codicts-ytj-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

/* When tabs are present, make them full width */
.codicts-ytj-add-form .ytj-add-tabs {
    width: 100%;
    flex-shrink: 0;
}

.codicts-ytj-add-form .ytj-tab-content {
    width: 100%;
    flex-shrink: 0;
}

.codicts-ytj-add-form input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 250px;
}

.codicts-ytj-add-form input[type="text"]:focus {
    border-color: #667eea;
}

.codicts-ytj-add-form .ytj-btn-primary {
    width: auto;
    padding: 0 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

/* Message */
.codicts-ytj-message {
    display: none;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.codicts-ytj-message.success {
    background: #d4edda;
    color: #155724;
}

.codicts-ytj-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* Login Notice */
.codicts-ytj-login-notice {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.codicts-ytj-login-notice p {
    margin: 0;
    color: #666;
}

/* Queue */
.codicts-ytj-queue {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.codicts-ytj-queue h4 {
    margin: 0 0 15px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.codicts-ytj-queue h4 .queue-count {
    font-weight: normal;
    color: #666;
}

/* Queue List */
.codicts-ytj-queue-list {
    max-height: 350px;
    overflow-y: auto;
}

.codicts-ytj-queue-list .no-items {
    text-align: center;
    color: #666;
    padding: 30px;
    margin: 0;
}

.codicts-ytj-queue .queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.codicts-ytj-queue .queue-item:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.codicts-ytj-queue .queue-item.next-up {
    background: linear-gradient(135deg, #667eea10 0%, #764ba210 100%);
    border: 1px solid #667eea30;
}

.queue-item .queue-position {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    background: #e9ecef;
    border-radius: 50%;
    flex-shrink: 0;
}

.queue-item.next-up .queue-position {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

/* Drag handle for DJ */
.queue-item .drag-handle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    cursor: grab;
    flex-shrink: 0;
    transition: color 0.2s;
}

.queue-item .drag-handle:hover {
    color: #667eea;
}

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

/* Sortable placeholder */
.codicts-ytj-queue-list .queue-item-placeholder {
    background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
    border: 2px dashed #667eea;
    border-radius: 8px;
    margin-bottom: 8px;
    height: 70px;
}

/* Sortable helper (dragging item) */
.codicts-ytj-queue-list .queue-item.ui-sortable-helper {
    background: #fff;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
    transform: scale(1.02);
    z-index: 1000;
}

/* Disable text selection while dragging */
.ui-sortable-helper * {
    user-select: none;
}

.queue-item .thumbnail {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
    background: #1a1a2e;
}

.queue-item .queue-item-info {
    flex: 1;
    min-width: 0;
}

.queue-item .title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.queue-item .meta {
    display: block;
    font-size: 12px;
    color: #666;
}

.queue-item .queue-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.queue-item:hover .queue-item-actions {
    opacity: 1;
}

.queue-item .ytj-btn-small {
    background: #e9ecef;
    color: #333;
}

.queue-item .ytj-btn-small:hover {
    background: #667eea;
    color: #fff;
}

/* Scrollbar */
.codicts-ytj-queue-list::-webkit-scrollbar {
    width: 6px;
}

.codicts-ytj-queue-list::-webkit-scrollbar-track {
    background: transparent;
}

.codicts-ytj-queue-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.codicts-ytj-queue-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive */
@media (max-width: 600px) {
    .codicts-ytj-now-playing {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .codicts-ytj-controls {
        flex-wrap: wrap;
    }

    .codicts-ytj-volume {
        width: 100%;
        margin-left: 0;
        margin-top: 10px;
        padding-left: 0;
        padding-top: 10px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        justify-content: center;
    }

    .codicts-ytj-add-form {
        flex-direction: column;
    }

    .codicts-ytj-add-form .ytj-btn-primary {
        width: 100%;
        justify-content: center;
    }

    .queue-item .thumbnail {
        width: 60px;
        height: 34px;
    }

    .queue-item .queue-item-actions {
        opacity: 1;
    }
}

/* =====================================================
   YouTube Search Tabs & Results
   ===================================================== */

/* Tab Navigation */
.ytj-add-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.ytj-tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
}

.ytj-tab-btn:hover {
    color: #374151;
    background: #f9fafb;
}

.ytj-tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Tab Content */
.ytj-tab-content {
    display: none;
    width: 100%;
    flex-basis: 100%;
}

.ytj-tab-content.active {
    display: block;
    width: 100%;
    flex-basis: 100%;
}

/* Input Row (URL tab) */
.ytj-input-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.ytj-input-row input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* Search Wrapper */
.ytj-search-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
}

.ytj-search-input-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.ytj-search-input-row input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.ytj-search-input-row .ytj-btn {
    flex-shrink: 0;
}

.ytj-search-wrapper input[type="text"] {
    width: 100%;
    min-width: 300px;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.ytj-search-wrapper input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Search Results Dropdown */
.ytj-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 5px;
}

.ytj-search-loading,
.ytj-search-error,
.ytj-search-empty {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.ytj-search-error {
    color: #dc2626;
}

/* Search Result Item */
.ytj-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s ease;
}

.ytj-search-result:last-child {
    border-bottom: none;
}

.ytj-search-result:hover {
    background: #f9fafb;
}

.ytj-result-thumbnail {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.ytj-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ytj-result-title {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ytj-result-channel {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollbar for search results */
.ytj-search-results::-webkit-scrollbar {
    width: 6px;
}

.ytj-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ytj-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ytj-search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive for search */
@media (max-width: 600px) {
    .ytj-add-tabs {
        flex-direction: column;
        border-bottom: none;
    }
    
    .ytj-tab-btn {
        border-bottom: none;
        border-left: 2px solid transparent;
    }
    
    .ytj-tab-btn.active {
        border-left-color: #667eea;
        background: #f9fafb;
    }
    
    .ytj-input-row {
        flex-direction: column;
    }
    
    .ytj-result-thumbnail {
        width: 60px;
        height: 34px;
    }
}
