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

:root {
    /* Colors - Apple-like Dark Theme */
    --background: #000000;
    --foreground: #ffffff;
    --card: #0a0a0a;
    --card-hover: #111111;
    --popover: #0a0a0a;
    --primary: #ffffff;
    --primary-foreground: #000000;
    --secondary: #262626;
    --secondary-foreground: #ffffff;
    --muted: #262626;
    --muted-foreground: #a3a3a3;
    --accent: #262626;
    --accent-foreground: #ffffff;
    --destructive: #ef4444;
    --border: #262626;
    --input: #262626;
    --ring: #525252;
    --radius: 0.75rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    border-bottom: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
}

.header-title h1 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

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

/* Main Layout */
.main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    overflow-y: auto;
}

.panel-left {
    flex: 1;
    max-width: 600px;
    border-right: 1px solid var(--border);
}

.panel-right {
    flex: 1.5;
    background: var(--background);
}

/* Card Component */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--ring);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-area:hover {
    border-color: var(--ring);
    background: var(--card-hover);
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--card-hover);
}

.upload-icon {
    width: 3rem;
    height: 3rem;
    color: var(--muted-foreground);
}

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

/* URL Section */
.url-section {
    margin-top: 1.5rem;
}

.divider {
    position: relative;
    text-align: center;
    margin: 1.5rem 0;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.divider span {
    position: relative;
    padding: 0 1rem;
    background: var(--card);
    color: var(--muted-foreground);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

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

/* Input */
.input {
    flex: 1;
    height: 2.5rem;
    padding: 0 0.75rem;
    background: var(--input);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    color: var(--foreground);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.input:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.input::placeholder {
    color: var(--muted-foreground);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.5rem;
    padding: 0 1rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-icon-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-ghost:hover {
    background: var(--accent);
}

.btn-sm {
    height: 2rem;
    padding: 0 0.75rem;
    font-size: 0.75rem;
}

/* Button Group & Toggle */
.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-toggle {
    height: 2.25rem;
    padding: 0 1rem;
    background: var(--secondary);
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle:hover {
    background: var(--accent);
    color: var(--foreground);
}

.btn-toggle.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
}

#videoPlayer {
    width: 100%;
    height: auto;
    max-height: 400px;
    display: block;
}

/* Control Group */
.control-group {
    margin-bottom: 1.5rem;
}

.controls-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.control-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.label-inline {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Select Dropdown */
.select {
    width: 100%;
    height: 2.5rem;
    padding: 0 2.5rem 0 0.75rem;
    background: var(--input);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    color: var(--foreground);
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
}

.select:hover {
    border-color: var(--ring);
}

.select:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Info Card */
.info-card {
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    margin: 1.5rem 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
}

.text-sm {
    font-size: 0.875rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
}

.action-buttons .btn:not(.btn-ghost) {
    flex: 1;
}

/* Progress */
.progress-content {
    padding: 1rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.progress-bar {
    height: 0.5rem;
    background: var(--secondary);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.progress-info {
    margin-top: 0.5rem;
    text-align: center;
}

/* Gallery */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.gallery-actions {
    display: flex;
    gap: 0.5rem;
}

.frame-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    flex: 1;
    overflow-y: auto;
    align-content: start;
    padding-right: 0.5rem;
}

/* Frame Item */
.frame-item {
    position: relative;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    background: var(--secondary);
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.frame-item:hover {
    border-color: var(--ring);
}

.frame-item.selected {
    border-color: var(--primary);
}

.frame-item img {
    width: 100%;
    height: auto;
    display: block;
}

.frame-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 1.25rem;
    height: 1.25rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.frame-checkbox.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.frame-checkbox.checked::after {
    content: '✓';
    color: var(--primary-foreground);
    font-size: 0.75rem;
}

.frame-time {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

.frame-actions {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
}

.frame-item:not(:hover) .frame-actions {
    opacity: 0;
}

.frame-actions button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 0.25rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.frame-actions button:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--muted-foreground);
}

.empty-icon {
    width: 4rem;
    height: 4rem;
    opacity: 0.3;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.lightbox.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.lightbox-image-container img {
    max-width: 85vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.lightbox-info {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem 2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.lightbox-time {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.lightbox-close:hover {
    background: var(--accent);
    transform: scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lightbox-nav:hover {
    background: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lightbox-nav:disabled:hover {
    transform: translateY(-50%);
    background: var(--card);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: var(--card);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-0.5rem);
}

/* Utilities */
.w-3 { width: 0.75rem; }
.h-3 { height: 0.75rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.h-full { height: 100%; }
.text-lg { font-size: 1.125rem; }
.font-semibold { font-weight: 600; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ring);
}

/* Responsive */
@media (max-width: 1024px) {
    .main {
        flex-direction: column;
    }

    .panel-left {
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .panel-right {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .panel {
        padding: 1rem;
    }

    .header-content {
        padding: 1rem;
    }

    .controls-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .control-item {
        width: 100%;
    }

    .frame-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .gallery-actions {
        flex-wrap: wrap;
    }
}