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

/* Ensure smooth scrolling for all scrollable elements */
* {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0b0b0c;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    scroll-behavior: smooth;
}

html {
    scroll-behavior: smooth;
}

/* Brand logo - keep crisp and avoid blurring */
.brand-logo {
    height: 40px;
    width: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor; /* legacy IE */
    border-radius: 6px;
}

/* Admin layout */
.admin-layout {
    position: relative;
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-areas: 'sidebar main';
    min-height: 100vh;
}

.admin-sidebar {
    grid-area: sidebar;
    background: rgba(28, 28, 30, 0.95);
    border-right: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(20px);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    align-self: start; /* ensure sticky works inside grid */
}

.admin-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 8px 16px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-brand-text { display: none; }
.admin-brand-logo-full { height: 24px; width: auto; display: block; }
.admin-brand-logo-mini { display: none; width: 28px; height: 28px; border-radius: 6px; }

.admin-menu { display: flex; flex-direction: column; gap: 6px; }
.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}
.admin-menu-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-menu-item.active { background: rgba(0,122,255,0.15); color: #007AFF; }
.admin-menu-icon { width: 18px; text-align: center; }
.admin-menu-text { white-space: nowrap; }

.admin-topbar {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(28,28,30,0.65);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.admin-topbar-logo { position: absolute; left: 50%; transform: translateX(-50%); pointer-events: none; }
.admin-topbar-logo-img { width: 200px; height: 20px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(0,0,0,0.25)); }

.admin-icon-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}
.admin-icon-btn:hover { background: rgba(255,255,255,0.12); }
.admin-topbar-spacer { flex: 1; }

.admin-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; }
.admin-content { padding: 20px; }

/* Clickable brand link inside centered header */
.brand-logo-link { 
    pointer-events: auto; 
    display: inline-block; 
    cursor: pointer; 
    transition: transform 0.2s ease;
    text-decoration: none;
}

.brand-logo-link:hover {
    transform: scale(1.05);
}

.brand-logo-link:active {
    transform: scale(0.98);
}

/* User menu */
.admin-user { position: relative; }
.admin-user-btn {
    display: flex; 
    align-items: center; 
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff; 
    padding: 10px 12px; 
    border-radius: 10px; 
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.admin-user-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.admin-user-name { font-size: 13px; font-weight: 500; }
.admin-user-dropdown {
    position: absolute; 
    right: 0; 
    top: calc(100% + 8px);
    background: rgba(28, 28, 30, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px; 
    backdrop-filter: blur(20px);
    min-width: 180px; 
    padding: 8px 0; 
    display: none; 
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.admin-user-dropdown.open { 
    display: block; 
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.admin-user-item { 
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none; 
    font-size: 14px; 
    padding: 12px 16px; 
    border-radius: 8px; 
    margin: 0 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.admin-user-item:hover { 
    background: rgba(255, 255, 255, 0.1); 
    color: #fff;
    transform: translateX(4px);
}

.admin-user-item:first-child {
    margin-top: 0;
    border-radius: 8px 8px 0 0;
}

.admin-user-item:last-child {
    margin-bottom: 0;
    border-radius: 0 0 8px 8px;
}

/* Icon styling in dropdown items */
.admin-user-item span {
    margin-right: 8px;
    font-size: 16px;
    opacity: 0.8;
}

/* Divider styling */
.admin-user-item.divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 8px;
    padding: 0;
    border-radius: 0;
}

.admin-user-item.divider:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
}

/* Collapsed sidebar */
/* Fully collapse sidebar without shifting main */
body.admin-collapsed .admin-layout { grid-template-columns: 0px 1fr; }
body.admin-collapsed .admin-sidebar { width: 0; padding: 0; border: none; overflow: hidden; }

/* Dashboard cards */
.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.admin-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 16px;
}
.admin-card-title { color: rgba(255,255,255,0.8); font-size: 13px; margin-bottom: 6px; }
.admin-card-value { color: #fff; font-size: 28px; font-weight: 700; }
.admin-card-sub { color: rgba(255,255,255,0.5); font-size: 12px; margin-top: 6px; }

/* Auth layout with subtle translucent card */
.auth-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(28, 28, 30, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.auth-card .modal-header { padding: 24px 24px 0; }
.auth-card .modal-body { padding: 20px 24px 24px; }
.auth-card .modal-footer { padding: 0 24px 24px; }

/* Background Elements */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.bg-circle-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.bg-circle-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    bottom: -50px;
    left: -50px;
    animation-delay: -7s;
}

.bg-circle-3 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

.bg-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    33% {
        transform: translateY(-20px) rotate(120deg);
    }
    66% {
        transform: translateY(10px) rotate(240deg);
    }
}

/* Centered Header Section */
.centered-header {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translate(-50%, 0);
    z-index: 100;
    text-align: center;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none !important;
}

.centered-header.shrunk {
    top: 20px;
    transform: translate(-50%, 0);
}

.main-title {
    display: none;
}

.centered-header.shrunk .main-title { display: none; }

.subtitle {
    display: none;
}

.centered-header.shrunk .subtitle { display: none; }

/* Hero logo in header */
.brand-logo-hero {
    height: 72px;
    width: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
    filter: drop-shadow(0 10px 30px rgba(0,0,0,0.35));
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.centered-header.shrunk .brand-logo-hero {
    height: 32px;
}

.app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    position: relative;
}



/* Dashboard Modal */
.dashboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-modal.open {
    opacity: 1;
    visibility: visible;
}

.dashboard-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 800px;
    background: rgba(28, 28, 30, 0.95);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.dashboard-modal.open .dashboard-content {
    transform: translate(-50%, -50%) scale(1);
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dashboard-header h2 {
    color: white;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.close-dashboard-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-dashboard-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Dashboard Tabs */
.dashboard-tabs {
    display: flex;
    padding: 0 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 16px 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    position: relative;
}

.tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.tab-btn.active {
    color: white;
    border-bottom-color: #667eea;
}

.tab-btn svg {
    transition: all 0.3s ease;
}

.tab-btn.active svg {
    color: #667eea;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 24px 32px;
    overflow-y: auto;
}

.tab-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.tab-panel::-webkit-scrollbar {
    width: 6px;
}

.tab-panel::-webkit-scrollbar-track {
    background: transparent;
}

.tab-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.tab-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.panel-header h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    flex: 1;
    max-width: 400px;
    transition: all 0.3s ease;
}

.search-bar:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.15);
}

.search-bar svg {
    color: rgba(255, 255, 255, 0.5);
    margin-right: 12px;
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    color: white;
    font-size: 14px;
    flex: 1;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Filters */
.filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filters select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filters select:hover {
    background: rgba(255, 255, 255, 0.15);
}

.filters select option {
    background: rgba(28, 28, 30, 0.95);
    color: white;
}

.export-btn {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.3);
    color: #667eea;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.export-btn:hover {
    background: rgba(102, 126, 234, 0.3);
    transform: translateY(-1px);
}

/* Conversations List */
.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dashboard-conversation-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.dashboard-conversation-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.dashboard-conversation-item.favorited {
    border-color: rgba(255, 193, 7, 0.5);
    background: rgba(255, 193, 7, 0.1);
}

.conversation-header-dashboard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.conversation-title-dashboard {
    color: white;
    font-size: 16px;
    font-weight: 500;
    flex: 1;
}

.conversation-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.favorite-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.favorite-btn:hover {
    color: #ffc107;
}

.favorite-btn.favorited {
    color: #ffc107;
}

.conversation-messages-dashboard {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.conversation-messages-dashboard.expanded {
    max-height: 200px;
    margin-top: 12px;
}

.dashboard-message-item {
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.dashboard-message-item:hover {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
}

.dashboard-message-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Automations */
.add-automation-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.add-automation-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.automations-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.automation-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.automation-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.automation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.automation-title {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

.automation-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

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

.status-indicator.active {
    background: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.status-indicator.inactive {
    background: #f44336;
}

.automation-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.automation-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Insights */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.insight-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.insight-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-4px);
}

.insight-card h4 {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}

.insight-value {
    color: white;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.charts-section {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
}

.charts-section h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

/* History Panel Styles */
.history-panel {
    position: fixed;
    left: -320px;
    top: 0;
    width: 320px;
    height: 100vh;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2000;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.history-panel.open {
    left: 0;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-header h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.close-panel-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-panel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.conversation-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.conversation-header {
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-header:hover {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: rgba(102, 126, 234, 0.5);
}

.conversation-header.active {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
}

.conversation-title {
    color: white;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    flex: 1;
    margin-right: 12px;
}

.conversation-time {
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    white-space: nowrap;
}

.expand-icon {
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-header.expanded .expand-icon {
    transform: rotate(90deg);
}

.conversation-messages {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.2);
}

.conversation-messages.expanded {
    max-height: 300px;
}

.message-item {
    padding: 12px 20px 12px 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    position: relative;
}

.message-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-left-color: rgba(102, 126, 234, 0.3);
}

.message-item.highlighted {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
}

.message-item::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

.message-item.user-message::before {
    background: #667eea;
}

.message-item.bot-message::before {
    background: rgba(255, 255, 255, 0.5);
}

.message-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-time {
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
    margin-top: 4px;
}

/* History Toggle Button */
.history-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1500;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.history-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.history-toggle-btn:active {
    transform: scale(0.95);
}

/* Chat Container */
.chat-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
}

.chat-container.panel-open {
    margin-left: 320px;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 16px;
    padding-bottom: 120px;
    padding-top: 20px;
    opacity: 0;
    transition: all 0.5s ease;
    position: relative;
    z-index: 1000;
    pointer-events: none;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.messages-container.has-messages {
    opacity: 1;
    padding-top: 200px;
    min-height: calc(100vh - 400px);
}

.messages-container::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    animation: messageSlideIn 0.4s ease-out;
    word-wrap: break-word;
    line-height: 1.4;
    white-space: pre-wrap;
    transition: all 0.3s ease;
    transform: translateY(0);
    will-change: transform;
    backface-visibility: hidden;
}

.message.highlighted {
    background: rgba(102, 126, 234, 0.2) !important;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.bot-message {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(10px);
}

.input-container {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 100%;
    max-width: 800px;
    padding: 20px;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999 !important;
    pointer-events: auto !important;
    will-change: transform;
    backface-visibility: hidden;
    /* Ensure input is always accessible */
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 20px;
}

.input-container.moved-to-bottom {
    bottom: 0;
    transform: translate(-50%, 0);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 50%, transparent 100%);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 8px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    position: relative;
    z-index: 10000 !important;
    pointer-events: auto !important;
}

.input-wrapper:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 16px;
    font-size: 16px;
    background: transparent;
    color: white;
    font-family: inherit;
    position: relative;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

#messageInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    margin-left: 8px;
    position: relative;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    align-self: flex-start;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

@keyframes historyItemSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Three Column Layout */
.main-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    height: 100vh;
    width: 100%;
    position: relative;
    z-index: 1000;
}

/* Left Sidebar */
.left-sidebar {
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header h3 {
    color: white;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.new-chat-btn {
    background: rgba(0, 122, 255, 0.15);
    border: 1px solid rgba(0, 122, 255, 0.3);
    color: #007AFF;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.new-chat-btn:hover {
    background: rgba(0, 122, 255, 0.25);
    transform: translateY(-1px);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.conversation-search {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 122, 255, 0.5);
}

.search-input-wrapper svg {
    color: rgba(255, 255, 255, 0.5);
    margin-right: 8px;
}

.search-input-wrapper input {
    background: none;
    border: none;
    outline: none;
    color: white;
    font-size: 14px;
    flex: 1;
}

.search-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.conversation-list::-webkit-scrollbar {
    width: 4px;
}

.conversation-list::-webkit-scrollbar-track {
    background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.conversation-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.conversation-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-left-color: rgba(0, 122, 255, 0.5);
}

.conversation-item.active {
    background: rgba(0, 122, 255, 0.12);
    border-left-color: #007AFF;
}

.conversation-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-right: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.conversation-item.active .conversation-icon {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-title {
    color: white;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-status.active {
    background: rgba(52, 199, 89, 0.2);
    color: #34C759;
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.conversation-status.quoted {
    background: rgba(255, 149, 0, 0.2);
    color: #FF9500;
    border: 1px solid rgba(255, 149, 0, 0.3);
}

.conversation-status.completed {
    background: rgba(88, 86, 214, 0.2);
    color: #5856D6;
    border: 1px solid rgba(88, 86, 214, 0.3);
}

.conversation-status:hover {
    transform: scale(1.05);
}

.conversation-subtitle {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    line-height: 1.3;
}

/* Right Sidebar */
.right-sidebar {
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Workflow Tabs Container */
.workflow-tabs-container {
    padding: 0 16px;
    margin-bottom: 16px;
}

/* Workflow Tabs */
.workflow-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
    gap: 2px;
}

.workflow-tab-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.workflow-tab-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 122, 255, 0.1);
    border-radius: 6px;
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.workflow-tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.workflow-tab-btn:hover::before {
    transform: scaleX(1);
}

.workflow-tab-btn.active {
    color: white;
    background: rgba(0, 122, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.workflow-tab-btn.active::before {
    transform: scaleX(1);
}

.workflow-tab-btn svg {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.workflow-tab-btn span {
    position: relative;
    z-index: 1;
}

.workflow-tab-btn.active svg {
    color: #007AFF;
}

/* Workflow Tab Content */
.workflow-tab-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.workflow-tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
    overflow-y: auto;
}

.workflow-tab-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.workflow-tab-panel::-webkit-scrollbar {
    width: 4px;
}

.workflow-tab-panel::-webkit-scrollbar-track {
    background: transparent;
}

.workflow-tab-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.workflow-tab-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Sidebar Header Layout */
.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    margin: 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

/* Floating Sidebar Toggle - Always Visible */
.floating-sidebar-toggle {
    position: fixed;
    right: 24px;
    top: 24px;
    z-index: 2001;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.floating-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}





.workflow-section {
    margin-bottom: 32px;
}

.workflow-section h4 {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.preview-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.preview-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.4;
}

.details-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
}

.detail-value {
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.detail-value.active {
    color: #4caf50;
}

.files-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.file-icon {
    font-size: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    color: white;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
}

.draft-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.draft-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.draft-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.draft-icon {
    font-size: 14px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.draft-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    line-height: 1.4;
}

/* Files Tab Content */
.add-file-btn {
    background: rgba(0, 122, 255, 0.15);
    border: 1px solid rgba(0, 122, 255, 0.3);
    color: #007AFF;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    width: 100%;
    justify-content: center;
}

.add-file-btn:hover {
    background: rgba(0, 122, 255, 0.25);
    transform: translateY(-1px);
}

.add-file-btn:active {
    transform: translateY(0);
}

.files-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.placeholder-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.placeholder-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.placeholder-subtext {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    line-height: 1.4;
}

/* Update existing chat container for new layout */
.chat-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
}

/* New Chat Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-body {
    padding: 20px 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: white;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 12px 16px;
    color: white;
    font-size: 14px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: rgba(0, 122, 255, 0.5);
    background: rgba(255, 255, 255, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    cursor: pointer;
}

.form-group select option {
    background: rgba(28, 28, 30, 0.95);
    color: white;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
    background: rgba(0, 122, 255, 0.2);
    border: 1px solid rgba(0, 122, 255, 0.3);
    color: #007AFF;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.btn-primary:hover {
    background: rgba(0, 122, 255, 0.3);
}

/* Dashboard Button (Bottom Left) */
.dashboard-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 2000;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dashboard-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.dashboard-btn:active {
    transform: translateY(0);
}

.dashboard-btn svg {
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.8);
}

/* User Dropdown Styles */
.admin-user-dropdown {
    position: fixed;
    bottom: 80px;
    left: 24px;
    z-index: 2001;
    background: rgba(28, 28, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    padding: 8px 0;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.admin-user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.admin-user-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.admin-user-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.admin-user-item:first-child {
    border-radius: 12px 12px 0 0;
}

.admin-user-item:last-child {
    border-radius: 0 0 12px 12px;
}

/* Chat History Popup */
.chat-history-popup {
    position: fixed;
    bottom: 80px;
    left: 24px;
    z-index: 2001;
    width: 320px;
    max-height: 500px;
    background: rgba(28, 28, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-history-popup.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.popup-header h3 {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.popup-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.popup-content {
    padding: 16px 20px;
}

.popup-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.popup-new-chat-btn,
.popup-save-btn {
    flex: 1;
    background: rgba(0, 122, 255, 0.15);
    border: 1px solid rgba(0, 122, 255, 0.3);
    color: #007AFF;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.popup-new-chat-btn:hover,
.popup-save-btn:hover {
    background: rgba(0, 122, 255, 0.25);
    transform: translateY(-1px);
}

.popup-new-chat-btn:active,
.popup-save-btn:active {
    transform: translateY(0);
}

.popup-conversations {
    max-height: 300px;
    overflow-y: auto;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.popup-conversations::-webkit-scrollbar {
    width: 4px;
}

.popup-conversations::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.popup-conversations::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.popup-conversations::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Profile Section (for sidebar) */
.profile-section {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(0, 122, 255, 0.2);
    border-radius: 50%;
    color: #007AFF;
}

.profile-name {
    font-size: 13px;
    font-weight: 500;
}

/* Profile Dropdown */
.profile-dropdown {
    position: absolute;
    bottom: 60px;
    left: 20px;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    min-width: 180px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.profile-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-item svg {
    color: rgba(255, 255, 255, 0.7);
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.empty-subtext {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-title {
        font-size: 60px;
    }
    
    .centered-header.shrunk .main-title {
        font-size: 28px;
    }
    
    .subtitle {
        font-size: 16px;
    }
    
    .centered-header.shrunk .subtitle {
        font-size: 13px;
    }
    
    .centered-header {
        top: 40px;
    }
    
    .centered-header.shrunk {
        top: 15px;
    }
    
    .messages-container.has-messages {
        padding-top: 180px;
    }
    
    .dashboard-content {
        width: 95%;
        height: 95%;
    }
    
    .dashboard-header {
        padding: 20px 24px;
    }
    
    .dashboard-tabs {
        padding: 0 24px;
    }
    
    .tab-btn {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .tab-panel {
        padding: 20px 24px;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .search-bar {
        max-width: none;
    }
    
    .filters {
        justify-content: space-between;
    }
    
    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .insight-card {
        padding: 20px;
    }
    
    .insight-value {
        font-size: 24px;
    }
    
    .history-panel {
        width: 280px;
        left: -280px;
    }
    
    .chat-container.panel-open {
        margin-left: 280px;
    }
    
    .messages-container {
        padding: 15px;
        padding-bottom: 100px;
        padding-top: 15px;
    }
    
    .input-container {
        padding: 15px;
    }
    
    .input-wrapper {
        border-radius: 20px;
    }
    
    #messageInput {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    

    
    .dashboard-btn {
        top: 15px;
        right: 15px;
        padding: 10px;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .left-sidebar {
        order: 1;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .chat-container {
        order: 2;
        height: 60vh;
    }
    
    .right-sidebar {
        order: 3;
        height: auto;
        max-height: 200px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .conversation-list {
        max-height: 120px;
    }
    
    .workflow-sections {
        max-height: 120px;
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 48px;
    }
    
    .centered-header.shrunk .main-title {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .centered-header.shrunk .subtitle {
        font-size: 12px;
    }
    
    .centered-header {
        top: 30px;
    }
    
    .centered-header.shrunk {
        top: 10px;
    }
    
    .messages-container.has-messages {
        padding-top: 160px;
    }
    
    .dashboard-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .dashboard-header {
        padding: 16px 20px;
    }
    
    .dashboard-tabs {
        padding: 0 20px;
    }
    
    .tab-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .tab-panel {
        padding: 16px 20px;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .insight-card {
        padding: 16px;
    }
    
    .insight-value {
        font-size: 20px;
    }
    
    .history-panel {
        width: 100%;
        left: -100%;
    }
    
    .chat-container.panel-open {
        margin-left: 0;
    }
    
    .messages-container {
        padding: 10px;
        padding-bottom: 90px;
        padding-top: 10px;
    }
    
    .input-container {
        padding: 10px;
    }
    
    .input-wrapper {
        border-radius: 18px;
        padding: 6px;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
    }
    

    
    .dashboard-btn {
        top: 10px;
        right: 10px;
        padding: 8px;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .left-sidebar {
        order: 1;
        height: auto;
        max-height: 150px;
    }
    
    .chat-container {
        order: 2;
        height: 50vh;
    }
    
    .right-sidebar {
        order: 3;
        height: auto;
        max-height: 150px;
    }
    
    .conversation-list {
        max-height: 80px;
    }
    
    .workflow-sections {
        max-height: 80px;
    }
}

/* Index page specific admin header styles */
.index-page .admin-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
}

.index-page .app-container {
    padding-top: 56px; /* Minimal padding - just enough for admin header */
}

.index-page .chat-container {
    margin-top: 20px;
}

/* Fix panel positioning to prevent overlap with admin header */
.index-page .left-sidebar,
.index-page .right-sidebar {
    position: relative;
    top: 0;
    z-index: 100; /* Lower than admin header */
    width: 320px; /* Increased width for better usability */
}

.index-page .left-sidebar {
    position: fixed;
    left: 0;
    top: 56px; /* Start immediately below admin header */
    height: calc(100vh - 56px);
    overflow-y: auto;
}

.index-page .right-sidebar {
    position: fixed;
    right: 0;
    top: 56px; /* Start immediately below admin header */
    height: calc(100vh - 56px);
    overflow-y: auto;
}

.index-page .chat-container {
    margin-left: 340px; /* Account for left sidebar width + padding */
    margin-right: 340px; /* Account for right sidebar width + padding */
    margin-top: 20px;
    width: calc(100vw - 680px); /* Full width between sidebars */
    max-width: none; /* Remove max-width restriction */
}

/* Ensure admin header elements are visible */
.index-page .admin-topbar-logo-img {
    width: 150px;
    height: 16px;
}

.index-page .admin-user-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.index-page .admin-user-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Responsive adjustments for index page */
@media (max-width: 1200px) {
    .index-page .chat-container {
        margin-left: 340px;
        margin-right: 340px;
        width: calc(100vw - 680px);
    }
}

@media (max-width: 1000px) {
    .index-page .left-sidebar,
    .index-page .right-sidebar {
        width: 300px;
    }
    
    .index-page .chat-container {
        margin-left: 320px;
        margin-right: 320px;
        width: calc(100vw - 640px);
    }
}

@media (max-width: 768px) {
    .index-page .app-container {
        padding-top: 56px;
    }
    
    .index-page .left-sidebar,
    .index-page .right-sidebar {
        top: 56px;
        height: calc(100vh - 56px);
        width: 280px;
    }
    
    .index-page .chat-container {
        margin-left: 300px;
        margin-right: 300px;
        width: calc(100vw - 600px);
    }
}

@media (max-width: 600px) {
    .index-page .left-sidebar,
    .index-page .right-sidebar {
        display: none; /* Hide sidebars on very small screens */
    }
    
    .index-page .chat-container {
        margin-left: 20px;
        margin-right: 20px;
    }
}

/* Prevent unwanted scroll behavior on message input */
.index-page .message-input {
    scroll-behavior: auto;
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
    color: #fff;
}

/* Ensure messages container uses full width */
.index-page .messages-container {
    width: 100%;
    max-width: none;
    padding: 20px;
}

/* Ensure chat bubbles use full width */
.index-page .message {
    width: 100%;
    max-width: none;
    margin: 10px 0;
}

.index-page .input-container {
    scroll-behavior: auto;
    /* Ensure input is always accessible in index page */
    z-index: 10000 !important;
    pointer-events: auto !important;
}

/* Ensure input wrapper is accessible */
.index-page .input-wrapper {
    z-index: 10001 !important;
    pointer-events: auto !important;
}

/* Ensure message input is accessible */
.index-page #messageInput {
    z-index: 10002 !important;
    pointer-events: auto !important;
}

/* Ensure send button is accessible */
.index-page .send-button {
    z-index: 10002 !important;
    pointer-events: auto !important;
}

/* Ensure proper focus and input behavior */
.index-page .message-input:focus {
    outline: none;
    border-color: rgba(0, 122, 255, 0.5);
}

.index-page .message-input:focus-visible {
    outline: 2px solid rgba(0, 122, 255, 0.5);
    outline-offset: 2px;
}

/* Workflow Submenu Styles */
.workflow-submenu {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin: 8px 16px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.workflow-submenu.open {
    max-height: 200px;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.submenu-item:last-child {
    border-bottom: none;
}

.submenu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.submenu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.submenu-text {
    font-size: 14px;
    font-weight: 500;
}

/* Workflow Modal Styles */
.workflow-modal,
.workflow-viewer-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.workflow-modal-content,
.workflow-viewer-content {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.workflow-modal-header,
.workflow-viewer-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.workflow-modal-header h3,
.workflow-viewer-header h3 {
    color: #fff;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.close-workflow-modal,
.close-workflow-viewer {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.close-workflow-modal:hover,
.close-workflow-viewer:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.workflow-modal-body,
.workflow-viewer-body {
    padding: 24px;
}

.workflow-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.workflow-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.workflow-info h4 {
    color: #fff;
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.workflow-info p {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 8px 0;
    font-size: 14px;
}

.workflow-info small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.workflow-actions {
    display: flex;
    gap: 8px;
}

.btn-view,
.btn-delete {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-view {
    background: rgba(102, 126, 234, 0.2);
    color: rgba(102, 126, 234, 0.9);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.btn-view:hover {
    background: rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.5);
}

.btn-delete {
    background: rgba(255, 59, 48, 0.2);
    color: rgba(255, 59, 48, 0.9);
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.btn-delete:hover {
    background: rgba(255, 59, 48, 0.3);
    border-color: rgba(255, 59, 48, 0.5);
}

.no-workflows {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    padding: 40px 20px;
    font-size: 16px;
}

.workflow-description {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.workflow-description p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 8px 0;
    font-size: 14px;
}

.workflow-description p:last-child {
    margin-bottom: 0;
}

.workflow-mermaid {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workflow-mermaid svg {
    max-width: 100%;
    max-height: 100%;
}
