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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.header {
    text-align: center;
    margin-bottom: 25px;
}

.header h1 {
    color: #1e3c72;
    font-size: 2em;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    font-size: 0.9em;
}

/* Cards */
.status-card, .control-card, .advanced-controls, .info-card, .monitor-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 1.1em;
}

.status-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
}

.status-badge.connected {
    background: #28a745;
    color: white;
    animation: pulse 2s infinite;
}

.status-badge.disconnected {
    background: #dc3545;
    color: white;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

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

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    letter-spacing: 2px;
    font-family: monospace;
    font-size: 18px;
}

.input-group input:focus {
    outline: none;
    border-color: #1e3c72;
}

.input-group small {
    display: block;
    margin-top: 5px;
    color: #666;
}

/* Grid das saídas */
.outputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.output-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.output-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.output-header h3 {
    color: #1e3c72;
    font-size: 1.2em;
}

.output-led {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ccc;
    transition: all 0.3s ease;
}

.output-led.on {
    background: #ff4444;
    box-shadow: 0 0 10px #ff4444;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.output-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
}

.output-status-badge {
    font-weight: bold;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
}

.output-status-badge.on {
    background: #ff4444;
    color: white;
}

.output-status-badge.off {
    background: #666;
    color: white;
}

/* Botões */
button {
    padding: 10px 20px;
    margin: 5px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #1e3c72;
    color: white;
    padding: 12px 25px;
    font-size: 16px;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: #2a5298;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    padding: 12px 25px;
    font-size: 16px;
    width: 100%;
    margin-top: 10px;
}

.btn-secondary:hover:not(:disabled) {
    background: #545b62;
}

.btn-on {
    background: #ff4444;
    color: white;
    flex: 1;
}

.btn-on:hover:not(:disabled) {
    background: #cc0000;
}

.btn-off {
    background: #666;
    color: white;
    flex: 1;
}

.btn-off:hover:not(:disabled) {
    background: #444;
}

.btn-all-on {
    background: #ff4444;
    color: white;
}

.btn-all-on:hover:not(:disabled) {
    background: #cc0000;
}

.btn-all-off {
    background: #666;
    color: white;
}

.btn-all-off:hover:not(:disabled) {
    background: #444;
}

.btn-status {
    background: #17a2b8;
    color: white;
}

.btn-status:hover:not(:disabled) {
    background: #138496;
}

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

.btn-process:hover:not(:disabled) {
    background: #1e7e34;
}

.btn-process-stop {
    background: #ffc107;
    color: #333;
}

.btn-process-stop:hover:not(:disabled) {
    background: #e0a800;
}

.btn-small {
    background: #6c757d;
    color: white;
    padding: 5px 15px;
    font-size: 12px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    gap: 10px;
}

.btn-icon {
    margin-right: 5px;
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.quick-buttons button {
    flex: 1;
    min-width: 120px;
}

/* Informações do dispositivo */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.info-label {
    font-weight: bold;
    color: #555;
}

.info-value {
    font-family: monospace;
    font-size: 1.1em;
    color: #1e3c72;
}

/* Monitor de Mensagens */
.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.message-log {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
    padding: 15px;
    border-radius: 8px;
    height: 250px;
    overflow-y: auto;
    font-size: 12px;
}

.message-log p {
    margin: 5px 0;
    padding: 5px;
    border-left: 3px solid #007bff;
    padding-left: 10px;
}

.message-log .received {
    border-left-color: #28a745;
}

.message-log .sent {
    border-left-color: #ffc107;
}

.message-log .error {
    border-left-color: #dc3545;
    color: #ff6b6b;
}

.message-log .info {
    border-left-color: #17a2b8;
    color: #7ab8cc;
}

/* Step Programming */
.step-programming-card {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.steps-container {
    background: white;
    border-radius: 10px;
    overflow-x: auto;
}

.step-header {
    display: grid;
    grid-template-columns: 60px 100px 1fr 100px 80px;
    gap: 10px;
    padding: 12px;
    background: #1e3c72;
    color: white;
    font-weight: bold;
    border-radius: 8px 8px 0 0;
}

.step-row {
    display: grid;
    grid-template-columns: 60px 100px 1fr 100px 80px;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    align-items: center;
}

.step-row:hover {
    background: #f8f9fa;
}

.step-number {
    font-weight: bold;
    color: #1e3c72;
    text-align: center;
}

.step-output, .step-action {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.step-time {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    width: 100%;
}

.btn-step-test {
    background: #17a2b8;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-step-test:hover:not(:disabled) {
    background: #138496;
}

.step-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    align-items: center;
}

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

.btn-run-steps:hover:not(:disabled) {
    background: #1e7e34;
}

.btn-stop-steps {
    background: #dc3545;
    color: white;
}

.btn-stop-steps:hover:not(:disabled) {
    background: #c82333;
}

.btn-save-steps {
    background: #ffc107;
    color: #333;
}

.btn-save-steps:hover:not(:disabled) {
    background: #e0a800;
}

.btn-load-steps {
    background: #17a2b8;
    color: white;
}

.loop-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.step-status {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    font-weight: bold;
}

#stepExecutionStatus {
    color: #28a745;
    font-weight: bold;
}

#currentStep {
    color: #1e3c72;
    margin-left: 10px;
}

.btn-send-program {
    background: #6f42c1;
    color: white;
}

.btn-send-program:hover:not(:disabled) {
    background: #5a32a3;
}

/* Tabs */
.step-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #1e3c72;
    border-bottom: 2px solid #1e3c72;
    margin-bottom: -2px;
}

.tab-content {
    display: none;
}

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

/* Steps Paralelos */
.parallel-steps-container {
    background: white;
    border-radius: 10px;
    overflow-x: auto;
}

.parallel-step-row {
    display: grid;
    grid-template-columns: 80px 1fr 200px 100px;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #ddd;
    align-items: center;
}

.parallel-step-row:hover {
    background: #f8f9fa;
}

.outputs-select {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.outputs-select label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

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

.parallel-time {
    width: 120px;
    padding: 8px;
}

.parallel-action {
    padding: 8px;
    border-radius: 5px;
}

.parallel-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    align-items: center;
}

.parallel-group-select {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

/* Sequence Builder */
.sequence-builder {
    background: white;
    border-radius: 10px;
    padding: 15px;
}

.sequence-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.btn-add-step {
    background: #28a745;
    color: white;
    padding: 8px 15px;
}

.sequence-steps-list {
    max-height: 400px;
    overflow-y: auto;
}

.sequence-step-item {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
}

.sequence-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sequence-step-title {
    font-weight: bold;
    color: #1e3c72;
}

.btn-remove-step {
    background: #dc3545;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
}

.sequence-step-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.sequence-outputs {
    flex: 2;
}

.sequence-time {
    width: 150px;
}

.sequence-action {
    width: 120px;
}

/* Ações em paralelo com tempos diferentes */
.parallel-timers {
    margin-top: 10px;
    padding-left: 20px;
    border-left: 3px solid #1e3c72;
}

.output-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
    font-size: 14px;
}

/* Responsivo para steps */
@media (max-width: 768px) {
    .step-header, .step-row {
        grid-template-columns: 50px 90px 1fr 90px 70px;
        gap: 5px;
        font-size: 12px;
    }
    
    .step-controls {
        flex-direction: column;
    }
    
    .loop-checkbox {
        margin-left: 0;
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .outputs-grid {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .quick-buttons {
        flex-direction: column;
    }
    
    .quick-buttons button {
        width: 100%;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}