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

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

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

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

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

.controls {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.controls select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.controls button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.controls button:hover {
    background: #5a6fd8;
}

.diagram-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.message-flow {
    display: grid;
    grid-template-columns: 150px 200px 200px 300px 150px;
    grid-template-rows: auto;
    gap: 20px;
    align-items: center;
    min-width: 1000px;
    position: relative;
}

.producer, .consumer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    transition: all 0.3s;
}

.producer .icon, .consumer .icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.producer.active, .consumer.active {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: scale(1.05);
}

.message-path {
    position: relative;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.message {
    background: #ff9800;
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-weight: bold;
    position: relative;
    transform: translateX(-100px);
    opacity: 0;
    transition: all 0.8s ease-in-out;
    cursor: pointer;
    margin: 5px 0;
}

.message.moving {
    transform: translateX(0);
    opacity: 1;
}

.message.delivered {
    transform: translateX(520px);
    opacity: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.message-content strong {
    font-size: 12px;
    margin-bottom: 2px;
}

.message-content small {
    font-size: 9px;
    opacity: 0.8;
    font-weight: normal;
}

.exchange {
    background: #4caf50;
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    position: relative;
    transition: all 0.3s;
}

.exchange.processing {
    animation: pulse 1s infinite;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.exchange-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.exchange-label {
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 5px;
}

.exchange-rules {
    font-size: 0.9em;
    opacity: 0.9;
}

.queues-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.queue {
    background: #2196f3;
    color: white;
    padding: 15px;
    border-radius: 10px;
    position: relative;
    transition: all 0.3s;
    min-height: 80px;
}

.queue.receiving {
    animation: flash 0.5s;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.7);
}

@keyframes flash {
    0%, 100% { background: #2196f3; }
    50% { background: #64b5f6; }
}

.queue-icon {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.queue-label {
    font-weight: bold;
    margin-bottom: 3px;
}

.queue-binding {
    font-size: 0.8em;
    opacity: 0.8;
    margin-bottom: 5px;
}

.message-count {
    position: absolute;
    top: 5px;
    right: 10px;
    background: rgba(0,0,0,0.3);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
}

.consumers-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.concept-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.concept-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.exchange-details h4 {
    color: #333;
    margin-bottom: 10px;
}

.exchange-details ul {
    margin-left: 20px;
    margin-top: 10px;
}

.exchange-details li {
    margin-bottom: 5px;
}

.components-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.examples-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.example {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #ff9800;
}

.example strong {
    color: #ff9800;
    font-size: 0.9em;
    display: block;
    margin-bottom: 4px;
}

.example p {
    font-size: 0.85em;
    margin-bottom: 4px;
    color: #333;
}

.example small {
    font-size: 0.75em;
    color: #666;
    font-style: italic;
}

.component {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.component strong {
    color: #667eea;
}

.status-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.status-panel h3 {
    color: #667eea;
    margin-bottom: 15px;
}

#statusLog {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.9em;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .message-flow {
        grid-template-columns: 120px 180px 180px 250px 120px;
        gap: 15px;
        min-width: 870px;
    }
}

@media (max-width: 768px) {
    .concepts-section {
        grid-template-columns: 1fr;
    }

    .components-grid {
        grid-template-columns: 1fr;
    }

    .message-flow {
        transform: scale(0.8);
        transform-origin: left top;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Animation for routing paths */
.routing-path {
    position: absolute;
    width: 2px;
    background: #ff9800;
    opacity: 0;
    transform-origin: left;
    transition: all 0.5s;
}

.routing-path.active {
    opacity: 1;
    animation: drawLine 1s ease-in-out;
}

@keyframes drawLine {
    0% { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

/* Exchange type specific styles */
.fanout-exchange {
    background: #e91e63 !important;
}

.topic-exchange {
    background: #9c27b0 !important;
}

.headers-exchange {
    background: #ff5722 !important;
}

.direct-exchange {
    background: #4caf50 !important;
}