/* ==================== */
/* DARK THEME CHAT CSS  */
/* ==================== */

:root {
    /* Colors */
    --bg-dark-primary: #000000;
    /* Main background */
    --bg-dark-secondary: #000000;
    /* Sidebar background */
    --bg-dark-tertiary: #111827;
    /* Elements/Inputs */

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #5B6CFF;
    /* Tech Blue */
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #5B6CFF 100%);
    --accent-glow: rgba(91, 108, 255, 0.5);

    --success: #10b981;

    /* Spacing & Layout */
    --sidebar-width: 320px;
    --header-height: 60px;

    /* Borders */
    --border-color: #1e293b;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ==================== */
/* LAYOUT               */
/* ==================== */

.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-size: 1.25rem;
}

.text-green {
    color: #2F8F4E !important;
    font-weight: 600;
}

.text-ai-blue {
    color: #5B6CFF !important;
    font-weight: 700;
}

.text-white {
    color: #ffffff !important;
}

.logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Agent Profile in Sidebar */
.agent-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-primary);
}

.agent-avatar-large {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
}

.agent-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg-dark-tertiary);
    padding: 0.5rem;
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.online-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    background-color: var(--success);
    border: 2px solid var(--bg-dark-secondary);
    border-radius: 50%;
}

.agent-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

.agent-bio {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 240px;
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}

.action-btn:hover {
    background: var(--bg-dark-tertiary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Main Chat Content */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-dark-primary);
}

.mobile-header {
    display: none;
    padding: 1rem;
    background-color: var(--bg-dark-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--bg-dark-tertiary);
    border-radius: 20px;
}

.message-wrapper {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.message-wrapper.agent {
    align-self: flex-start;
}

.message-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    /* Slight rounded corner for better aesthetics, but essentially square */
    background: transparent;
}

.message {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    font-size: 1rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.agent {
    background-color: var(--bg-dark-tertiary);
    color: var(--text-primary);
    border-top-left-radius: 0.25rem;
}

.message.user {
    background: var(--accent-gradient);
    color: white;
    border-top-right-radius: 0.25rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Media Styling */
.media-container {
    margin-top: 0.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    max-width: 300px;
}

.media-container img,
.media-container video {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 0.5rem;
    object-fit: cover;
}

/* Input Area */
.chat-input-area {
    padding: 1.5rem 2rem;
    background-color: var(--bg-dark-primary);
    /* Blend with main bg */
    display: flex;
    gap: 1rem;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.chat-input-area input[type="text"] {
    flex: 1;
    background-color: var(--bg-dark-tertiary);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 100px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.chat-input-area input[type="text"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.chat-input-area button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-area button:hover {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

#send-btn {
    background: var(--accent-primary);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

#send-btn:hover {
    background: var(--accent-primary);
    transform: scale(1.05);
    color: white;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    /* Flex/None toggled by JS */
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-dark-secondary);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.login-body input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-dark-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 1.5rem;
    outline: none;
}

.login-body input:focus {
    border-color: var(--accent-primary);
}

.login-body button {
    width: 100%;
    padding: 1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-body button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.message.typing-msg {
    padding: 0.75rem 1rem;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.2s infinite ease-in-out both;
    opacity: 0.6;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        height: 100%;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-header {
        display: flex;
    }

    .message-wrapper {
        max-width: 90%;
    }

    .mobile-only {
        display: none !important;
    }

    .message.agent {
        border-top-left-radius: 1.25rem;
    }

    .chat-input-area {
        padding: 1rem;
    }
}