/* ==================== Global Styles ==================== */

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

:root {
    --primary-color: #3498db;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --gray-color: #95a5a6;
    --accent-color: #e67e22;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--dark-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}


/* ==================== Header ==================== */

.header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}


/* ==================== Main Layout ==================== */

.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.panel:hover {
    box-shadow: var(--shadow-hover);
}

.panel h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--dark-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

.panel-copy {
    margin-bottom: 14px;
    color: var(--dark-color);
    font-size: 0.95rem;
}

.main-area {
    display: flex;
    flex-direction: column;
    gap: 25px;
}


/* ==================== Example Selector ==================== */

#example-select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--light-color);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

#example-select:hover {
    border-color: var(--primary-color);
}

#example-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}


/* ==================== Canvas Section ==================== */

.canvas-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.canvas-section h2 {
    margin-bottom: 20px;
    color: var(--dark-color);
}

#tape-canvas {
    width: 100%;
    height: 200px;
    border: 2px solid var(--light-color);
    border-radius: var(--border-radius);
    background: white;
}

.status-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.status-item {
    background: var(--light-color);
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
}

.status-item .label {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-color);
    margin-bottom: 5px;
}

.status-item .value {
    display: block;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--dark-color);
}


/* ==================== Control Section ==================== */

.control-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tape-editor {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.tape-editor h3 {
    width: 100%;
    margin-bottom: 10px;
}

#tape-input {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 2px solid var(--light-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

#tape-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.execution-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.speed-control label {
    font-weight: 500;
}

#speed-slider {
    flex: 1;
    max-width: 300px;
}

#speed-value {
    min-width: 60px;
    font-weight: bold;
}


/* ==================== Buttons ==================== */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #27ae60;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #e67e22;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.btn-secondary {
    background: var(--light-color);
    color: var(--dark-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}


/* ==================== Rules Section ==================== */

.rules-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.rules-section h3 {
    margin-bottom: 20px;
}

.rules-editor {
    overflow-x: auto;
}

#rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

#rules-table th {
    background: var(--dark-color);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 500;
}

#rules-table td {
    padding: 10px;
    border-bottom: 1px solid var(--light-color);
}

#rules-table tr:hover {
    background: var(--light-color);
}

.rule-input {
    width: 100%;
    padding: 8px;
    border: 2px solid var(--light-color);
    border-radius: 4px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.rule-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.rule-input[type="select"] {
    cursor: pointer;
}

.rules-actions {
    display: flex;
    gap: 10px;
}


/* ==================== Log Section ==================== */

.log-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.log-section h3 {
    margin-bottom: 15px;
}

.log-container {
    max-height: 300px;
    overflow-y: auto;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: var(--border-radius);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.8;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid #333;
}

.log-time {
    color: #6a9955;
    font-weight: bold;
    margin-right: 10px;
}


/* ==================== Footer ==================== */

.footer {
    text-align: center;
    padding: 20px;
    background: var(--dark-color);
    color: white;
    border-radius: var(--border-radius);
    margin-top: 30px;
}


/* ==================== Responsive Design ==================== */

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .status-display {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .execution-controls {
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        min-width: 100px;
    }
    
    #rules-table {
        font-size: 0.85rem;
    }
    
    #rules-table th,
    #rules-table td {
        padding: 8px 5px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .status-display {
        grid-template-columns: 1fr;
    }
    
    .tape-editor {
        flex-direction: column;
    }
    
    #tape-input {
        width: 100%;
    }
}


/* ==================== Animations ==================== */

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

.panel,
.canvas-section,
.control-section,
.rules-section,
.log-section {
    animation: fadeIn 0.5s ease;
}


/* ==================== Scrollbar Styling ==================== */

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

.log-container::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 5px;
}

.log-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: #777;
}


/* ==================== Utility Classes ==================== */

.text-center {
    text-align: center;
}

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

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}
