/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Simple Mode Colors - Navy Blue (fast, action-oriented) */
    --simple-primary: hsl(220, 70%, 35%);
    --simple-secondary: hsl(220, 70%, 45%);
    --simple-accent: hsl(220, 70%, 55%);

    /* Full Mode Colors - Deeper Navy (comprehensive, robust) */
    --full-primary: hsl(220, 70%, 30%);
    --full-secondary: hsl(220, 70%, 40%);
    --full-accent: hsl(220, 70%, 50%);

    /* Common Colors */
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, hsl(220, 70%, 40%) 0%, hsl(220, 70%, 25%) 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: var(--card-bg);
    padding: 20px 30px;
    border-radius: 12px 12px 0 0;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 32px;
    background: linear-gradient(135deg, hsl(220, 70%, 40%), hsl(220, 70%, 28%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Icon Styles */
.logo-icon {
    width: 32px;
    height: 32px;
    stroke: hsl(220, 70%, 35%);
    flex-shrink: 0;
}

.icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.badge-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.tab-icon {
    width: 40px;
    height: 40px;
    stroke: currentColor;
    flex-shrink: 0;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    stroke: var(--text-secondary);
    fill: transparent;
    margin: 0 auto 16px;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.agini-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, hsl(220, 70%, 40%), hsl(220, 70%, 28%));
    color: white;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu-btn:hover {
    background: var(--card-bg);
    border-color: hsl(220, 70%, 35%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, hsl(220, 70%, 40%), hsl(220, 70%, 28%));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 1000;
    animation: dropdownSlide 0.2s ease-out;
}

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

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-color);
}

/* Salesforce Connection Status Banner */
.sf-status-banner {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--warning-color);
}

.sf-status-banner.connected {
    border-left-color: var(--success-color);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.05), var(--card-bg));
}

.sf-status-banner.disconnected {
    border-left-color: var(--warning-color);
    background: linear-gradient(to right, rgba(245, 158, 11, 0.05), var(--card-bg));
}

.sf-status-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.sf-status-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.sf-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.sf-status-banner.connected .sf-icon {
    color: var(--success-color);
}

.sf-status-banner.disconnected .sf-icon {
    color: var(--warning-color);
}

#sf-status-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.sf-status-actions {
    display: flex;
    gap: 10px;
}

.btn-sf-connect,
.btn-sf-disconnect {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sf-connect {
    background: hsl(220, 70%, 35%);
    color: white;
}

.btn-sf-connect:hover {
    background: hsl(220, 70%, 28%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px hsl(220, 70%, 35%, 0.3);
}

.btn-sf-disconnect {
    background: var(--text-secondary);
    color: white;
}

.btn-sf-disconnect:hover {
    background: #4a5568;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(113, 128, 150, 0.3);
}

.sf-connection-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.connection-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.connection-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.connection-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Tab Navigation */
.tab-navigation {
    background: var(--card-bg);
    display: flex;
    gap: 2px;
    padding: 0;
    box-shadow: var(--shadow);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 30px;
    background: var(--bg-color);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: white;
}

.tab-btn.active {
    background: white;
    border-bottom-color: var(--simple-primary);
}

.tab-btn[data-tab="full"].active {
    border-bottom-color: var(--full-primary);
}

.tab-icon {
    font-size: 32px;
    line-height: 1;
}

.tab-content {
    text-align: left;
    flex: 1;
}

.tab-title {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.tab-subtitle {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    min-height: 0; /* Critical for flex scroll */
    overflow: hidden;
    position: relative;
}

.tab-content-area {
    display: none;
    height: 100%;
}

.tab-content-area.active {
    display: flex;
    flex-direction: column;
}

.tab-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    background: var(--card-bg);
    border-radius: 0 0 12px 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    flex: 1;
    min-height: 0; /* Critical for flex scroll */
    height: calc(100vh - 200px);
}

/* Sidebar Styles */
.sidebar {
    padding: 24px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-color);
    min-height: 0;
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.sidebar h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mode Indicator */
.mode-indicator {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.mode-badge.simple {
    background: linear-gradient(135deg, var(--simple-primary), var(--simple-secondary));
    color: white;
}

.mode-badge.full {
    background: linear-gradient(135deg, var(--full-primary), var(--full-secondary));
    color: white;
}

.mode-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Session Info Box */
.session-info-box {
    background: white;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.session-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--success-color);
    color: white;
}

.btn-new-session {
    width: 100%;
    padding: 10px;
    margin-top: 12px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-new-session:hover {
    border-color: var(--simple-primary);
    color: var(--simple-primary);
}

#full-new-session:hover {
    border-color: var(--full-primary);
    color: var(--full-primary);
}

/* Quick Actions (Simple Mode) */
.quick-actions {
    margin-bottom: 20px;
}

.example-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.example-btn:hover {
    border-color: var(--simple-primary);
    background: hsl(220, 70%, 35%, 0.05);
    transform: translateX(4px);
}

.example-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-color);
}

.example-btn:disabled:hover {
    border-color: var(--border-color);
    background: var(--bg-color);
    transform: none;
}

/* Workflow Stages (Full Mode) */
.workflow-stages {
    margin-bottom: 20px;
}

.stage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stage {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
    opacity: 0.4;
    background: white;
}

.stage.active {
    opacity: 1;
    background: linear-gradient(135deg, hsl(220, 70%, 30%, 0.1), hsl(220, 70%, 40%, 0.1));
    border-left: 3px solid var(--full-primary);
}

.stage.completed {
    opacity: 0.7;
}

.stage-icon {
    font-size: 16px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
    color: var(--text-secondary);
    flex-shrink: 0;
    font-size: 8px;
}

.stage.active .stage-icon {
    background: var(--full-primary);
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.stage.completed .stage-icon {
    background: var(--success-color);
    color: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.stage-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.stage-description {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Session Actions (Full Mode) */
.session-actions {
    margin-bottom: 20px;
}

.btn-action {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-action:hover:not(:disabled) {
    border-color: var(--full-primary);
    background: hsl(220, 70%, 30%, 0.05);
    transform: translateX(4px);
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Chat Area */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* Critical for flex scroll */
    overflow: hidden; /* Contain scroll within chat-messages */
    background: white;
}

/* Progress Bar */
.progress-bar-container {
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 3px;
}

.progress-fill.simple {
    background: linear-gradient(90deg, var(--simple-primary), var(--simple-secondary));
}

.progress-fill.full {
    background: linear-gradient(90deg, var(--full-primary), var(--full-secondary));
}

.progress-text {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar for Chat Messages */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 24px;
}

.welcome-message p {
    margin-bottom: 8px;
    font-size: 15px;
}

.quick-starts {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

.quick-start-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--full-primary), var(--full-secondary));
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.quick-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.quick-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-secondary);
}

.quick-start-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: slideIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, hsl(220, 70%, 40%), hsl(220, 70%, 28%));
}

.message.user .message-avatar svg {
    stroke: white;
}

.message.assistant .message-avatar {
    background: var(--border-color);
}

.message.assistant .message-avatar svg {
    stroke: var(--text-primary);
}

.message-content {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: linear-gradient(135deg, hsl(220, 70%, 40%), hsl(220, 70%, 28%));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: var(--bg-color);
    border-radius: 12px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Chat Input */
.chat-input-container {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: white;
}

.chat-form {
    display: flex;
    gap: 12px;
}

.message-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 15px;
    transition: all 0.3s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--simple-primary);
    box-shadow: 0 0 0 3px hsl(220, 70%, 35%, 0.1);
}

.message-input:disabled {
    background: var(--bg-color);
    cursor: not-allowed;
    opacity: 0.7;
}

#full-input:focus {
    border-color: var(--full-primary);
    box-shadow: 0 0 0 3px hsl(220, 70%, 30%, 0.1);
}

.btn-send {
    padding: 14px 32px;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-send.simple {
    background: linear-gradient(135deg, var(--simple-primary), var(--simple-secondary));
}

.btn-send.full {
    background: linear-gradient(135deg, var(--full-primary), var(--full-secondary));
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

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

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

#modal-body {
    margin-top: 20px;
}

pre {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .tab-layout {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 1024px) {
    .tab-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        border-radius: 12px;
    }

    .tab-navigation {
        flex-direction: column;
    }

    .tab-btn {
        padding: 16px 20px;
    }

    .tab-icon {
        font-size: 24px;
    }

    .tab-title {
        font-size: 16px;
    }

    .message-content {
        max-width: 85%;
    }

    .quick-starts {
        flex-direction: column;
    }

    .quick-start-btn {
        width: 100%;
    }

    .tab-layout {
        height: calc(100vh - 300px);
    }
}
