/* Global Variables & Colors */
:root {
    --bg-gradient-start: #0a0c16;
    --bg-gradient-end: #121528;
    --panel-bg: rgba(20, 24, 46, 0.55);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f1f3fa;
    --text-secondary: #8a92b2;
    --text-disabled: #4e536c;

    /* Neon Accents */
    --accent-purple: hsl(270, 85%, 65%);
    --accent-cyan: hsl(180, 85%, 55%);
    --accent-green: hsl(145, 80%, 55%);
    --accent-orange: hsl(25, 95%, 60%);
    --accent-red: hsl(350, 85%, 58%);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(270, 85%, 65%), hsl(240, 80%, 65%));
    --gradient-accent: linear-gradient(135deg, hsl(180, 85%, 55%), hsl(210, 90%, 60%));
    --gradient-danger: linear-gradient(135deg, hsl(350, 85%, 58%), hsl(330, 90%, 60%));
    --gradient-success: linear-gradient(135deg, hsl(145, 80%, 55%), hsl(165, 85%, 50%));
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at 50% 50%, var(--bg-gradient-end) 0%, var(--bg-gradient-start) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    padding: 16px;
    gap: 16px;
}

/* Glassmorphism Panel Utility */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Sidebar Controls */
.sidebar {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    gap: 24px;
}

.app-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 16px;
}

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

.logo-dot {
    width: 12px;
    height: 12px;
    background: var(--accent-purple);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent-purple);
}

.app-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #ffffff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Status Badges */
.badge {
    align-self: flex-start;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.badge.disconnected {
    background: rgba(235, 87, 87, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(235, 87, 87, 0.25);
}

.badge.connected {
    background: rgba(39, 174, 96, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(39, 174, 96, 0.25);
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.15);
}

/* Sidebar Config Sections */
.config-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.config-section h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
}

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

label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.15);
}

input[type="text"]:disabled,
select:disabled {
    color: var(--text-disabled);
    border-color: rgba(255, 255, 255, 0.03);
    background: rgba(255, 255, 255, 0.01);
    cursor: not-allowed;
}

.url-input-row,
.device-actions {
    display: flex;
    gap: 8px;
}

.url-input-row input {
    flex-grow: 1;
}

.device-actions select {
    flex-grow: 1;
}

/* Button Styles */
.btn {
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.primary-btn {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(168, 85, 247, 0.35);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(168, 85, 247, 0.45);
}

.primary-btn:active {
    transform: translateY(0);
}

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

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

.danger-btn {
    background: var(--gradient-danger);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(235, 87, 87, 0.3);
}

.danger-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(235, 87, 87, 0.4);
}

.accent-btn {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(6, 182, 212, 0.3);
}

.accent-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(6, 182, 212, 0.4);
}

/* Device Status Indicator */
.device-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-indicator.ready {
    color: var(--accent-green);
    font-weight: 500;
}

.battery-status {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 4px;
}

.battery-status.hidden {
    display: none;
}

/* Channel Selector Grid & Pills */
.channel-selector-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 6px;
    margin-bottom: 12px;
}

.channel-select-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
    padding: 7px 0;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    outline: none;
}

.channel-select-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.channel-select-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.channel-select-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* Switch styling */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:checked+.slider {
    background-color: var(--accent-purple);
    box-shadow: 0 0 6px rgba(168, 85, 247, 0.4);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-purple);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Main Display Area Layout */
.main-display {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

/* Top Control Bar */
.control-bar {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.run-info {
    display: flex;
    gap: 24px;
}

.run-info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.recording-controls {
    display: flex;
    gap: 12px;
}

/* Upload Progress Card */
.upload-progress-card {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.upload-progress-card.hidden {
    display: none;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-title {
    font-size: 0.9rem;
    font-weight: 500;
}

#progress-percent {
    font-weight: 600;
    color: var(--accent-cyan);
}

.progress-bar-wrapper {
    height: 8px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: 10px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.upload-status-msg {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Plots Grid Container */
.plots-grid-container {
    flex-grow: 1;
    overflow: hidden;
}

.plots-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

/* Individual Channel Plot wrapper */
.canvas-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 200px;
    flex-shrink: 0;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.canvas-wrapper:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.channel-label {
    position: absolute;
    top: 10px;
    left: 12px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(10, 12, 22, 0.8);
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.canvas-wrapper canvas {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    background: transparent;
    display: block;
}

/* Keyframe Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom Scrollbar for elements */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}