* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #e50914;      /* deep red */
    --secondary-color: #1f2937;    /* slate */
    --bg-color: #0a0c10;           /* near-black */
    --surface-color: #111827;      /* deep panel */
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --accent-color: #00c2ff;       /* modern cyan */
    --hover-color: #1c2533;
    --progress-color: #e50914;
    --border-color: #1f2937;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: var(--surface-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo svg {
    flex-shrink: 0;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.developer {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.developer span {
    color: var(--accent-color);
    font-weight: 600;
}

.history-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-btn:hover {
    background: var(--border-color);
    border-color: var(--accent-color);
}

.history-btn svg {
    width: 20px;
    height: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* URL Input Section */
.url-input-section {
    margin-bottom: 2rem;
}

.input-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

#videoUrl {
    flex: 1;
    padding: 1rem 1.5rem;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

#videoUrl:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

#videoUrl::placeholder {
    color: var(--text-secondary);
}

.load-btn {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.load-btn:hover {
    background: #CC0000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

.load-btn:active {
    transform: translateY(0);
}

.format-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding-left: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.format-note {
    color: var(--accent-color);
    font-size: 0.8rem;
    font-style: italic;
}

/* Video Wrapper */
.video-wrapper {
    background: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
}

.video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #000;
}

#videoPlayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    outline: none;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.video-container:hover .video-overlay {
    opacity: 1;
}

.play-icon {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.play-icon:hover {
    transform: scale(1.1);
}

/* Video Info */
.video-info {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.video-info h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.video-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Resume Notification */
.resume-notification {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(62, 166, 255, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.resume-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    flex: 1;
}

.resume-content svg {
    color: var(--accent-color);
    flex-shrink: 0;
}

.resume-content span {
    font-size: 0.95rem;
}

.resume-content strong {
    color: var(--accent-color);
    font-weight: 600;
}

.resume-actions {
    display: flex;
    gap: 0.75rem;
}

.resume-btn,
.start-over-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.resume-btn {
    background: var(--accent-color);
    color: white;
}

.resume-btn:hover {
    background: #2d8fdd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(62, 166, 255, 0.3);
}

.start-over-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.start-over-btn:hover {
    background: var(--hover-color);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Controls Panel */
.controls-panel {
    padding: 1rem 1.5rem;
    background: var(--surface-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--hover-color);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 200px;
}

#volumeSlider {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#volumeSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#volumeSlider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

#volumeSlider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

#volumeValue {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 40px;
    text-align: right;
}

.time-display {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

/* Progress Bar */
.progress-container {
    margin: 0.75rem 0;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    transition: height 0.2s ease;
}

.progress-bar:hover {
    height: 8px;
}

.progress-filled {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--progress-color);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.progress-bar:hover .progress-handle {
    opacity: 1;
}

.speed-select {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.speed-select:hover {
    border-color: var(--primary-color);
}

.speed-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.1);
}

/* Converting Overlay */
.converting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
}

.converting-content {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.converting-content h3 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.converting-content #convertingStatus {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 1rem 0;
}

.converting-progress {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1.5rem 0;
}

.converting-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #FF4444);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    animation: pulse-progress 2s ease-in-out infinite;
}

@keyframes pulse-progress {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.converting-note {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 1rem;
    font-style: italic;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error Message */
.error-message {
    background: var(--surface-color);
    border: 2px solid #FF4444;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    margin: 2rem 0;
}

.error-message svg {
    color: #FF4444;
    margin-bottom: 1rem;
}

.error-message p {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    line-height: 1.8;
    white-space: pre-line;
}

.retry-btn {
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #CC0000;
    transform: translateY(-2px);
}

/* Watch History Panel */
.history-panel {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin: 2rem 0;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
}

.history-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.history-header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.clear-history-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: var(--hover-color);
    color: var(--text-primary);
    border-color: #FF4444;
}

.close-history-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-history-btn:hover {
    background: var(--hover-color);
    color: var(--text-primary);
}

.history-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.history-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.history-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.history-empty svg {
    margin-bottom: 1rem;
    opacity: 0.3;
}

.history-empty p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.history-empty span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.history-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-item:hover {
    background: var(--hover-color);
    border-color: var(--accent-color);
}

.history-item-thumbnail {
    width: 80px;
    height: 60px;
    background: var(--surface-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.history-item-thumbnail svg {
    width: 30px;
    height: 30px;
    color: var(--text-secondary);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.history-item-time {
    color: var(--text-secondary);
}

.history-item-duration {
    color: var(--accent-color);
}

.history-item-format {
    background: var(--surface-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.history-item-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.history-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.history-progress-filled {
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.history-progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.history-play-btn,
.history-delete-btn {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-play-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.history-delete-btn:hover {
    background: #FF4444;
    border-color: #FF4444;
    color: white;
}

/* Footer */
.footer {
    background: var(--surface-color);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer strong {
    color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .header-actions {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .logo h1 {
        font-size: 1.2rem;
    }
    
    .history-item {
        flex-direction: column;
    }
    
    .history-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .main-content {
        padding: 1rem;
    }

    .input-container {
        flex-direction: column;
    }

    .load-btn {
        width: 100%;
        justify-content: center;
    }

    .control-group {
        flex-wrap: wrap;
    }

    .volume-control {
        max-width: 100%;
        order: 3;
        width: 100%;
    }

    .time-display {
        order: 2;
    }

    .video-info {
        padding: 1rem;
    }

    .video-info h2 {
        font-size: 1rem;
    }
    
    .resume-notification {
        flex-direction: column;
        align-items: stretch;
    }
    
    .resume-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .resume-btn,
    .start-over-btn {
        flex: 1;
    }

    .controls-panel {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1rem;
    }

    .developer {
        font-size: 0.8rem;
    }

    #videoUrl {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }

    .load-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Fullscreen Styles */
:fullscreen .video-container {
    padding-top: 0;
    height: 100vh;
}

:-webkit-full-screen .video-container {
    padding-top: 0;
    height: 100vh;
}

:-moz-full-screen .video-container {
    padding-top: 0;
    height: 100vh;
}
