:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Animations */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    animation: float 20s infinite alternate;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: rgba(59, 130, 246, 0.2);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: rgba(16, 185, 129, 0.15);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: rgba(139, 92, 246, 0.2);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(50px, 50px) rotate(20deg); }
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 2rem;
}

.view {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.view.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

.view.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Login View */
#login-view {
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
}

.icon-lock {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

#login-form input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 4px;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#login-form input:focus {
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }

.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 20px;
}

/* Dashboard View */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.8);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 8px;
}

.status-badge .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fbbf24; /* yellow default */
}

.status-badge.connected .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-badge.disconnected .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.btn-secondary {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.card h3 {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    color: var(--primary);
}

/* Status Card */
.qr-container {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    color: #000;
}
.qr-container img {
    max-width: 100%;
    height: auto;
    margin-top: 1rem;
}

.connected-info {
    text-align: center;
    padding: 2rem 1rem;
}
.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.btn-danger {
    padding: 10px 16px;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.api-key-box {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.api-key-box code {
    color: var(--success);
    font-family: monospace;
    font-size: 1.1rem;
    letter-spacing: 2px;
}
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity 0.3s;
}
.btn-icon:hover { opacity: 1; }

/* Test Form */
.form-group { margin-bottom: 1.2rem; }
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.form-group input[type="text"], .form-group textarea {
    width: 100%;
    padding: 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    outline: none;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.checkbox-group input { width: auto; }
.checkbox-group label { margin-bottom: 0; cursor: pointer; }

.file-input {
    width: 100%;
    color: var(--text-muted);
}
.file-input::file-selector-button {
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: white;
    margin-right: 1rem;
    cursor: pointer;
}

/* Utils */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.w-100 { width: 100%; }
.text-sm { font-size: 0.8rem; color: var(--text-muted); }

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Generic Hidden Utility */
.hidden {
    display: none !important;
}

/* API Docs Styling */
.full-width-card {
    grid-column: 1 / -1;
}

.api-docs-container {
    margin-top: 1.5rem;
}

.api-endpoints-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    margin-bottom: 1.5rem;
}

.api-endpoint-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.api-endpoint-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.api-endpoint-btn.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.doc-section h4 {
    color: var(--text-main);
    font-size: 1.05rem;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: left;
}

.doc-table th, .doc-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.doc-table th {
    color: var(--text-muted);
    font-weight: 500;
    background: rgba(0, 0, 0, 0.2);
}

.doc-table td code {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 4px;
    color: #e2e8f0;
    font-family: monospace;
}

.doc-table td .doc-key-value {
    color: var(--success);
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.badge-get {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

/* Code Tabs */
.code-examples-section {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.code-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--glass-border);
}

.code-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.code-tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

.code-tab-btn.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 2px solid var(--primary);
}

.code-content {
    position: relative;
    padding: 1.5rem;
}

.code-block {
    display: none;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

.code-block.active {
    display: block;
}

.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* Main Dashboard Navigation Tabs */
.main-tabs {
    display: flex;
    gap: 15px;
    padding: 10px 1.5rem;
    margin-bottom: 2rem;
    border-radius: 12px;
}

.main-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.main-tab-btn.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.tab-content {
    transition: opacity 0.3s ease;
}

.tab-content.hidden {
    display: none !important;
}

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

/* AI Docs Card Styling */
.docs-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.docs-actions-btn-group {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.ai-docs-textarea-container {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
}

.ai-docs-box {
    width: 100%;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    height: 350px;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; gap: 1rem; text-align: center; }
    .docs-header-flex {
        flex-direction: column;
        align-items: flex-start;
    }
    .docs-actions-btn-group {
        width: 100%;
    }
    .docs-actions-btn-group button {
        flex: 1;
    }
}

/* Logs Table Styling */
.logs-table th {
    background: rgba(0, 0, 0, 0.4) !important;
}

.logs-table td {
    font-size: 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.badge-direction {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.badge-incoming {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge-outgoing {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.logs-container {
    overflow-x: auto;
    max-height: 550px;
    overflow-y: auto;
}
