/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

/* Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Upload Section */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    padding: 3rem 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background-color: var(--surface-color);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.upload-area h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.supported-formats {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--surface-hover);
    border-color: var(--primary-color);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--surface-color);
    color: var(--text-primary);
}

.btn-icon {
    padding: 0.5rem;
    background-color: var(--surface-hover);
    border-radius: var(--radius-sm);
}

.btn-icon:hover:not(:disabled) {
    background-color: var(--primary-color);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Editor Section */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Video Container */
.video-container {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

#video-player {
    width: 100%;
    max-height: 500px;
    background-color: #000;
    display: block;
}

.video-info {
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.video-info span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Timeline Container */
.timeline-container {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.timeline-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Range Slider */
.range-slider-container {
    margin-bottom: 1.5rem;
}

.range-slider {
    position: relative;
    height: 48px;
    background-color: var(--background-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    touch-action: none;
}

.range-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    transform: translateY(-50%);
}

.range-selected {
    position: absolute;
    top: 50%;
    height: 8px;
    background: linear-gradient(90deg, var(--primary-color), #a855f7);
    border-radius: 4px;
    transform: translateY(-50%);
    left: 0;
    right: 0;
}

.range-handle {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 36px;
    background-color: var(--primary-color);
    border-radius: var(--radius-sm);
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 10;
    transition: transform 0.1s, box-shadow 0.1s;
}

.range-handle:hover,
.range-handle:focus {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
    outline: none;
}

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

.range-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 16px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    transform: translate(-50%, -50%);
}

.start-handle {
    left: 0;
}

.end-handle {
    left: 100%;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--warning-color);
    transform: translateX(-50%);
    left: 0;
    z-index: 5;
    pointer-events: none;
}

.playhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--warning-color);
}

.time-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Trim Inputs */
.trim-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.time-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.time-input {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
}

.time-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.duration-display span {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--primary-color);
}

/* Controls Container */
.controls-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.preview-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.export-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.format-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.format-select label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.format-select select {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
}

.format-select select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Progress Section */
.progress-section {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--background-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #a855f7);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* New Video Section */
.new-video-section {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background-color: var(--surface-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease;
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

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

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 0;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .logo-img {
        width: 36px;
        height: 36px;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .upload-area {
        padding: 2rem 1.5rem;
    }

    .upload-area h2 {
        font-size: 1.25rem;
    }

    .timeline-container,
    .controls-container {
        padding: 1rem;
    }

    .controls-container {
        flex-direction: column;
        gap: 1rem;
    }

    .preview-controls,
    .export-controls {
        width: 100%;
        justify-content: center;
    }

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

    .btn-lg {
        width: 100%;
    }

    .trim-inputs {
        grid-template-columns: 1fr 1fr;
    }

    .duration-display {
        grid-column: span 2;
        text-align: center;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0 0.75rem;
    }

    .upload-icon svg {
        width: 48px;
        height: 48px;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .trim-inputs {
        grid-template-columns: 1fr;
    }

    .duration-display {
        grid-column: span 1;
    }

    #video-player {
        max-height: 300px;
    }

    .range-slider {
        height: 56px;
    }

    .range-handle {
        width: 24px;
        height: 44px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #fff;
        --text-secondary: #fff;
    }
}
