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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
}

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

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

header h1 {
    color: #4a9eff;
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    color: #888;
    font-size: 1.1em;
}

.user-identity {
    background: #333;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    text-align: center;
    font-weight: bold;
    color: #4a9eff;
}

.room-section {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #333;
}

.server-config {
    margin-bottom: 15px;
}

.server-config label {
    display: block;
    margin-bottom: 5px;
    color: #4a9eff;
    font-weight: bold;
    font-size: 14px;
}

.server-config input {
    width: 100%;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 5px;
    background: #333;
    color: #e0e0e0;
    font-size: 14px;
    font-family: monospace;
}

.server-config input:focus {
    outline: none;
    border-color: #4a9eff;
}

.room-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.room-controls input {
    flex: 1;
    padding: 12px;
    border: 1px solid #444;
    border-radius: 5px;
    background: #333;
    color: #e0e0e0;
    font-size: 16px;
}

.room-controls input:focus {
    outline: none;
    border-color: #4a9eff;
}

.room-controls button {
    padding: 12px 24px;
    background: #4a9eff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.room-controls button:hover {
    background: #3a8eef;
}

.status {
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

.status.disconnected {
    background: #ffebee;
    color: #c62828;
}

.status.connecting {
    background: #fff3e0;
    color: #ef6c00;
}

.status.connected {
    background: #e8f5e8;
    color: #2e7d32;
}

.chat-section {
    background: #2a2a2a;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #333;
}

.security-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #333;
    border-radius: 5px;
    margin-bottom: 20px;
}

.security-indicator {
    font-size: 1.2em;
}

.security-status.secure {
    background: #1b5e20;
    color: #4caf50;
}

.security-status.insecure {
    background: #d32f2f;
    color: #ffcdd2;
}

.security-status.key-exchange {
    background: #ff6f00;
    color: #ffe0b2;
}

.security-status.secure {
    background: #1b5e20;
    color: #4caf50;
    animation: pulse-secure 2s ease-in-out;
}

@keyframes pulse-secure {
    0% { background: #1b5e20; }
    50% { background: #2e7d32; }
    100% { background: #1b5e20; }
}

.chat-container {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 20px;
    height: 500px;
}

.messages {
    background: #333;
    border-radius: 5px;
    padding: 15px;
    overflow-y: auto;
}

.messages-controls {
    display: flex;
    justify-content: flex-end;
    padding: 10px 0;
    border-bottom: 1px solid #444;
    margin-bottom: 15px;
}

.receive-area h3 {
    color: #4a9eff;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.toggle-all-btn {
    background: #666;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s;
    font-weight: bold;
}

.toggle-all-btn:hover {
    background: #777;
}

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

.message-sender {
    font-weight: bold;
    color: #4a9eff;
    font-size: 0.9em;
}

.lock-icon {
    font-size: 14px;
    user-select: none;
}

.message {
    background: #444;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    border-left: 3px solid #4a9eff;
}

.message.delivered {
    border-left-color: #4caf50;
}

.message.system-message {
    background: #2a2a2a;
    border-left-color: #888;
    font-style: italic;
    opacity: 0.8;
}

.message-content {
    word-wrap: break-word;
}

.message-time {
    font-size: 0.8em;
    color: #888;
    margin-top: 5px;
}

.send-area {
    background: #333;
    padding: 15px;
    border-radius: 5px;
}

.send-area h3 {
    color: #4a9eff;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.send-area textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 5px;
    background: #444;
    color: #e0e0e0;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
}

.send-area textarea:focus {
    outline: none;
    border-color: #4a9eff;
}

.send-area button {
    margin-top: 10px;
    padding: 10px 20px;
    background: #4a9eff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.send-area button:hover:not(:disabled) {
    background: #3a8eef;
}

.send-area button:disabled {
    background: #666;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    .room-controls {
        flex-direction: column;
    }
    
    .chat-container {
        height: 400px;
    }
    
    header h1 {
        font-size: 2em;
    }
}

/* MITM Protection Authentication Styles */
.authentication-section {
    background: #2a2a2a;
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
    border: 2px solid #4a9eff;
}

.auth-card {
    padding: 20px;
}

.alice-card {
    background: linear-gradient(135deg, #2a4a2a, #2a2a2a);
    border-left: 4px solid #4CAF50;
}

.bob-card {
    background: linear-gradient(135deg, #2a3a4a, #2a2a2a);
    border-left: 4px solid #2196F3;
}

.auth-card h3 {
    color: #4a9eff;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.auth-card p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.authcode-display {
    background: #1a1a1a;
    border: 2px solid #4a9eff;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.authcode-display code {
    flex: 1;
    font-size: 1.4em;
    font-weight: bold;
    color: #4CAF50;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

.copy-btn {
    background: #4a9eff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.copy-btn:hover {
    background: #357abd;
}

.authcode-input {
    margin: 15px 0;
}

.authcode-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #e0e0e0;
}

.authcode-input input {
    width: 100%;
    padding: 12px;
    background: #1a1a1a;
    border: 2px solid #555;
    border-radius: 5px;
    color: #e0e0e0;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.authcode-input input:focus {
    outline: none;
    border-color: #4a9eff;
}

.verify-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.2s;
}

.verify-btn:hover {
    background: #45a049;
}

.verification-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.reject-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.2s;
}

.reject-btn:hover {
    background: #d32f2f;
}


.auth-instructions {
    background: rgba(74, 158, 255, 0.1);
    border-left: 4px solid #4a9eff;
    padding: 15px;
    margin: 15px 0;
    border-radius: 0 5px 5px 0;
}

.auth-instructions p {
    margin-bottom: 10px;
}

.auth-instructions ol {
    margin-left: 20px;
}

.auth-instructions li {
    margin-bottom: 8px;
}

.auth-instructions code {
    background: #1a1a1a;
    padding: 2px 6px;
    border-radius: 3px;
    color: #4CAF50;
    font-weight: bold;
}

.auth-feedback {
    margin: 15px 0;
    padding: 12px;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
}

.auth-feedback.success {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4CAF50;
    color: #4CAF50;
}

.auth-feedback.error {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
    color: #f44336;
}

.auth-feedback.info {
    background: rgba(74, 158, 255, 0.2);
    border: 1px solid #4a9eff;
    color: #4a9eff;
}

/* Security status updates for authentication states */
.security-status.authenticated {
    background: linear-gradient(90deg, #2a4a2a, #1a3a1a);
    border-color: #4CAF50;
}

.security-status.unverified {
    background: linear-gradient(90deg, #4a3a2a, #3a2a1a);
    border-color: #ff9800;
}

.security-status.key-exchange {
    background: linear-gradient(90deg, #2a3a4a, #1a2a3a);
    border-color: #2196F3;
}

/* Loading spinner for authentication */
.auth-loading {
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #333;
    border-top: 3px solid #4a9eff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.auth-loading p {
    margin: 10px 0;
    color: #e0e0e0;
}

.auth-loading small {
    color: #888;
}