/* =============================================
   STYLE.CSS — Base Layout, Controls, Theme
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
    /* Background & Surfaces */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-input: #0d1117;
    --bg-hover: #21262d;

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;

    /* Accent */
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #bc8cff;
    --accent-cyan: #76e3ea;

    /* Borders */
    --border-color: #30363d;
    --border-light: #21262d;

    /* Misc */
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-code: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

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

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

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- App Container ---------- */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ---------- INPUT PANEL ---------- */
.input-panel {
    width: 380px;
    min-width: 340px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    max-height: 100vh;
    position: sticky;
    top: 0;
}

/* Scrollbar */
.input-panel::-webkit-scrollbar {
    width: 6px;
}
.input-panel::-webkit-scrollbar-track {
    background: transparent;
}
.input-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ---------- Logo ---------- */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-highlight {
    color: var(--accent-blue);
}

/* ---------- Input Groups ---------- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.input-group textarea {
    width: 100%;
    min-height: 200px;
    max-height: 400px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
    tab-size: 4;
}

.input-group textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.input-group input[type="text"] {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-family: var(--font-code);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.input-group input[type="text"]:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.input-group select {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-family: var(--font-ui);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--transition);
}

.input-group select:focus {
    border-color: var(--accent-blue);
}

/* Settings Row */
.settings-row {
    display: flex;
    gap: 12px;
}

.settings-row .half {
    flex: 1;
}

/* ---------- Range Slider ---------- */
.input-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform var(--transition);
}

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

.input-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

/* ---------- Toggle Switch ---------- */
.toggle-group {
    flex-direction: row !important;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--border-color);
    border-radius: 11px;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: all var(--transition);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--accent-blue);
}

.toggle-label input:checked + .toggle-switch::after {
    left: 21px;
    background: white;
}

/* ---------- Control Buttons ---------- */
.control-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    flex: 1;
    min-width: 100px;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn:active {
    transform: scale(0.97);
}

.btn-icon {
    font-size: 16px;
}

.btn-play {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.btn-play:hover {
    background: #4393e6;
    border-color: #4393e6;
}

.btn-play.paused {
    background: var(--accent-yellow);
    border-color: var(--accent-yellow);
    color: #000;
}

.btn-reset {
    background: var(--bg-tertiary);
}

.btn-fullscreen {
    background: var(--bg-tertiary);
}

/* ---------- Progress Bar ---------- */
.progress-container {
    position: relative;
    width: 100%;
    height: 24px;
    background: var(--bg-input);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: none;
}

.progress-container.active {
    display: block;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 12px;
    transition: width 0.1s linear;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---------- OUTPUT PANEL ---------- */
.output-panel {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 30px;
    min-height: 100vh;
    position: relative;
}

/* ---------- Exit Fullscreen Button ---------- */
.btn-exit-fullscreen {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    opacity: 0.5;
}

.btn-exit-fullscreen:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* Fullscreen state */
.app-container.fullscreen .input-panel {
    display: none;
}

.app-container.fullscreen .output-panel {
    padding: 0;
    align-items: center;
    justify-content: center;
    background: #000;
}

.app-container.fullscreen .editor-window {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    border: none;
}

.app-container.fullscreen .editor-body {
    max-height: none !important;
    height: calc(100vh - 86px) !important;
}

.app-container.fullscreen .btn-exit-fullscreen {
    display: block;
}

.app-container.fullscreen .editor-titlebar {
    border-radius: 0;
}
/* =============================================
   RECORDING & CANVAS PREVIEW STYLES
   ============================================= */

/* ---------- Section Divider ---------- */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ---------- Record Button ---------- */
.btn-record {
    background: var(--bg-tertiary);
}
.btn-record:hover {
    background: #2d1a1a;
    border-color: var(--accent-red);
    color: var(--accent-red);
}
.btn-record.recording {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #fff;
    animation: recordPulse 1.5s ease-in-out infinite;
}
@keyframes recordPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* ---------- Canvas Preview ---------- */
.canvas-preview {
    display: none;
    width: 100%;
    max-width: 480px;
    align-items: center;
    justify-content: center;
}
.canvas-preview.active {
    display: flex;
}
.canvas-preview canvas {
    width: 100%;
    height: auto;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ---------- Recording Indicator ---------- */
.recording-indicator {
    display: none;
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    padding: 8px 20px;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: 20px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    align-items: center;
    gap: 10px;
    user-select: none;
}
.recording-indicator.active {
    display: flex;
}
.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: recBlink 1s ease-in-out infinite;
}
@keyframes recBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
.rec-label {
    color: var(--accent-red);
    letter-spacing: 1px;
}
.rec-timer {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-code);
    font-size: 12px;
}

/* ---------- Download Overlay ---------- */
.download-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}
.download-overlay.active {
    display: flex;
}
.download-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 520px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.download-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.download-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.download-icon { font-size: 28px; }
.download-preview {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #000;
}
.download-preview video {
    width: 100%;
    display: block;
    max-height: 340px;
    object-fit: contain;
}
.download-info {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
}
.download-info span {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.download-actions {
    display: flex;
    gap: 10px;
}
.btn-download {
    flex: 2;
    background: var(--accent-green) !important;
    border-color: var(--accent-green) !important;
    color: #000 !important;
    font-weight: 700 !important;
}
.btn-download:hover {
    background: #36a346 !important;
    border-color: #36a346 !important;
}
.btn-close-overlay {
    flex: 1;
}
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.4 !important;
}

/* ---------- Mobile responsive for canvas ---------- */
@media screen and (max-width: 1024px) {
    .canvas-preview {
        max-width: 100%;
        padding: 12px;
    }
    .canvas-preview canvas {
        max-height: 70vh;
    }
}
@media screen and (max-width: 640px) {
    .canvas-preview canvas {
        border-radius: var(--radius);
        max-height: 65vh;
    }
    .download-card {
        padding: 20px;
    }
    .download-preview video {
        max-height: 260px;
    }
}
.info-message,
.warning-message {
    margin-top: 10px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.info-message {
    background: rgba(122, 162, 247, 0.12);
    border: 1px solid rgba(122, 162, 247, 0.28);
    color: #a9b1d6;
}

.warning-message {
    background: rgba(255, 158, 100, 0.12);
    border: 1px solid rgba(255, 158, 100, 0.28);
    color: #ff9e64;
}