/* Design System and Variables */
:root {
    --bg-base: #070913;
    --bg-surface: rgba(15, 22, 42, 0.65);
    --bg-surface-hover: rgba(22, 32, 60, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --primary-hover: #2563eb;
    
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-highlight: #38bdf8;
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Glowing background animations */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, #0c122c 0%, #060814 100%);
    z-index: -3;
}

.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -2;
    opacity: 0.4;
    pointer-events: none;
}

.glow-1 {
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(99, 102, 241, 0.1) 70%);
    top: -10vw;
    left: -10vw;
    animation: float-orb 15s infinite alternate ease-in-out;
}

.glow-2 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, rgba(59, 130, 246, 0.05) 70%);
    bottom: -15vw;
    right: -10vw;
    animation: float-orb 20s infinite alternate-reverse ease-in-out;
}

@keyframes float-orb {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5vw, 5vw) scale(1.1); }
}

/* Layout Container */
.app-container {
    width: 100%;
    max-width: 1400px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 95vh;
}

/* Header styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--text-highlight);
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--text-highlight) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Badges & Live Status */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.live-badge {
    background-color: var(--accent-emerald-glow);
    border: 1px solid var(--accent-emerald);
    color: var(--accent-emerald);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Cards (Glassmorphism) */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: border-color var(--transition-normal);
}

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

/* Main Workspace Grid */
.workspace {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    flex-grow: 1;
}

@media (max-width: 950px) {
    .workspace {
        grid-template-columns: 1fr;
    }
}

/* Sidebar Controls Panel */
.controls-panel {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 80vh;
    overflow-y: auto;
}

/* Custom Scrollbar for Sidebar */
.controls-panel::-webkit-scrollbar {
    width: 6px;
}
.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}
.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.controls-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.section-title i {
    width: 18px;
    height: 18px;
    color: var(--text-highlight);
}

.section-title h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.margin-top {
    margin-top: 10px;
}

/* Tabs System */
.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-md);
    padding: 3px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--primary);
    color: var(--text-main);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.tab-btn i {
    width: 14px;
    height: 14px;
}

.tab-content {
    animation: fadeIn 0.25s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Drag & Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-md);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: all var(--transition-normal);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--text-highlight);
    background: rgba(56, 189, 248, 0.03);
}

.drop-icon {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    margin-bottom: 8px;
    transition: transform var(--transition-normal) ease;
}

.drop-zone:hover .drop-icon {
    transform: translateY(-2px);
    color: var(--text-highlight);
}

.drop-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

.drop-text .highlight {
    color: var(--text-highlight);
}

.drop-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.file-input-hidden {
    display: none;
}

/* Webcam Controls */
.webcam-control-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-preview-container {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: var(--border-radius-md);
    background: #000;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

#webcam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    background: #05070f;
    font-size: 0.8rem;
}

.video-placeholder i {
    width: 24px;
    height: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    outline: none;
    border-radius: var(--border-radius-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-main);
    box-shadow: 0 4px 14px 0 var(--primary-glow);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: var(--border-radius-sm);
}

.btn-full {
    width: 100%;
}

.btn i {
    width: 14px;
    height: 14px;
}

/* URL Input */
.url-input-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.url-input-box label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 8px 12px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.input-with-btn input:focus {
    border-color: var(--primary);
}

.input-help {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.inline-icon {
    width: 12px;
    height: 12px;
}

/* Form Settings Group */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-item label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.label-with-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-badge {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-highlight);
    background: rgba(56, 189, 248, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Button group selector */
.btn-group {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-md);
    padding: 2px;
    border: 1px solid var(--border-color);
}

.group-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.group-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

/* Form Select / Input */
.form-select, .form-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 8px 12px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.form-select:focus, .form-input:focus {
    border-color: var(--primary);
}

.form-select option {
    background: #0f172a;
    color: var(--text-main);
}

/* Custom Range Slider */
.form-range {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
    transition: transform var(--transition-fast);
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Custom Switch Toggle */
.flex-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    transition: .3s;
    border-radius: 34px;
}

.slider-switch:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider-switch {
    background-color: var(--primary);
}

input:checked + .slider-switch:before {
    transform: translateX(16px);
    background-color: var(--text-main);
}

/* Right-side Display Panel */
.display-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 80vh;
}

.display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-with-icon h2 {
    font-size: 1rem;
    font-weight: 600;
}

.display-icon {
    width: 18px;
    height: 18px;
    color: var(--text-highlight);
}

.output-actions {
    display: flex;
    gap: 8px;
}

/* ASCII Viewport & Output Rendering */
.ascii-viewport {
    flex-grow: 1;
    background: #000000;
    overflow: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

/* The magic core where ASCII displays */
.ascii-output {
    font-family: var(--font-mono);
    font-size: 8px;
    line-height: 1;
    letter-spacing: 0;
    margin: 0;
    padding: 20px;
    white-space: pre;
    color: #ffffff;
    user-select: text;
    transform-origin: center center;
}

/* Status loading overlay */
.status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 9, 19, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 10;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

.status-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(56, 189, 248, 0.1);
    border-top: 3px solid var(--text-highlight);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#status-message {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 80%;
    text-align: center;
}

/* Stats Footer details */
.display-footer {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.75rem;
}

.stat-item {
    display: flex;
    gap: 6px;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    color: var(--text-highlight);
    font-family: var(--font-mono);
    font-weight: 600;
}
