:root {
    /* Color Palette */
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-tertiary: #1e2442;
    --bg-card: rgba(30, 36, 66, 0.6);
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: rgba(148, 163, 184, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    /* Animation */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* Header */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.6s ease;
}

.header-content {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5));
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    animation: fadeIn 0.8s ease;
}

/* Control Panel */
.control-panel {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    height: fit-content;
    position: sticky;
    top: var(--spacing-lg);
}

.panel-header h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: var(--spacing-xs);
}

.operation-group {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.operation-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.operation-group h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.input-group {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
    flex-wrap: wrap;
}

.input-field {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'JetBrains Mono', monospace;
    transition: all var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-small {
    flex: 0 1 80px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-accent {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

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

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Speed Control */
.speed-control {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.speed-control label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

#speedSlider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

#speedSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    transition: all var(--transition-fast);
}

#speedSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.6);
}

/* Visualization Area */
.visualization-area {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--accent-primary);
}

.viz-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.list-info {
    display: flex;
    gap: var(--spacing-sm);
}

.info-badge {
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.info-badge strong {
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
}

/* Linked List Container */
.linked-list-container {
    min-height: 300px;
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 20px;
    position: relative;
}

.empty-state {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-sm);
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-xs);
}

.empty-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Node Styling */
.node {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: nodeAppear 0.5s ease;
    position: relative;
}

@keyframes nodeAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.node-box {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: var(--spacing-md);
    min-width: 180px;
    box-shadow: var(--shadow-md), 0 0 20px rgba(99, 102, 241, 0.2);
    transition: all var(--transition-normal);
    position: relative;
}

.node-box:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.4);
    border-color: var(--accent-secondary);
}

.node-address {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.node-address::before {
    content: '📍';
    font-size: 0.9rem;
}

.node-data {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    margin: var(--spacing-xs) 0;
}

.node-next {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.node-next::before {
    content: '→';
    font-size: 1rem;
}

.arrow {
    color: var(--accent-primary);
    font-size: 2rem;
    font-weight: bold;
    animation: arrowPulse 2s ease-in-out infinite;
}

@keyframes arrowPulse {
    0%, 100% {
        opacity: 1;
        transform: translateX(0);
    }
    50% {
        opacity: 0.6;
        transform: translateX(5px);
    }
}

.null-indicator {
    background: var(--bg-tertiary);
    border: 2px dashed var(--text-muted);
    border-radius: 8px;
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Highlight Effects */
.node-highlight {
    animation: highlightPulse 1s ease;
}

@keyframes highlightPulse {
    0%, 100% {
        border-color: var(--accent-primary);
        box-shadow: var(--shadow-md), 0 0 20px rgba(99, 102, 241, 0.2);
    }
    50% {
        border-color: var(--accent-warning);
        box-shadow: var(--shadow-lg), 0 0 40px rgba(245, 158, 11, 0.6);
    }
}

.node-delete {
    animation: nodeDelete 0.5s ease forwards;
}

@keyframes nodeDelete {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(10deg);
    }
}

/* Log Panel */
.log-panel {
    margin-top: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.log-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.btn-clear-log {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-clear-log:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

.log-container {
    max-height: 200px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.log-entry {
    padding: 0.5rem;
    margin-bottom: 0.3rem;
    border-radius: 6px;
    display: flex;
    gap: var(--spacing-sm);
    animation: logAppear 0.3s ease;
}

@keyframes logAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.log-message {
    color: var(--text-secondary);
}

.log-info {
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--accent-primary);
}

.log-success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--accent-success);
}

.log-error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--accent-danger);
}

.log-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--accent-warning);
}

/* Info Section */
.info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
    animation: fadeIn 1s ease;
}

.info-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.info-card h3 {
    font-size: 1.3rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.info-card p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.7;
}

.info-card ul {
    list-style: none;
    padding-left: 0;
}

.info-card li {
    color: var(--text-secondary);
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.info-card li::before {
    content: '▹';
    position: absolute;
    left: 0;
    color: var(--accent-primary);
    font-weight: bold;
}

/* Complexity Table */
.complexity-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-sm);
}

.complexity-table th,
.complexity-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.complexity-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.complexity-table td {
    color: var(--text-secondary);
}

.complexity-table code {
    background: var(--bg-tertiary);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.complexity-table tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    .title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .info-section {
        grid-template-columns: 1fr;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-small {
        flex: 1;
    }
}
