/* Reset and Variables */
:root {
    --bg-dark: #090b10;
    --bg-card: rgba(18, 22, 33, 0.65);
    --bg-card-hover: rgba(26, 32, 48, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(157, 78, 221, 0.4);
    
    --accent-purple: #9d4edd;
    --accent-glow: rgba(157, 78, 221, 0.5);
    --accent-green: #00f5d4;
    --accent-green-glow: rgba(0, 245, 212, 0.3);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(157, 78, 221, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(58, 134, 200, 0.12) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(9, 11, 16, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Header styling */
.app-header {
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: rgba(18, 22, 33, 0.4);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.logo-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 8px var(--accent-purple));
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    color: var(--accent-purple);
    text-shadow: 0 0 10px var(--accent-glow);
}

.mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.btn-mode {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-mode.active {
    background: var(--accent-purple);
    color: white;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Workspace Layout */
.workspace-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr 360px;
    height: calc(100vh - 64px);
    overflow: hidden;
}

/* Sidebar Panels */
.panel {
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    gap: 20px;
}

.panel.inputs-panel {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.panel-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-section h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 4px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Inputs & Form styling */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"],
select,
textarea {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: var(--font-sans);
    font-size: 13px;
    transition: all 0.2s ease;
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(157, 78, 221, 0.25);
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* File Upload Zone */
.file-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
    background: rgba(0, 0, 0, 0.15);
}

.file-upload-zone:hover {
    border-color: var(--accent-purple);
    background: rgba(157, 78, 221, 0.04);
}

.file-upload-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-zone p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Playback and Preview Area */
.preview-area {
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.45);
}

.canvas-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#captionCanvas {
    max-height: 100%;
    max-width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    background-color: #1a1a1a;
    background-image: 
        linear-gradient(45deg, #111111 25%, transparent 25%), 
        linear-gradient(-45deg, #111111 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #111111 75%), 
        linear-gradient(-45deg, transparent 75%, #111111 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.playback-controls {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.playback-buttons {
    display: flex;
    gap: 8px;
}

.time-readout {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.fps-tag {
    color: var(--text-muted);
    font-size: 11px;
}

.timeline-container {
    width: 100%;
    max-width: 800px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

/* Segments list */
.segments-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.segment-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s;
}

.segment-item:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.04);
}

.segment-item-header {
    display: flex;
    gap: 6px;
    align-items: center;
}

.segment-item-header input[type="text"] {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
}

.segment-item textarea {
    width: 100%;
    padding: 6px 8px;
    font-size: 12px;
    resize: vertical;
}

/* Custom Scrollbars */
.scrollbar-styled::-webkit-scrollbar {
    width: 6px;
}

.scrollbar-styled::-webkit-scrollbar-track {
    background: transparent;
}

.scrollbar-styled::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.scrollbar-styled::-webkit-scrollbar-thumb:hover {
    background: rgba(157, 78, 221, 0.5);
}

/* Buttons */
button {
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    outline: none;
}

.btn-primary {
    background: var(--accent-purple);
    color: white;
    border: none;
    padding: 10px 24px;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    background: #b566ff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger-sm {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 6px;
}

.btn-danger-sm:hover {
    background: rgba(239, 68, 68, 0.3);
}

.btn-success {
    background: var(--accent-green);
    color: #000;
    border: none;
    padding: 12px 24px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 14px var(--accent-green-glow);
}

.btn-success:hover {
    background: #39ffd0;
    box-shadow: 0 6px 20px var(--accent-green-glow);
    transform: translateY(-1px);
}

.w-full {
    width: 100%;
}

.btn-lg {
    font-size: 15px;
    padding: 14px 28px;
}

/* Progress bar */
.progress-bar-bg {
    background: rgba(255, 255, 255, 0.1);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-green);
    transition: width 0.1s linear;
}

#exportStatusText {
    font-size: 11px;
    color: var(--accent-green);
    margin-top: 6px;
    text-align: center;
    font-weight: 600;
}

/* Utilities */
.hidden {
    display: none !important;
}

.mode-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
