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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 15px;
    color: #667eea;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #f5f5f5;
    border-radius: 25px;
    font-weight: 500;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    animation: pulse 2s infinite;
}

.status-dot.initializing {
    background: #ffa500;
}

.status-dot.qr {
    background: #ffa500;
}

.status-dot.authenticated {
    background: #4CAF50;
}

.status-dot.ready {
    background: #4CAF50;
    animation: none;
}

.status-dot.error,
.status-dot.auth_failure {
    background: #f44336;
    animation: none;
}

.status-dot.disconnected {
    background: #f44336;
}

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

.card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.card h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.card p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    background: #f9f9f9;
    border-radius: 10px;
    margin: 20px 0;
    min-height: 300px;
}

#qrcode,
.qr-container img {
    max-width: 100%;
    height: auto;
}

.instructions {
    background: #e3f2fd;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.instructions ol {
    margin-left: 20px;
    color: #1976d2;
}

.instructions li {
    margin: 10px 0;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.result-message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.result-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.result-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

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

.message-item {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid #667eea;
}

.message-item .message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: #667eea;
}

.message-item .message-body {
    color: #333;
    line-height: 1.6;
    margin-bottom: 5px;
}

.message-item .message-time {
    font-size: 0.85em;
    color: #666;
}

.message-item .message-meta {
    font-size: 0.85em;
    color: #999;
    margin-top: 5px;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.dashboard-card h2 {
    color: #667eea;
    font-size: 1em;
    margin-bottom: 10px;
    font-weight: 500;
}

.dashboard-card .value {
    font-size: 2em;
    font-weight: 600;
    color: #667eea;
}

.dashboard-card.success .value {
    color: #4CAF50;
}

.dashboard-card.warn .value {
    color: #ffa500;
}

.dashboard-card.error .value {
    color: #f44336;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    color: #667eea;
    font-weight: 600;
}

.data-table tbody tr:hover {
    background: #f9f9f9;
}

/* Nav / Actions */
.nav-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.nav-actions a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

.nav-actions a:hover {
    text-decoration: underline;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

/* Scrollbar styling */
.messages-list::-webkit-scrollbar {
    width: 8px;
}

.messages-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.messages-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.hidden {
    display: none !important;
}

.api-test-block {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.api-test-block h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1em;
}

.api-result {
    margin-top: 15px;
    padding: 15px;
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 8px;
    font-size: 0.85em;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.api-result:empty {
    display: none;
}
