:root {
    --primary: #8a2be2;
    --primary-light: #a64dff;
    --bg-dark: #0f111a;
    --bg-tile: #1a1d2e;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #e0e0e0;
    --text-muted: #94a3b8;
    --danger: #ff4d4d;
    --success: #00ff88;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

/* Glassmorphism utility */
.glass {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

/* Screens */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
}

/* Login Screen */
#login-screen {
    background: radial-gradient(circle at center, #1a1d2e 0%, #0f111a 100%);
    justify-content: center;
    align-items: center;
}

.login-card {
    width: 400px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-header .logo-icon {
    font-size: 40px;
    color: var(--primary);
    margin-bottom: 20px;
}

.login-header h1 span {
    color: var(--primary);
    font-weight: 300;
}

.login-header p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 15px 15px 15px 45px;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    border: none;
    padding: 15px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
}

.error-text {
    color: var(--danger);
    margin-top: 15px;
    font-size: 14px;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 20px;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

#logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    transition: color 0.3s;
}

#logout-btn:hover {
    color: var(--danger);
}

.search-bar {
    position: relative;
    margin-bottom: 15px;
}

.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 10px 10px 10px 35px;
    border-radius: 10px;
    color: white;
}

.session-list-container {
    flex: 1;
    overflow-y: auto;
}

.session-list-container h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

#session-list {
    list-style: none;
}

.session-item {
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text-muted);
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.session-item.active {
    background: rgba(138, 43, 226, 0.15);
    border-color: rgba(138, 43, 226, 0.3);
    color: white;
}

/* Grouping Styles (v69) */
.tenant-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 8px;
    margin: 15px 0 8px 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
}

.session-info-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.client-name {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.client-phone {
    font-size: 11px;
    color: var(--text-muted);
}

.id-short {
    font-family: monospace;
    font-size: 10px;
    opacity: 0.4;
    margin-top: 2px;
}

.empty-list {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.top-nav {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-nav h2 {
    font-size: 20px;
    margin-bottom: 5px;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-muted);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
}

/* Workspace Grid */
.workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    padding: 30px;
    overflow-y: auto;
    gap: 20px;
}

.empty-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
}

.empty-workspace i {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.2;
}

/* Chat Messages */
.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 18px;
    margin-bottom: 10px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.human {
    align-self: flex-end;
    background: var(--primary);
    border-bottom-right-radius: 4px;
}

.message.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.message .sender {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 5px;
    opacity: 0.6;
}

.tool-event {
    align-self: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px dashed var(--glass-border);
    font-family: monospace;
    font-size: 12px;
    color: #61dafb;
    max-width: 90%;
}

.tool-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

/* Details Panel */
.details-panel {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.panel-header {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.metadata-grid {
    flex: 1;
    overflow-y: auto;
}

.metadata-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.metadata-card h4 {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.metadata-card .value {
    word-break: break-all;
    font-size: 14px;
}

.danger-zone {
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
    margin-top: 20px;
}

.danger-zone h3 {
    font-size: 14px;
    color: var(--danger);
    margin-bottom: 15px;
}

.btn-danger {
    width: 100%;
    background: rgba(255, 77, 77, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* Buttons */
.btn-icon {
    background: none;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-icon:hover {
    color: white;
    border-color: var(--primary);
    background: rgba(138, 43, 226, 0.1);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

.toast {
    padding: 15px 25px;
    border-radius: 12px;
    background: var(--bg-tile);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.error { border-left: 5px solid var(--danger); }
.toast.success { border-left: 5px solid var(--success); }

/* 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); }