:root {
    --bg-color: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* Typography */
h1, h2 { font-weight: 800; letter-spacing: -0.5px; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* Glassmorphism */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-overlay {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Login Screen */
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: 20px;
    text-align: center;
    transform: translateY(0);
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
}
.brand h1 { font-size: 1.5rem; }
.brand-icon { color: var(--primary); width: 32px; height: 32px; }

.login-box p { color: var(--text-muted); margin-bottom: 2rem; }

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-primary.glow {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 2rem;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.sidebar .brand { justify-content: flex-start; margin-bottom: 3rem; }

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar nav a:hover, .sidebar nav a.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.sidebar nav a.logout {
    margin-top: auto;
    color: var(--danger);
}
.sidebar nav a.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    padding: 3rem 4rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.filter-btn:hover { background: rgba(255, 255, 255, 0.1); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.select-input {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    outline: none;
}

.pagination-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 3rem;
    flex-wrap: wrap;
}

.page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.page-btn:hover { background: rgba(255, 255, 255, 0.1); }
.page-btn.active { background: var(--primary); border-color: var(--primary); }

.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Instance Card */
.instance-card {
    padding: 1.5rem;
    border-radius: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.instance-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.instance-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.instance-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.instance-info > .info-container {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.instance-info h3 {
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
}

.instance-info h3 span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitle-wrapper {
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    margin-top: 2px;
}

.subtitle-wrapper p {
    margin-top: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
    margin-left: 6px;
    flex-shrink: 0;
}

.copy-btn:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

/* Config UI Toggles */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.config-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    padding: 1.2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s;
}

.config-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.toggle-info h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--text-main);
    word-break: break-word;
}
.toggle-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-bottom: 1rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--success);
  border-color: var(--success);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #334155;
    object-fit: cover;
    border: 2px solid var(--glass-border);
    flex-shrink: 0;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-left: 10px;
}

.status-open { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-connecting { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.status-close { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.instance-actions {
    display: flex;
    gap: 8px;
    margin-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
}

.btn-icon {
    flex: 1;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}
.btn-icon.connect { color: var(--success); border-color: rgba(16, 185, 129, 0.3); }
.btn-icon.connect:hover { background: rgba(16, 185, 129, 0.1); }
.btn-icon.config { color: var(--primary); }
.btn-icon.config:hover { background: rgba(59, 130, 246, 0.1); }
.btn-icon.delete { color: var(--danger); }
.btn-icon.delete:hover { background: rgba(239, 68, 68, 0.1); }

/* QR Modal */
.modal-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: 20px;
    text-align: center;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover { color: white; }

.qr-container {
    width: 250px;
    height: 250px;
    background: white;
    border-radius: 10px;
    margin: 2rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-container img {
    width: 100%;
    height: 100%;
}

.qr-instruction {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 4rem;
}
