/* Web Serial Studio (Web 串口调试助手) Styles */

.ws-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    color: var(--text-main);
}

/* Header & Status Bar */
.ws-top-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.ws-port-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    background: #090d16;
    border: 1px solid var(--border);
}

.ws-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #64748b;
    display: inline-block;
    transition: all 0.3s ease;
}

.ws-status-indicator.connected {
    background-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.ws-status-indicator.connecting {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Quick Pin Controls (DTR / RTS / MCU Reset) */
.ws-pin-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ws-pin-btn {
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ws-pin-btn:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.ws-pin-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-hover);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

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

/* Main Workspace Layout */
.ws-workspace {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--spacing-sm);
    align-items: start;
}

@media (max-width: 1024px) {
    .ws-workspace {
        grid-template-columns: 1fr;
    }
}

/* Left Configuration Panel */
.ws-config-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ws-config-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ws-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ws-form-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ws-form-select,
.ws-form-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease;
    width: 100%;
}

.ws-form-select:focus,
.ws-form-input:focus {
    border-color: var(--primary);
}

/* Right Content Area & Tabs */
.ws-main-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.ws-tabs-bar {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    overflow-x: auto;
}

.ws-tab-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ws-tab-btn:hover {
    color: var(--text-main);
    border-color: #4b5563;
}

.ws-tab-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.ws-tab-content {
    display: none;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.ws-tab-content.active {
    display: flex;
}

/* Terminal & Log Viewer */
.ws-terminal-container {
    background: #090c13;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 480px;
    position: relative;
}

.ws-terminal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: #111622;
    border-bottom: 1px solid var(--border);
}

.ws-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ws-btn-tool {
    padding: 4px 10px;
    font-size: 0.76rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ws-btn-tool:hover {
    background: #2d3748;
    border-color: #4b5563;
}

.ws-btn-tool.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-hover);
}

.ws-terminal-screen {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    font-family: 'JetBrains Mono', Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #cbd5e1;
    white-space: pre-wrap;
    word-break: break-all;
    user-select: text;
    background: #06090e;
}

.ws-terminal-screen.no-wrap {
    white-space: pre;
    overflow-x: auto;
}

/* Log Entry Styling */
.ws-log-entry {
    margin-bottom: 3px;
    border-radius: 3px;
    padding: 2px 4px;
    transition: background 0.15s ease;
}

.ws-log-entry:hover {
    background: rgba(255, 255, 255, 0.04);
}

.ws-log-ts {
    color: #64748b;
    font-size: 0.78rem;
    margin-right: 6px;
    user-select: none;
}

.ws-log-tag {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 3px;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}

.ws-log-tag.rx {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.ws-log-tag.tx {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.ws-log-tag.sys {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.ws-log-tag.err {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.ws-log-content {
    color: #e2e8f0;
}

.ws-log-content.hex {
    color: #38bdf8;
    font-family: 'JetBrains Mono', monospace;
}

.ws-log-highlight {
    background-color: #eab308;
    color: #000;
    font-weight: bold;
    border-radius: 2px;
    padding: 0 2px;
}

/* Stats Footer Bar */
.ws-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 6px 14px;
    background: #0e131d;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: #94a3b8;
}

.ws-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ws-stat-val {
    font-weight: 600;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
}

/* Transmit Panel */
.ws-tx-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ws-tx-input-container {
    position: relative;
    width: 100%;
}

.ws-tx-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-main);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.4;
    resize: vertical;
    min-height: 80px;
    outline: none;
    box-sizing: border-box;
}

.ws-tx-textarea:focus {
    border-color: var(--primary);
}

.ws-tx-options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ws-tx-options-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ws-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.ws-checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
}

.ws-tx-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Quick Commands Table */
.ws-quick-commands-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ws-cmd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.ws-cmd-table th,
.ws-cmd-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.ws-cmd-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    background: rgba(0, 0, 0, 0.2);
}

.ws-cmd-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.ws-cmd-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 8px;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    width: 100%;
}

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

/* Real-time Waveform Scope */
.ws-scope-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ws-scope-canvas-container {
    background: #04070d;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    position: relative;
    width: 100%;
    height: 380px;
    overflow: hidden;
}

.ws-scope-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.ws-scope-channels {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.ws-channel-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    background: #111827;
    border: 1px solid var(--border);
}

.ws-channel-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Modbus RTU Assistant */
.ws-modbus-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ws-modbus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.ws-modbus-preview-box {
    background: #090c13;
    border: 1px solid #1e293b;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    color: #38bdf8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ws-modbus-breakdown {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ws-modbus-field {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: #1e293b;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #334155;
}

.ws-modbus-field-name {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.ws-modbus-field-val {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f1f5f9;
}

/* Browser Compatibility Warning Banner */
.ws-unsupported-banner {
    display: none;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    color: #fca5a5;
    font-size: 0.88rem;
    margin-bottom: var(--spacing-sm);
}

.ws-unsupported-banner.show {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
