/* Boiler Terminal CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Consolas', 'Monaco', monospace;
    background-color: #1e1e1e;
    color: #ffffff;
    line-height: 1.4;
}

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

/* Header */
.header {
    background-color: #2d2d2d;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    color: #4CAF50;
    font-size: 24px;
    font-weight: bold;
}

.boiler-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.boiler-selector label {
    color: #cccccc;
    font-weight: bold;
}

.boiler-selector select {
    background-color: #404040;
    color: #ffffff;
    border: 1px solid #666666;
    border-radius: 4px;
    padding: 8px 12px;
    min-width: 200px;
}

.boiler-selector button {
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
}

.boiler-selector button:hover {
    background-color: #45a049;
}

/* Server Status */
.server-status {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
}

.server-status.connected {
    background-color: #4CAF50;
    color: white;
}

.server-status.disconnected {
    background-color: #f44336;
    color: white;
}

.server-status.connecting {
    background-color: #ff9800;
    color: white;
}

.server-status.error {
    background-color: #9c27b0;
    color: white;
}

/* Boiler Info */
.boiler-info {
    background-color: #2a2a2a;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.boiler-info h3 {
    color: #4CAF50;
    margin-bottom: 10px;
    font-size: 20px;
}

.boiler-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.boiler-details span {
    color: #cccccc;
}

.device-count {
    background-color: #2196F3;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

/* Device Tabs */
.device-tabs {
    background-color: #2d2d2d;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.tab-header {
    background-color: #3d3d3d;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 10px;
    border-bottom: 2px solid #555555;
}

.tab-button {
    background-color: #555555;
    color: #cccccc;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-button:hover {
    background-color: #666666;
    color: #ffffff;
}

.tab-button.active {
    background-color: #4CAF50;
    color: white;
}

.device-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-left: 10px;
}

.device-tab {
    position: relative;
}

.device-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.connection-type {
    background-color: #333;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    margin-right: 2px;
    min-width: 20px;
    text-align: center;
    border: 1px solid #555;
}

.tab-button:hover .connection-type {
    background-color: #444;
    border-color: #666;
}

.tab-button.active .connection-type {
    background-color: #2d7d32;
    border-color: #4CAF50;
}

.device-status.online {
    background-color: #4CAF50;
    box-shadow: 0 0 6px #4CAF50;
}

.device-status.offline {
    background-color: #f44336;
}

/* Tab Content */
.tab-content {
    padding: 20px;
}

.tab-pane {
    display: none;
}

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

.tab-pane h4 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 18px;
}

/* Broadcast Controls */
.broadcast-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
}

.broadcast-controls input {
    flex: 1;
    min-width: 300px;
    background-color: #404040;
    color: #ffffff;
    border: 1px solid #666666;
    border-radius: 4px;
    padding: 12px;
    font-family: inherit;
}

.broadcast-controls button {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}

.broadcast-controls button:hover {
    background-color: #1976D2;
}

#discover-btn {
    background-color: #FF9800;
}

#discover-btn:hover {
    background-color: #F57C00;
}

/* Device Tab Content */
.device-info {
    background-color: #3a3a3a;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.device-details {
    color: #cccccc;
    line-height: 1.6;
}

.device-status-text.online {
    color: #4CAF50;
    font-weight: bold;
}

.device-status-text.offline {
    color: #f44336;
    font-weight: bold;
}

.device-controls {
    margin-bottom: 20px;
}

.message-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.message-input-group input {
    flex: 1;
    min-width: 300px;
    background-color: #404040;
    color: #ffffff;
    border: 1px solid #666666;
    border-radius: 4px;
    padding: 10px;
    font-family: inherit;
}

.message-input-group button {
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: bold;
}

.message-input-group button:hover {
    background-color: #45a049;
}

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

.action-btn {
    background-color: #666666;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.action-btn:hover {
    background-color: #777777;
}

/* Device Output */
.device-output {
    background-color: #1a1a1a;
    border-radius: 6px;
    padding: 15px;
}

.device-output h5 {
    color: #4CAF50;
    margin-bottom: 10px;
    font-size: 14px;
}

.device-messages {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 10px;
    background-color: #0a0a0a;
}

.device-message {
    margin-bottom: 5px;
    padding: 5px 0;
    border-bottom: 1px solid #333333;
}

.device-message:last-child {
    border-bottom: none;
}

.device-message.sent .message {
    color: #2196F3;
}

.device-message.received .message {
    color: #4CAF50;
}

/* Terminal Section */
.terminal-section, .realtime-section {
    background-color: #2d2d2d;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.terminal-header {
    background-color: #3d3d3d;
    padding: 15px;
    border-bottom: 2px solid #555555;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-header h3 {
    color: #4CAF50;
    font-size: 18px;
}

#clear-log-btn {
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
}

#clear-log-btn:hover {
    background-color: #d32f2f;
}

/* Terminal */
.terminal {
    height: 500px;
    overflow-y: auto;
    padding: 15px;
    background-color: #1a1a1a;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

.log-entry {
    margin-bottom: 5px;
    padding: 3px 0;
}

.timestamp {
    color: #888888;
    font-size: 11px;
    margin-right: 10px;
}

.message {
    color: #ffffff;
}

.log-entry.log-success .message {
    color: #4CAF50;
}

.log-entry.log-error .message {
    color: #f44336;
}

.log-entry.log-info .message {
    color: #2196F3;
}

.log-entry.log-sent .message {
    color: #FF9800;
    font-weight: bold;
}

.log-entry.log-device-response .message {
    color: #4CAF50;
    background-color: #1a3a1a;
    padding: 2px 6px;
    border-radius: 3px;
}

.log-entry.log-direct-message .message {
    color: #9C27B0;
    font-weight: bold;
}

.log-entry.log-broadcast-message .message {
    color: #FF5722;
    font-weight: bold;
}

/* Real-time Terminal */
.realtime-terminal {
    background-color: #1a1a1a;
    padding: 15px;
}

.realtime-status {
    background-color: #666666;
    color: white;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}

.realtime-output {
    min-height: 300px;
    max-height: 500px;
    background-color: #0a0a0a;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.realtime-char {
    color: #00ff00;
    background-color: #1a3a1a;
    padding: 1px 2px;
    margin: 0 1px;
    border-radius: 2px;
    /* animation: blink 1s; */
}

/* @keyframes blink {
    0% { background-color: #4CAF50; }
    100% { background-color: #1a3a1a; }
} */

.realtime-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.prompt {
    color: #4CAF50;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.realtime-input input {
    flex: 1;
    background-color: #404040;
    color: #ffffff;
    border: 1px solid #666666;
    border-radius: 4px;
    padding: 10px;
    font-family: 'Courier New', monospace;
}

.realtime-input input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .terminal-container {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .boiler-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .boiler-selector select {
        min-width: auto;
    }
    
    .tab-header {
        flex-direction: column;
    }
    
    .device-buttons {
        margin-left: 0;
        margin-top: 10px;
    }
    
    .broadcast-controls {
        flex-direction: column;
    }
    
    .broadcast-controls input {
        min-width: auto;
    }
    
    .message-input-group {
        flex-direction: column;
    }
    
    .message-input-group input {
        min-width: auto;
    }
    
    .device-actions {
        flex-direction: column;
    }
    
    .terminal {
        height: 400px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background-color: #2d2d2d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background-color: #666666;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #777777;
}

/* Connection Buttons */
.connection-button {
    padding: 10px 20px;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.connection-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.connection-button:disabled {
    background-color: #BDBDBD;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* WebSocket Button */
.ws-button {
    background-color: #2196F3;
}

.ws-button:hover {
    background-color: #1976D2;
}

.ws-button.connected {
    background-color: #4CAF50;
}

.ws-button.connected:hover {
    background-color: #45a049;
}

/* BLE Button */
.ble-button {
    background-color: #9C27B0;
}

.ble-button:hover {
    background-color: #7B1FA2;
}

.ble-button.connected {
    background-color: #4CAF50;
}

.ble-button.connected:hover {
    background-color: #45a049;
}

/* Error Modal */
.error-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

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

.error-modal {
    background-color: #2d2d2d;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

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

.error-modal-header {
    background-color: #f44336;
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.error-icon {
    font-size: 32px;
}

.error-modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.error-modal-body {
    padding: 20px;
    color: #ffffff;
    line-height: 1.6;
}

.error-modal-body p {
    margin: 0;
    white-space: pre-line;
}

.error-modal-footer {
    padding: 20px;
    text-align: right;
    border-top: 1px solid #404040;
}

.error-modal-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.error-modal-btn:hover {
    background-color: #45a049;
}

/* Update server status for BLE */
.server-status {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    background-color: #666666;
    color: white;
}

.server-status.connected {
    background-color: #4CAF50;
    color: white;
}
