/* Minimalistic Whitespace Design for MQTT Encryption/Decryption Tool */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #ffffff;
    color: #1f2937;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

.container {
    width: 100%;
    max-width: 50rem;
    background-color: #ffffff;
    padding: 3rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

h1 {
    font-size: 1.875rem;
    font-weight: 300;
    color: #111827;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: -0.025em;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background-color: #f3f4f6;
    border-radius: 0.5rem;
    padding: 0.25rem;
    margin-bottom: 2rem;
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background-color: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-align: center;
}

.mode-btn.active {
    background-color: #ffffff;
    color: #1f2937;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.mode-btn:hover:not(.active) {
    color: #374151;
}

/* Forms */
.operation-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.operation-form.hidden {
    display: none;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    letter-spacing: 0.025em;
}

input,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: #1f2937;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    font-family: inherit;
    resize: vertical;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

textarea {
    min-height: 4rem;
}

/* Topic Selector Section */
.topic-selector-section {
    margin-top: 1rem;
    padding: 1.5rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
}

.topic-selector-section label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 1rem;
}

.topic-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.topic-btn,
.send-topic-btn {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #475569;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-align: center;
    white-space: nowrap;
}

.topic-btn:hover,
.send-topic-btn:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
    color: #334155;
}

.topic-btn.active {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 1px 3px 0 rgba(59, 130, 246, 0.3);
}

.send-topic-btn.active {
    background-color: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
    box-shadow: 0 1px 3px 0 rgba(22, 163, 74, 0.3);
}

.topic-btn:focus,
.send-topic-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Generated Topic Section */
.generated-topic {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
}

.generated-topic label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.5rem;
}

.topic-display {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.topic-display input {
    flex: 1;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    background-color: #ffffff;
    border-color: #3b82f6;
    color: #1e40af;
    font-weight: 500;
}

/* Connection Status Display */
.connection-status-display {
    margin: 1rem 0;
    padding: 1rem;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
}

.status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-text {
    font-weight: 500;
    font-size: 0.875rem;
}

.status-text.connecting {
    color: #f59e0b;
}

.status-text.connected {
    color: #16a34a;
}

.status-text.disconnected {
    color: #ef4444;
}

.status-text.failed {
    color: #dc2626;
}

.retry-count {
    font-size: 0.75rem;
    color: #6b7280;
    font-style: italic;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    font-family: inherit;
    letter-spacing: 0.025em;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: #3b82f6;
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2563eb;
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.btn-primary:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #e5e7eb;
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.3);
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-danger:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.btn-success {
    background-color: #10b981;
    color: #ffffff;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
}

.btn-success:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

/* Loading state */
.btn-loading,
.btn-sending {
    position: relative;
    color: transparent !important;
}

.btn-loading::after,
.btn-sending::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Button group */
.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Output area */
#output {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 4rem;
    display: flex;
    align-items: center;
    transition: all 0.15s ease-in-out;
}

#output:empty {
    display: none;
}

#output.success {
    background-color: #f0fdf4;
    border-color: #16a34a;
    color: #166534;
}

#output.error {
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

#output.processing {
    background-color: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}

/* Decrypt Mode Toggle */
.decrypt-mode-toggle {
    display: flex;
    background-color: #f9fafb;
    border-radius: 0.375rem;
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e5e7eb;
}

.decrypt-mode-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    background-color: transparent;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-align: center;
}

.decrypt-mode-btn.active {
    background-color: #ffffff;
    color: #1f2937;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.decrypt-mode-btn:hover:not(.active) {
    color: #374151;
}

/* Extracted Fields Display */
.extracted-fields {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.375rem;
}

.extracted-field {
    margin-bottom: 0.75rem;
}

.extracted-field:last-child {
    margin-bottom: 0;
}

.extracted-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #166534;
    margin-bottom: 0.25rem;
}

.extracted-value {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    color: #15803d;
    word-break: break-all;
    background-color: #ffffff;
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #bbf7d0;
}

/* Decrypt Output Section */
.decrypt-output {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f0fdf4;
    border: 1px solid #16a34a;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

.decrypt-output.hidden {
    display: none;
}

.decrypt-output .output-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #166534;
    margin-bottom: 0.5rem;
}

.decrypt-output .output-field textarea {
    flex: 1;
    min-height: 4rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    background-color: #ffffff;
    border-color: #16a34a;
    color: #166534;
    resize: vertical;
    white-space: pre-wrap;
}

.encrypt-output {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f0fdf4;
    border: 1px solid #16a34a;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

.encrypt-output.hidden {
    display: none;
}

.output-group {
    margin-bottom: 1.5rem;
}

.output-group:last-child {
    margin-bottom: 0;
}

.output-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #166534;
    margin-bottom: 0.5rem;
}

.output-field {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.output-field textarea {
    flex: 1;
    min-height: 3rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    background-color: #ffffff;
    border-color: #16a34a;
    color: #166534;
    resize: vertical;
}

.copy-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #16a34a;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
    height: fit-content;
}

.copy-btn:hover {
    background-color: #15803d;
}

.copy-btn.copied {
    background-color: #059669;
}

/* Fill button styles */
.fill-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
    height: fit-content;
}

.fill-btn:hover {
    background-color: #2563eb;
}

.fill-btn.filled {
    background-color: #16a34a;
}

/* MQTT Monitor Styles */
.mqtt-config {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mqtt-monitor {
    margin-top: 2rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background-color: #ffffff;
    overflow: hidden;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-disconnected {
    color: #ef4444;
    font-weight: 500;
    font-size: 0.875rem;
}

.status-connected {
    color: #16a34a;
    font-weight: 500;
    font-size: 0.875rem;
}

.status-connecting {
    color: #f59e0b;
    font-weight: 500;
    font-size: 0.875rem;
}

.message-count {
    font-size: 0.75rem;
    color: #6b7280;
}

.view-toggle {
    display: flex;
    background-color: #ffffff;
    border-radius: 0.375rem;
    padding: 0.25rem;
    border: 1px solid #d1d5db;
}

.view-btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    background-color: transparent;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.view-btn.active {
    background-color: #3b82f6;
    color: #ffffff;
}

.view-btn:hover:not(.active) {
    color: #374151;
}

.monitor-controls {
    padding: 1rem 1.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
}

.message-list {
    max-height: 25rem;
    overflow-y: auto;
    background-color: #ffffff;
}

.no-messages {
    padding: 3rem;
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

.message-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease-in-out;
}

.message-item:hover {
    background-color: #f9fafb;
}

.message-item:last-child {
    border-bottom: none;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-topic {
    font-weight: 500;
    color: #1f2937;
    font-size: 0.875rem;
}

.message-time {
    font-size: 0.75rem;
    color: #6b7280;
}

.message-payload {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    color: #374151;
    background-color: #f9fafb;
    padding: 0.75rem;
    border-radius: 0.25rem;
    word-break: break-all;
    white-space: pre-wrap;
    max-height: 6rem;
    overflow-y: auto;
}

.message-payload.encrypted {
    color: #b45309;
    background-color: #fef3c7;
}

.message-payload.decrypted {
    color: #166534;
    background-color: #f0fdf4;
}

.message-payload.error {
    color: #dc2626;
    background-color: #fef2f2;
}

.message-status {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
    text-transform: uppercase;
}

.message-status.encrypted {
    background-color: #fbbf24;
    color: #92400e;
}

.message-status.decrypted {
    background-color: #34d399;
    color: #065f46;
}

.message-status.error {
    background-color: #f87171;
    color: #7f1d1d;
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
}

.status-success .status-dot {
    background-color: #16a34a;
}

.status-error .status-dot {
    background-color: #ef4444;
}

.status-processing .status-dot {
    background-color: #3b82f6;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* MQTT Send Message Styles */
.mqtt-send-section {
    margin-top: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background-color: #ffffff;
    overflow: hidden;
}

.send-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.send-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.mqtt-send-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message-type-toggle {
    display: flex;
    background-color: #f3f4f6;
    border-radius: 0.375rem;
    padding: 0.25rem;
}

.message-type-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background-color: transparent;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-align: center;
}

.message-type-btn.active {
    background-color: #ffffff;
    color: #1f2937;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.message-type-btn:hover:not(.active) {
    color: #374151;
}

.json-message-builder {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.builder-header label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.json-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.json-field {
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.75rem;
}

.field-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.field-key,
.field-value {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background-color: #ffffff;
}

.field-key:focus,
.field-value:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.remove-field {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.15s ease-in-out;
}

.remove-field:hover {
    background-color: #dc2626;
}

.remove-field:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.json-preview {
    margin-top: 1rem;
}

.json-preview label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.json-preview textarea {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #1f2937;
    resize: vertical;
}

.raw-message-input {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
}

.send-controls {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.send-controls .btn-group {
    justify-content: flex-start;
    gap: 0.75rem;
}

/* Animation for field addition */
.json-field.new-field {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Success/Error feedback */
.send-feedback {
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.send-feedback.success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.send-feedback.error {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Subscribed Topic Display */
.subscribed-topic-display {
    padding: 0.75rem 1.5rem;
    background-color: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
    border-top: 1px solid #bbf7d0;
}

.subscribed-topic-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topic-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #166534;
}

.topic-value {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    color: #15803d;
    background-color: #ffffff;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #bbf7d0;
    word-break: break-all;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Scrollbar styling for message list */
.message-list::-webkit-scrollbar {
    width: 0.5rem;
}

.message-list::-webkit-scrollbar-track {
    background-color: #f3f4f6;
}

.message-list::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 0.25rem;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .container {
        padding: 2rem 1.5rem;
        max-width: 100%;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .output-field {
        flex-direction: column;
    }

    .copy-btn {
        align-self: flex-end;
        width: fit-content;
    }

    .monitor-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .connection-status {
        justify-content: center;
    }

    .monitor-controls {
        flex-wrap: wrap;
    }

    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .topic-display {
        flex-direction: column;
        gap: 0.5rem;
    }

    .copy-btn {
        align-self: flex-start;
    }

    .topic-selector {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .topic-btn,
    .send-topic-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.6875rem;
    }

    .send-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .field-inputs {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .remove-field {
        justify-self: flex-end;
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.875rem;
    }

    .send-controls .btn-group {
        flex-direction: column;
    }

    .builder-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .subscribed-topic-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .topic-value {
        width: 100%;
        word-break: break-all;
    }
}

@media (max-width: 640px) {
    .mode-toggle {
        flex-direction: column;
    }

    .view-toggle {
        width: 100%;
    }

    .topic-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .message-type-toggle {
        flex-direction: column;
    }

    .mqtt-send-form {
        padding: 1rem;
    }
}

/* Focus states for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        border-color: #000000;
    }

    input,
    textarea {
        border-color: #000000;
    }

    input:focus,
    textarea:focus {
        border-color: #0000ff;
    }

    .mode-btn.active {
        border: 2px solid #000000;
    }

    .message-item {
        border-color: #000000;
    }

    .topic-btn {
        border-color: #000000;
    }

    .topic-btn.active {
        background-color: #000000;
        border-color: #000000;
    }
}