
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #22d3ee;
    --accent-glow: rgba(34, 211, 238, 0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #252542;
    --border: #2d2d4a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-2: linear-gradient(135deg, #22d3ee 0%, #6366f1 100%);
    --glass: rgba(26, 26, 46, 0.8);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.bg-animation::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.05) 0%, transparent 50%);
    animation: bgPulse 15s ease-in-out infinite;
}

@keyframes bgPulse {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* Header */
.header {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

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

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
}

/* Main Layout */
.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    gap: 1.5rem;
    min-height: calc(100vh - 80px);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.1);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.card-icon {
    width: 28px;
    height: 28px;
    background: var(--gradient-2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Left Panel - Controls */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group {
    margin-bottom: 0.5rem;
}

.control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.control-label span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.control-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(34, 211, 238, 0.1);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
}

/* Custom Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--gradient-1);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
    transition: all 0.2s ease;
}

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

/* Number Input */
.number-input {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.number-input input {
    width: 55px;
    padding: 0.3rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    text-align: center;
}

.number-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

.number-btn {
    width: 24px;
    height: 24px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

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

/* Preset Buttons */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.4rem 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.preset-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.preset-btn.active {
    background: var(--gradient-1);
    border-color: transparent;
}

/* Center Panel - Visualization */
.center-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.canvas-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-1);
}

#theCanvas {
    width: 100%;
    border-radius: 8px;
    display: block;
}

/* Display Toggle */
.display-toggle {
    display: flex;
    background: var(--bg-dark);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.toggle-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: var(--gradient-1);
    color: white;
    font-weight: 500;
}

/* Phasor Clocks Info */
.phasor-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.phasor-info-icon {
    font-size: 1.25rem;
}

.phasor-info-text {
    font-size: 0.8rem;
    color: var(--accent);
}

/* Right Panel - Info & Data */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Live Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.625rem 0.5rem;
    text-align: left;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.data-table td {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.data-value {
    color: var(--accent);
}

/* Energy Level Indicator */
.energy-bar {
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.energy-fill {
    height: 100%;
    background: var(--gradient-2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Instructions Panel */
.instruction-step {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.instruction-step:hover {
    background: var(--bg-card-hover);
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--gradient-1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Formula Display */
.formula-box {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    margin-bottom: 0.75rem;
}

.formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    color: var(--accent);
}

.formula-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--success);
}

.status-badge.paused {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.status-badge.paused .status-dot {
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Tooltip */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Quick Actions Bar */
.quick-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.action-btn {
    flex: 1;
    min-width: 60px;
    padding: 0.4rem 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.action-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.action-btn span {
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .left-panel,
    .right-panel {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .left-panel,
    .right-panel {
        grid-template-columns: 1fr;
    }

    .main-container {
        padding: 1rem;
    }
}

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

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

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

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