:root {
    --primary: #00a884;
    --primary-dark: #008f6f;
    --bg-main: #f0f2f5;
    --bg-panel: #ffffff;
    --text-main: #111b21;
    --text-light: #667781;
    --border: #d1d7db;
    --msg-in: #ffffff;
    --msg-out: #d9fdd3;
    --danger: #ef4444;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --radius-lg: 12px;
    --radius-md: 8px;
}

body.dark-theme {
    --bg-main: #111b21;
    --bg-panel: #202c33;
    --text-main: #e9edef;
    --text-light: #8696a0;
    --border: #222d34;
    --msg-in: #202c33;
    --msg-out: #005c4b;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    padding: 24px 20px;
    background: var(--primary);
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-header p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-left: 36px;
}

.add-session {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.add-session input, .search-box input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    background: var(--bg-main);
    color: var(--text-main);
}

.add-session input:focus, .search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.1);
}

.btn-primary, .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.sessions-container {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-panel);
}

.sessions-list {
    list-style: none;
}

.sessions-list li {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.sessions-list li:hover {
    background: var(--bg-main);
}

.sessions-list li.active {
    background: var(--bg-main);
    border-left: 4px solid var(--primary);
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-info strong {
    font-size: 0.95rem;
    color: var(--text-main);
}

.session-status {
    font-size: 0.8rem;
    color: var(--text-light);
}

.session-status.ready { color: var(--primary); }

.btn-delete {
    background: #ffe3e3;
    color: var(--danger);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 0.8rem;
    font-weight: bold;
}

.btn-delete:hover {
    background: #ffc9c9;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.top-bar {
    height: 70px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-main);
    padding: 0 16px;
    border-radius: var(--radius-md);
    gap: 12px;
}

.search-box input {
    background: transparent;
    border: none;
    padding: 12px 0;
    box-shadow: none !important;
}

.search-box input:focus {
    border: none;
}

.search-box svg {
    color: var(--text-light);
}

.btn-secondary {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 24px;
}

.btn-secondary:hover {
    background: var(--bg-main);
}

/* Chat Area */
.chat-area {
    flex: 1;
    position: relative;
    background-size: 400px;
    background-repeat: repeat;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: var(--bg-panel);
    padding: 12px 24px;
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: transparent;
}

.messages-scroll-area {
    flex-shrink: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    font-size: 0.95rem;
    line-height: 1.4;
    animation: fadeIn 0.3s ease-out;
}

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

.message.in {
    align-self: flex-start;
    background-color: var(--msg-in);
    border-top-left-radius: 0;
}

.message.out {
    align-self: flex-end;
    background-color: var(--msg-out);
    border-top-right-radius: 0;
}

.message-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 4px;
}

.message-content {
    word-wrap: break-word;
    white-space: pre-wrap;
    color: var(--text-main);
}

.message-time {
    font-size: 0.65rem;
    color: var(--text-light);
    text-align: right;
    margin-top: 4px;
}

/* Modal QR */
.qr-modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(17, 27, 33, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

/* Auth / Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-panel);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    width: 350px;
    text-align: center;
}

.login-card h2 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

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

.form-group {
    margin-bottom: 1rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
}

.error-text {
    color: var(--danger) !important;
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* Dashboard */
.dashboard-view {
    padding: 1rem 2rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-cards {
    display: flex;
    gap: 1rem;
}

.stat-card {
    flex: 1;
    background: var(--bg-panel);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(11,20,26,0.05);
    border: 1px solid var(--border);
}

.stat-card h4 {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.stat-card p {
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 700;
}

.chart-container {
    background: var(--bg-panel);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(11,20,26,0.05);
    border: 1px solid var(--border);
    height: 200px;
}

/* Header Filters */
.filter-box {
    display: flex;
    gap: 0.5rem;
}

.filter-box input {
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    outline: none;
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.qr-card {
    background: var(--bg-panel);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.qr-card h3 {
    font-size: 1.4rem;
    color: var(--text-main);
    margin-bottom: 8px;
}

.qr-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.qr-wrapper {
    background: white;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: inline-block;
    margin-bottom: 24px;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
}

.btn-text:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 20%;
    font-size: 0.9rem;
}
