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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 2rem;
    font-weight: 300;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#status {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

.status-connected {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.status-disconnected {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

button {
    background: #2196F3;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

button:hover {
    background: #1976D2;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.program-type-selector {
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.program-type-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.program-type-btn {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.program-type-btn:hover {
    background: #dee2e6;
}

.program-type-btn.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.tab-btn {
    background: transparent;
    color: #666;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(33, 150, 243, 0.1);
    color: #2196F3;
}

.tab-btn.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
    background: rgba(33, 150, 243, 0.05);
}

.tab-content {
    display: none;
    padding: 2rem;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 1.5rem;
}

.speed-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.speed-input-group input {
    flex: 1;
}

.speed-input-group select {
    min-width: 120px;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

input[type="number"]:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.help {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.25rem;
}

.program-builder {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.steps-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
}

.program-selector {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.program-name {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.program-name input {
    width: 100%;
    max-width: 200px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: monospace;
    font-weight: bold;
    text-transform: uppercase;
}

.program-name input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.program-selector label {
    display: inline-block;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.program-selector select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    min-width: 150px;
}

.program-selector select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.program-step {
    background: #f8f9fa;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border-left: 4px solid #2196F3;
}

.program-step h4 {
    margin-bottom: 0.75rem;
    color: #333;
}

.program-step label {
    display: inline-block;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.program-step .speed-input-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.program-step .speed-input-group select {
    padding: 0.25rem;
    min-width: 60px;
    margin-left: 0;
}

.program-step input {
    width: 100px;
    padding: 0.25rem;
    margin-left: 0.5rem;
}

.program-step button {
    background: #f44336;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    margin-left: 1rem;
}

.program-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 400px;
}

.position-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.position-control input {
    flex: 1;
}

.program-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.home-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

#setHomeBtn {
    background: #4CAF50;
}

#setHomeBtn:hover {
    background: #45a049;
}

#homeBtn {
    background: #FF9800;
}

#homeBtn:hover {
    background: #F57C00;
}

#startBtn {
    background: #4CAF50;
}

#startBtn:hover {
    background: #45a049;
}

#stopBtn {
    background: #f44336;
}

#stopBtn:hover {
    background: #da190b;
}

#homeBtn {
    background: #4CAF50;
    align-self: flex-start;
}

.console {
    background: #1e1e1e;
    color: #fff;
    padding: 1rem;
    margin: 2rem;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

.console h3 {
    color: #4CAF50;
    margin-bottom: 0.5rem;
}

#console-output {
    height: 200px;
    overflow-y: auto;
    background: #2d2d2d;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.4;
}

#console-output div {
    margin-bottom: 0.25rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        margin: 0;
        box-shadow: none;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 120px;
    }
    
    .program-builder {
        grid-template-columns: 1fr;
    }
    
    .position-control {
        flex-direction: column;
        align-items: stretch;
    }
    
    .console {
        margin: 1rem;
    }
}

/* Animation for smooth transitions */
.tab-content {
    animation: fadeIn 0.3s ease-in-out;
}

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