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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Board Selector Styling */
.board-selector {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px 20px;
    margin: 20px auto;
    max-width: 520px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.board-selector label {
    font-weight: 600;
    color: #4a5568;
    font-size: 1.1em;
}

.board-selector select {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    min-width: 200px;
}

.board-selector select:hover {
    border-color: #764ba2;
    background: #f7fafc;
}

.board-selector select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.board-selector optgroup {
    font-weight: 700;
    color: #764ba2;
    font-style: normal;
}

.board-selector option {
    font-weight: 400;
    color: #333;
    padding-left: 10px;
}

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

.panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.panel h2 {
    margin-bottom: 20px;
    color: #4a5568;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

/* Board Title inside Pin Diagram */
.panel h3 {
    color: #667eea;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.2em;
    padding: 10px;
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.esp32-diagram {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
}

/* Scrollbar styling */
.esp32-diagram::-webkit-scrollbar {
    width: 8px;
}

.esp32-diagram::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.esp32-diagram::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.esp32-diagram::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.pin-button {
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.pin-button:hover {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.pin-button.selected {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #5a67d8;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.pin-name {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.95em;
}

.pin-type {
    font-size: 0.85em;
    color: #666;
}

.pin-button.selected .pin-type {
    color: #e2e8f0;
}

.pin-config {
    margin-top: 20px;
}

.pin-config > p {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 20px;
}

.config-section {
    background: #f7fafc;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.config-section h4 {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.1em;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #4a5568;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.code-editor {
    background: #1a202c;
    color: #e2e8f0;
    border: none;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    width: 100%;
    min-height: 400px;
    resize: vertical;
}

.code-editor:focus {
    outline: 2px solid #667eea;
}

/* ─── Action Buttons ─── */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px;
    margin: 3px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #edf2f7;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
    border-color: #cbd5e0;
    transform: translateY(-2px);
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.btn-warning {
    background-color: #ffc107;
    color: #000;
}

.btn-warning:hover:not(:disabled) {
    background-color: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

/* Continue Flash button - distinct teal/cyan */
.btn-flash-continue {
    background: linear-gradient(135deg, #00b4d8, #0077b6);
    color: white;
}

.btn-flash-continue:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 180, 216, 0.4);
}

/* Serial Shortcuts button */
.btn-info {
    background: linear-gradient(135deg, #38b2ac, #2c7a7b);
    color: white;
}

.btn-info:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(56, 178, 172, 0.4);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

/* ─── Output / Terminal Panel ─── */
.output-panel {
    grid-column: 1 / -1;
    margin-top: 20px;
}

.output-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.output-header h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
    flex: 1;
}

/* Tab toggle */
.output-toggle {
    display: flex;
    background: #edf2f7;
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
}

.toggle-btn {
    padding: 6px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    background: transparent;
    color: #718096;
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Tab content */
.tab-content {
    display: none;
}

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

.output {
    background: #1a202c;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
    min-height: 150px;
    max-height: 300px;
    white-space: pre-wrap;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
}

.output::-webkit-scrollbar {
    width: 8px;
}

.output::-webkit-scrollbar-track {
    background: #2d3748;
    border-radius: 10px;
}

.output::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

/* Terminal-specific styles */
.terminal-output {
    background: #0d1117;
    color: #58a6ff;
    border: 1px solid #30363d;
    min-height: 200px;
    max-height: 280px;
}

.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px 12px;
}

.terminal-prompt {
    color: #3fb950;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 15px;
    font-weight: bold;
    flex-shrink: 0;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e6edf3;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    caret-color: #58a6ff;
}

.terminal-input::placeholder {
    color: #484f58;
}

/* color classes */
.error {
    color: #fc8181;
}

.success {
    color: #68d391;
}

.warning {
    color: #f6e05e;
}

.info {
    color: #63b3ed;
}

/* ─── Shortcuts Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 14px;
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: fadeIn 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #2d3748;
    color: #e2e8f0;
    font-weight: 700;
    font-size: 1.1em;
}

.modal-close {
    background: none;
    border: none;
    color: #718096;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #fc8181;
    background: rgba(252, 129, 129, 0.1);
}

.modal-body {
    padding: 16px 20px;
}

.shortcut-group {
    margin-bottom: 20px;
}

.shortcut-group-title {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #667eea;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #2d3748;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 0;
    color: #cbd5e0;
    font-size: 0.9em;
    border-bottom: 1px solid #1a202c;
}

.shortcut-row.cmd-row {
    cursor: pointer;
    padding: 7px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}

.shortcut-row.cmd-row:hover {
    background: rgba(102, 126, 234, 0.15);
    color: #e2e8f0;
}

.shortcut-row kbd {
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 5px;
    padding: 3px 9px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85em;
    color: #63b3ed;
    white-space: nowrap;
}

/* Template selector */
.template-selector-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.template-selector-row label {
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}

.template-selector-row select {
    flex: 1;
    min-width: 160px;
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 0.95em;
    background: white;
    color: #333;
    cursor: pointer;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .esp32-diagram {
        grid-template-columns: 1fr;
        max-height: 400px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .board-selector {
        flex-direction: column;
        gap: 10px;
    }
    
    .board-selector select {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5em;
    }
    
    .header p {
        font-size: 0.9em;
    }
    
    .panel {
        padding: 15px;
    }
    
    .code-editor {
        min-height: 300px;
        font-size: 12px;
    }
}

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

.panel {
    animation: fadeIn 0.5s ease-out;
}

.pin-button {
    animation: fadeIn 0.3s ease-out;
}
