:root {
    --bg-color:        #0d1117;
    --glass-bg:        rgba(22, 27, 34, 0.7);
    --glass-border:    rgba(255, 255, 255, 0.08);
    --card-bg:         rgba(255, 255, 255, 0.03);
    --primary-gradient:linear-gradient(135deg, #25D366, #128C7E);
    --sidebar-bg:      rgba(13, 17, 23, 0.8);
    --text-main:       #f0f6fc;
    --text-muted:      #8b949e;
    --input-bg:        rgba(1, 4, 9, 0.5);
    --success:         #25D366;
    --warning:         #f0a500;
    --danger:          #f85149;
    --blue:            #58a6ff;
    --grad:            linear-gradient(135deg, #25D366, #128C7E);
}

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

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 10% 50%, rgba(37,211,102,0.05), transparent 35%),
        radial-gradient(circle at 90% 20%, rgba(18,140,126,0.05), transparent 35%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

/* ── Layout ─────────────────────────────────────────────────── */
.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    width: 100%;
    max-width: 1400px;
    min-height: 850px;
    max-height: 95vh;
    display: flex;
    overflow: hidden;
    box-shadow: 0 12px 60px rgba(0,0,0,0.5);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    overflow-y: auto;
    flex: 1;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
}

.device-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-item:hover { background: rgba(255,255,255,0.06); }
.device-item.active {
    background: rgba(37,211,102,0.1);
    border-color: var(--success);
}

.device-item .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted);
}
.device-item.online .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.device-item.warning .dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); }

.nav-item {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px;
    text-align: left;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item.active, .nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.device-item .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted);
}
.device-item.online .dot { background: var(--success); box-shadow: 0 0 10px var(--success); }
.device-item.warning .dot { background: var(--warning); box-shadow: 0 0 10px var(--warning); }

.device-info { display: flex; flex-direction: column; }
.device-info .name { font-size: 0.95rem; font-weight: 600; color: #fff; }
.device-info .status { font-size: 0.75rem; color: var(--text-muted); }

.add-device-btn {
    width: 100%;
    background: rgba(37,211,102,0.1);
    border: 1px dashed rgba(37,211,102,0.4);
    color: var(--success);
    border-radius: 14px;
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.add-device-btn:hover { background: rgba(37,211,102,0.15); border-style: solid; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.logout-btn {
    width: 100%;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: #f85149;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 1rem;
}
.logout-btn:hover { background: rgba(248, 81, 73, 0.15); }

.legal-links {
    display: flex;
    gap: 10px;
    justify-content: center;
    font-size: 0.7rem;
    opacity: 0.6;
}
.legal-links a { color: #fff; text-decoration: none; }
.legal-links a:hover { text-decoration: underline; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: rgba(22, 27, 34, 0.4);
}

.main-header {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}
.main-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.main-header p { font-size: 0.9rem; color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 15px; }

/* ── Content States ────────────────────────────────────────── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
}
.empty-icon { font-size: 4rem; margin-bottom: 1.5rem; opacity: 0.5; }
.empty-state h2 { font-size: 1.5rem; margin-bottom: 0.8rem; }
.empty-state p { color: var(--text-muted); max-width: 400px; }

.input-section { padding: 2rem; display: flex; flex-direction: column; gap: 2rem; }

/* ── QR Section ────────────────────────────────────────────── */
.qr-section {
    padding: 3rem 2rem;
    text-align: center;
}
.qr-container {
    background: #fff;
    padding: 1.5rem;
    border-radius: 20px;
    display: inline-block;
    margin: 1.5rem 0;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#qrImage { width: 220px; height: 220px; display: block; }
.helper-text { font-size: 0.85rem; color: var(--text-muted); margin-top: 10px; }

/* ── Cards & Elements ─────────────────────────────────────── */
.section-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
}
.section-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; gap: 10px; }

.input-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1rem; }
.input-group label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }

input[type="text"], textarea {
    width: 100%; background: var(--input-bg); border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 10px 14px; color: #fff; font-size: 0.95rem;
}
input:focus, textarea:focus { outline: none; border-color: var(--success); box-shadow: 0 0 10px rgba(37,211,102,0.2); }

.copy-wrapper { display: flex; gap: 8px; width: 100%; }
.copy-wrapper input { flex: 1; font-family: monospace; font-size: 0.85rem; color: #a5f3fc; padding: 10px; background: rgba(0,0,0,0.3); }

.primary-btn {
    background: var(--primary-gradient); color: #fff; border: none; border-radius: 12px;
    padding: 12px 20px; font-weight: 600; cursor: pointer; transition: 0.2s;
}
.primary-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.copy-btn, .small-btn {
    background: rgba(37,211,102,0.1); border: 1px solid rgba(37,211,102,0.3);
    color: var(--success); border-radius: 10px; padding: 8px 14px; font-size: 0.85rem; cursor: pointer;
}
.danger-btn {
    background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.3);
    color: var(--danger); border-radius: 10px; padding: 8px 14px; font-size: 0.85rem; cursor: pointer;
}

.status-badge {
    padding: 4px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 700;
}
.status-badge.AUTHENTICATED { background: rgba(37,211,102,0.15); color: var(--success); }
.status-badge.WAITING_FOR_SCAN { background: rgba(240,165,0,0.15); color: var(--warning); }
.status-badge.INITIALIZING { background: rgba(88,166,255,0.15); color: var(--blue); }
.status-badge.OFFLINE { background: rgba(255,255,255,0.1); color: var(--text-muted); }

/* ── Message Log ─────────────────────────────────────────── */
.message-log {
    max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.log-entry {
    background: rgba(255,255,255,0.02); border: 1px solid var(--glass-border);
    padding: 10px 14px; border-radius: 12px;
}
.log-entry .log-sender { font-size: 0.8rem; font-weight: 600; color: var(--success); }
.log-entry .log-body { font-size: 0.9rem; margin-top: 4px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    padding: 2.5rem; border-radius: 24px; width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-content h3 { margin-bottom: 1.5rem; font-size: 1.3rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 1.5rem; }

/* ── API Reference & Code Snippets ───────────────────────── */
.api-ref-block { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.api-method { font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 6px; }
.api-method.post { background: rgba(37,211,102,0.15); color: var(--success); }

.code-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: 0.2s;
}

.tab-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.tab-btn.active {
    color: var(--success);
    background: rgba(37,211,102,0.1);
}

.code-snippet-container {
    position: relative;
    background: #0d1117;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--glass-border);
}

.code-snippet-container pre {
    margin: 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e6edf3;
}

.code-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: 0.2s;
}

.code-copy-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

#toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
    background: #000; border: 1px solid var(--success); color: var(--success);
    padding: 12px 24px; border-radius: 30px; font-weight: 600; transition: 0.3s; z-index: 1000;
}
#toast.show { transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

@media (max-width: 900px) {
    .glass-container { flex-direction: column; height: auto; border-radius: 0; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--glass-border); }
    .sidebar-nav { max-height: 200px; }
}

/* Status Badges */
.status-badge.AUTHENTICATED { background: rgba(37, 211, 102, 0.1); color: var(--success); border: 1px solid rgba(37, 211, 102, 0.3); }
.status-badge.RECONNECTING { background: rgba(255, 165, 0, 0.1); color: #ffa500; border: 1px solid rgba(255, 165, 0, 0.3); animation: pulse 1.5s infinite; }
.status-badge.WAITING_FOR_SCAN { background: rgba(255, 193, 7, 0.1); color: #ffc107; border: 1px solid rgba(255, 193, 7, 0.3); }
.status-badge.FAILED, .status-badge.DISCONNECTED { background: rgba(255, 60, 60, 0.1); color: #ff3c3c; border: 1px solid rgba(255, 60, 60, 0.3); }

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

.device-item.online .dot { background: var(--success); box-shadow: 0 0 10px var(--success); }
.device-item.reconnecting .dot { background: #ffa500; animation: pulse 1.5s infinite; }
.device-item.warning .dot { background: #ffc107; }

.device-list::-webkit-scrollbar { width: 4px; }
.device-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
