/* Core CSS Design System */
:root {
    --bg-dark: #0f111a;
    --bg-sidebar: #161925;
    --bg-card: rgba(255, 255, 255, 0.03);
    --border-light: rgba(255, 255, 255, 0.08);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --accent: #f59e0b;
    --green: #10b981;
    --red: #ef4444;
    --font-outfit: 'Outfit', sans-serif;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

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

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.gold-gradient-text {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.5rem;
}

.badge {
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--primary-light);
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    margin-left: 0.5rem;
    vertical-align: middle;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.quick-prompts {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.prompt-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.prompt-btn i {
    color: var(--primary-light);
    font-size: 1rem;
}

.prompt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.clear-chat-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.clear-chat-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--red);
}

/* Chat Area Styling */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.chat-header {
    height: 70px;
    border-bottom: 1px solid var(--border-light);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 17, 26, 0.8);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.agent-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.agent-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    position: relative;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.active-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background-color: var(--green);
    border: 2px solid var(--bg-dark);
    border-radius: 50%;
}

.agent-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.agent-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.icon-btn:hover {
    color: var(--text-main);
}

/* Messages Window */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Welcome Card */
.welcome-card {
    max-width: 600px;
    margin: 3rem auto;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(10px);
}

.welcome-icon {
    width: 70px;
    height: 70px;
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1.5rem auto;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.welcome-card h2 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.welcome-card p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.feature-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-light);
    padding: 1rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    text-align: center;
    font-weight: 500;
}

.feature-item i {
    font-size: 1.5rem;
}

.text-green { color: var(--green); }
.text-purple { color: var(--primary-light); }
.text-orange { color: var(--accent); }

/* Chat Bubbles */
.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message-row.user .message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-row.assistant .message-bubble {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.typing-bubble {
    display: flex;
    gap: 5px;
    padding: 0.75rem 1.25rem;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Markdown Rendering Custom Styles inside Chat */
.message-bubble p {
    margin-bottom: 0.5rem;
}
.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble ul, .message-bubble ol {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Elegant Table Design for CRM data */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.message-bubble th, .message-bubble td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble th {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary-light);
    font-weight: 600;
    border-bottom: 1px solid rgba(139, 92, 246, 0.3);
}

.message-bubble tr:last-child td {
    border-bottom: none;
}

/* Chat Input Footer */
.chat-footer {
    padding: 1.5rem 2rem 2rem 2rem;
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent);
}

.input-form {
    display: flex;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--glass-shadow);
    transition: border-color 0.2s ease;
}

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

.input-form input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    height: 40px;
}

.input-form input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: var(--primary);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none; /* simple hides sidebar for tablet/mobile */
    }
}

/* Custom Divider */
.divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 1.5rem 0;
    width: 100%;
}

/* Tab Switcher */
.tab-switcher {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 0.25rem;
    border: 1px solid var(--border-light);
    margin-bottom: 1rem;
    gap: 0.25rem;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* Phone Identifier Bar */
.phone-identifier-bar {
    display: flex;
    align-items: center;
    background: rgba(245, 158, 11, 0.05);
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    padding: 0.75rem 2rem;
    gap: 1rem;
    transition: all 0.3s ease;
}

.phone-icon-wrapper {
    color: var(--accent);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

#customer-phone {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--text-main);
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

#customer-phone:focus {
    border-color: var(--accent);
}

.btn-phone-save {
    background: var(--accent);
    color: #0f111a;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-phone-save:hover {
    background: #fbbf24;
    transform: translateY(-1px);
}

.phone-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.phone-status.verified {
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

/* Document Management Header Button */
.doc-manage-btn {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--primary-light);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    margin-right: 1rem;
}

.doc-manage-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Docs Panel (Slide-out) */
.docs-panel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-light);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.docs-panel.open {
    right: 0;
}

.docs-panel-header {
    height: 70px;
    border-bottom: 1px solid var(--border-light);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.1);
}

.docs-panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-panel-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-panel-btn:hover {
    color: var(--text-main);
}

.docs-panel-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

.doc-selector-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.doc-selector-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.select-row {
    display: flex;
    gap: 0.5rem;
}

#doc-select {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    color: var(--text-main);
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

#doc-select optgroup {
    background: var(--bg-sidebar);
    color: var(--text-muted);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* Editor Container */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.editor-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.75rem;
}

.file-path-indicator {
    color: var(--primary-light);
    font-family: monospace;
}

.save-status-indicator {
    color: var(--text-muted);
}

#doc-editor {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    padding: 1rem;
    color: var(--text-main);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
}

/* Editor Actions */
.editor-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-save, .btn-create-new {
    flex: 1;
    border: none;
    padding: 0.8rem;
    border-radius: 10px;
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-save {
    background: var(--primary);
    color: #fff;
}

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

.btn-create-new {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-main);
}

.btn-create-new:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 17, 26, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 2rem;
    width: 400px;
    max-width: 90%;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-light);
}

.modal-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

#new-guide-filename {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    color: var(--text-main);
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    outline: none;
}

#new-guide-filename:focus {
    border-color: var(--primary-light);
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn-modal {
    flex: 1;
    border: none;
    padding: 0.7rem;
    border-radius: 8px;
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-confirm {
    background: var(--primary);
    color: #fff;
}

.btn-confirm:hover {
    background: var(--primary-light);
}

