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

body {
    font-family: 'Inter', sans-serif;
    background: #030303;
    color: white;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation; /* Improves touch responsiveness */
}

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

/* Sidebar */
.sidebar {
    width: 256px;
    background: rgba(15, 15, 15, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
    position: relative;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
}

.sidebar-logo-text {
    font-weight: 600;
    font-size: 1rem;
}

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



.sidebar-section {
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Agents Section */
.agents-section {
    margin-bottom: 1.5rem;
}

.agents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 0.75rem;
}

.agents-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.collapse-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.collapse-button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.collapse-button.collapsed {
    /* No rotation needed as we use different symbols */
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1001;
        transform: translateX(-100%);
    }
    
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 256px; /* Keep original width for smooth animation */
    }
    
    .right-panel {
        position: absolute;
        right: 0;
        top: 0;
        height: 100vh;
        z-index: 1001;
        transform: translateX(100%);
    }
    
    .right-panel:not(.collapsed) {
        transform: translateX(0);
    }
    
    .right-panel.collapsed {
        transform: translateX(100%);
        width: 320px; /* Keep original width for smooth animation */
    }
    
    .main-content {
        width: 100%;
        position: relative;
        z-index: 1000;
    }
}

/* iPhone 13 Pro specific */
@media (max-width: 390px) {
    .sidebar {
        width: 280px;
    }
    
    .right-panel {
        width: 300px;
    }
    
    .collapse-button {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
}

.right-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.right-panel-title {
    margin: 0;
}

/* Restore buttons for collapsed panels */
.sidebar-restore-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: rgba(99, 102, 241, 0.9);
    border: none;
    border-radius: 0 8px 8px 0;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

.sidebar-restore-btn:hover {
    background: rgba(99, 102, 241, 1);
    width: 28px;
}

.right-panel-restore-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: rgba(99, 102, 241, 0.9);
    border: none;
    border-radius: 8px 0 0 8px;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.3s ease;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
}

.right-panel-restore-btn:hover {
    background: rgba(99, 102, 241, 1);
    width: 28px;
}

/* User Subscription Info */
.user-subscription {
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.subscription-plan, .subscription-usage {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.subscription-usage {
    margin-bottom: 0.75rem;
}

.plan-label, .usage-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.plan-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(139, 92, 246, 0.8));
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.usage-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.usage-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(139, 92, 246, 0.8));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
    padding: 0 0.75rem;
}

.agents-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agent-item {
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

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

.agent-item.featured {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.agent-item.featured:hover {
    background: rgba(99, 102, 241, 0.15);
}

.agent-item.disabled {
    opacity: 0.5;
}

.agent-item.disabled .agent-name {
    color: rgba(255, 255, 255, 0.5);
}

.agent-item.disabled .agent-role {
    color: rgba(255, 255, 255, 0.3);
}

.agent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.agent-avatar {
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.agent-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.agent-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    line-height: 1.2;
}

.agent-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.2;
}

.agent-note {
    font-size: 0.7rem;
    color: rgba(99, 102, 241, 0.8);
    font-style: italic;
    margin-top: 0.25rem;
    display: block;
    line-height: 1.2;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: rgba(255, 255, 255, 0.8);
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    border-color: rgb(99, 102, 241);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background-color: white;
}

/* Chat History */
.chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.new-chat-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    border: none;
    color: white;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
}

.new-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.empty-history {
    text-align: center;
    padding: 2rem 1rem;
    color: rgba(255, 255, 255, 0.5);
}

.empty-history p {
    font-size: 0.8rem;
    line-height: 1.4;
}

.chat-history-item {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.chat-history-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.chat-history-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.chat-history-preview {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-history-date {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.25rem;
}

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

/* Header */
.header {
    height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(20px);
}

.header-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-button {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

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

/* Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 100%;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
    animation: fadeInUp 0.3s ease-out;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-sender {
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
}

.message-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.message-body {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message.user .message-body {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.message-action {
    width: 28px;
    height: 28px;
    border-radius: 0.375rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Chat Input */
.chat-input-container {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(20px);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.upload-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f3f4f6;
    cursor: pointer;
    user-select: none;
}

.upload-label:hover {
    background: #e5e7eb;
}

.chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 128px;
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 0.875rem;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: rgb(99, 102, 241);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

.send-button {
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    border: none;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

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

/* Right Panel */
.right-panel {
    width: 320px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
}

.right-panel.collapsed {
    width: 0;
    min-width: 0;
    border-left: none;
    overflow: hidden;
}

.right-panel-header {
    height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 1rem;
    display: flex;
    align-items: center;
}

.right-panel-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: white;
}

.right-panel-content {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.panel-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
}

.panel-tab {
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.panel-tab.active {
    background: rgba(99, 102, 241, 0.2);
    color: rgb(99, 102, 241);
}

/* User info */
.user-info {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.user-info-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-details h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
}

.user-details p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.logout-button {
    width: 100%;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: rgb(244, 63, 94);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.logout-button:hover {
    background: rgba(244, 63, 94, 0.2);
}

/* Mobile Styles */
.mobile-header {
    display: none;
    height: 70px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    box-sizing: border-box;
}

/* iOS safe area support */
@supports (-webkit-touch-callout: none) {
    .mobile-header {
        padding-top: env(safe-area-inset-top);
        height: calc(70px + env(safe-area-inset-top));
    }
}

.mobile-menu-button {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.right-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .right-panel {
        width: 280px;
    }
    
    .dashboard-container {
        gap: 0;
    }
}

/* Tablet styles */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1002;
        background: rgba(15, 15, 15, 0.95);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        z-index: 1001;
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .right-panel-overlay.active {
        display: block;
    }

    .main-content {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
        padding-top: 70px; /* Space for mobile header */
    }

    .main-content .header {
        display: none; /* Hide desktop header */
    }

    .chat-container {
        flex: 1;
        height: calc(100vh - 70px);
        overflow: hidden;
    }

    .chat-main {
        height: 100%;
    }

    .chat-messages {
        height: calc(100vh - 180px); /* Reserve space for header and floating input */
        padding: 1rem;
        padding-bottom: 6rem; /* Extra padding for floating input */
        overflow-y: auto;
    }

    .chat-input-container {
        position: fixed;
        bottom: 20px;
        left: 1rem;
        right: 1rem;
        background: rgba(15, 15, 15, 0.95);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 1rem;
        padding: 1rem;
        z-index: 100;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }

    .right-panel {
        position: fixed;
        top: 70px;
        right: 0;
        height: calc(100vh - 70px);
        width: 320px;
        transform: translateX(100%);
        z-index: 1000;
        transition: transform 0.3s ease;
    }

    .right-panel.open {
        transform: translateX(0);
    }

    .message {
        max-width: 95%;
        margin-bottom: 1rem;
    }

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

    .chat-input-wrapper {
        gap: 0.75rem;
        flex-wrap: nowrap;
    }

    .chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 44px; /* iOS touch target */
    }

    .send-button {
        padding: 0.75rem 1.25rem;
        white-space: nowrap;
        min-width: 100px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .mobile-header {
        padding: 0.75rem 1rem;
        height: 60px;
    }

    .mobile-header .header-title {
        font-size: 1rem;
    }

    .main-content {
        padding-top: 60px;
    }
    
    /* iOS specific adjustments */
    @supports (-webkit-touch-callout: none) {
        .main-content {
            padding-top: calc(60px + env(safe-area-inset-top)) !important;
        }
        
        .sidebar {
            padding-top: env(safe-area-inset-top);
        }
        
        .right-panel {
            top: calc(60px + env(safe-area-inset-top)) !important;
            height: calc(100vh - 60px - env(safe-area-inset-top)) !important;
        }
        
        .mobile-header {
            height: calc(60px + env(safe-area-inset-top)) !important;
        }
    }

    .chat-container {
        height: calc(100vh - 60px);
    }

    .chat-messages {
        padding: 0.75rem;
        height: calc(100% - 70px);
    }

    .chat-input-container {
        padding: 0.75rem;
    }

    .message {
        max-width: 100%;
        margin-bottom: 0.75rem;
    }

    .message.user {
        max-width: 90%;
    }

    .message-content {
        padding: 0.75rem;
    }

    .message-body {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .message-actions {
        padding: 0.5rem 0.75rem;
        gap: 1rem;
    }

    .message-action {
        font-size: 1rem;
        padding: 0.25rem;
        min-width: 32px;
        min-height: 32px;
    }

    .chat-input-wrapper {
        gap: 0.5rem;
        align-items: flex-end;
    }

    .chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
        min-height: 48px;
        max-height: 120px;
        -webkit-appearance: none;
        border-radius: 8px;
        resize: none;
        outline: none;
    }

    .send-button {
        padding: 0.75rem 1rem;
        min-width: 80px;
        font-size: 0.9rem;
        height: 48px;
    }

    .sidebar {
        width: 100%;
        max-width: 320px;
    }

    .right-panel {
        width: 100%;
        max-width: 320px;
        top: 60px;
        height: calc(100vh - 60px);
    }

    /* Agent cards on mobile */
    .agent-item {
        padding: 1rem;
        margin-bottom: 0.5rem;
    }

    .agent-details .agent-name {
        font-size: 0.9rem;
    }

    .agent-details .agent-role {
        font-size: 0.8rem;
    }

    .agent-note {
        font-size: 0.75rem;
    }

    /* Chat history on mobile */
    .chat-history-item {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .chat-history-title {
        font-size: 0.9rem;
    }

    .chat-history-preview {
        font-size: 0.8rem;
    }

    /* Empty state adjustments */
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state h3 {
        font-size: 1.1rem;
    }

    .empty-state p {
        font-size: 0.85rem;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .mobile-header {
        padding: 0.5rem;
    }

    .mobile-header .header-title {
        font-size: 0.9rem;
    }

    .chat-messages {
        padding: 0.5rem;
    }

    .chat-input-container {
        padding: 0.5rem;
    }

    .message-content {
        padding: 0.5rem;
    }

    .send-button {
        min-width: 70px;
        padding: 0.75rem 0.75rem;
    }
}

/* Mobile performance and UX improvements */
@media (max-width: 768px) {
    /* Prevent overscroll bounce on iOS */
    html, body {
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Improve scrolling performance */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Prevent text selection on buttons */
    .mobile-menu-button,
    .send-button,
    .collapse-button {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Improve touch targets */
    .chat-history-item,
    .agent-item,
    .message-action {
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Prevent horizontal scroll */
    .dashboard-container,
    .main-content,
    .chat-container {
        overflow-x: hidden;
    }
}

/* Keyboard active state for mobile */
@media (max-width: 768px) {
    /* When keyboard is active, adjust the layout */
    body.keyboard-active {
        height: 100vh;
        overflow: hidden;
    }
    
    body.keyboard-active .chat-container {
        padding-bottom: 0;
    }
    
    body.keyboard-active .chat-messages {
        height: calc(100vh - 160px) !important; /* Adjust for keyboard space */
        padding-bottom: 1rem;
    }
    
    body.keyboard-active .chat-input-container {
        background: rgba(15, 15, 15, 0.98) !important;
        backdrop-filter: blur(20px);
        border-top: 2px solid rgba(99, 102, 241, 0.3);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
    
    /* Ensure input is always visible when keyboard is active */
    body.keyboard-active .chat-input {
        transform: translateY(0) !important;
        opacity: 1 !important;
    }
    
    /* Prevent scroll when typing */
    body.keyboard-active .main-content {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
        padding-top: 70px;
    }
}

/* iOS specific keyboard handling */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        body.keyboard-active .chat-input-container {
            /* iOS safe area handling when keyboard is active */
            padding-bottom: env(safe-area-inset-bottom);
        }
        
        /* Better iOS keyboard handling */
        body.keyboard-active .chat-messages {
            -webkit-overflow-scrolling: touch;
            scroll-behavior: smooth;
        }
        
        /* Prevent iOS bounce when keyboard is visible */
        body.keyboard-active {
            position: fixed;
            width: 100%;
        }
    }
}

/* Enhanced mobile input styling */
@media (max-width: 768px) {
    .chat-input:focus {
        border-color: rgba(99, 102, 241, 0.6);
        box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
        outline: none;
    }
    
    /* Ensure send button is always accessible */
    .send-button {
        flex-shrink: 0;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better mobile input wrapper */
    .chat-input-wrapper {
        align-items: flex-end;
        min-height: 60px;
        box-sizing: border-box;
    }
}

/* Loading and Error States */
.loading-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    gap: 1rem;
}

.loading-state p {
    font-size: 1rem;
    opacity: 0.8;
}

.error-state p {
    font-size: 1rem;
    color: rgba(244, 63, 94, 0.8);
    margin-bottom: 1rem;
}

.retry-btn {
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Message with system role */
.message.system {
    opacity: 0.8;
}

.message.system .message-content {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid rgba(245, 158, 11, 0.5);
}

.message.system .message-sender {
    color: rgba(245, 158, 11, 0.9);
}

/* Actions Panel */
.actions-panel {
    padding: 1rem;
}

.actions-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.action-section {
    margin-bottom: 2rem;
}

.action-section h4 {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-description {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
    margin: 0;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    width: 100%;
}

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

.action-btn.primary {
    background: linear-gradient(135deg, rgb(99, 102, 241), rgb(139, 92, 246));
    color: white;
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, rgb(79, 82, 221), rgb(119, 72, 226));
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.action-btn.secondary {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: rgb(34, 197, 94);
}

.action-btn.secondary:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.5);
}

.action-btn.tertiary {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: rgb(245, 158, 11);
}

.action-btn.tertiary:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.5);
}

.action-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.action-btn span:last-child {
    flex: 1;
}

/* Mobile styles for action buttons */
@media (max-width: 768px) {
    .actions-panel {
        padding: 0.75rem;
    }
    
    .action-btn {
        padding: 1rem;
        font-size: 0.9rem;
        min-height: 48px; /* Touch target */
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }
    
    .action-icon {
        font-size: 1.2rem;
    }
    
    .action-section {
        margin-bottom: 1.5rem;
    }
    
    .action-section h4 {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
}

/* Processing message animation */
.message.processing {
    animation: pulse 2s infinite;
}

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

/* Markdown styles */
.message-body h1, 
.message-body h2, 
.message-body h3 {
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
    line-height: 1.2;
}

.message-body h1 { 
    font-size: 1.5rem; 
    color: rgb(99, 102, 241);
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
    padding-bottom: 0.5rem;
}

.message-body h2 { 
    font-size: 1.3rem; 
    color: rgb(139, 92, 246);
}

.message-body h3 { 
    font-size: 1.1rem; 
    color: rgb(168, 85, 247);
}

.message-body strong {
    color: rgb(34, 197, 94);
    font-weight: 600;
}

.message-body em {
    color: rgb(251, 191, 36);
    font-style: italic;
}

.message-body code {
    background: rgba(99, 102, 241, 0.1);
    color: rgb(167, 243, 208);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
}

.message-body pre {
    background: rgba(15, 15, 15, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    position: relative;
}

.message-body pre code {
    background: none;
    color: rgb(229, 231, 235);
    padding: 0;
    border-radius: 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

.message-body ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-body li {
    margin: 0.3rem 0;
    color: rgba(255, 255, 255, 0.9);
}

.message-body li::marker {
    color: rgb(99, 102, 241);
}

.message-body br {
    line-height: 1.6;
}

/* Reaction buttons with improved states */
.message-action {
    opacity: 0.6;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.message-action:hover {
    opacity: 1;
    transform: scale(1.1);
}

.message-action.reacted {
    opacity: 1;
    transform: scale(1.05);
}

/* Modal styles for selective export */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: rgb(15, 15, 15);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

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

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

.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1rem;
}

.agent-selection-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.agent-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-checkbox:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.agent-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: rgb(99, 102, 241);
}

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

.agent-emoji {
    font-size: 1.2rem;
}

.agent-name {
    color: white;
    font-weight: 500;
}

.export-options {
    margin-top: 1.5rem;
}

.export-options h4 {
    color: white;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.export-format-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.radio-option:hover {
    background: rgba(255, 255, 255, 0.03);
}

.radio-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: rgb(99, 102, 241);
}

.radio-option span {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-footer .action-btn {
    width: auto;
    min-width: 100px;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .action-btn {
        width: 100%;
    }
}

/* Tab panel styles */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Client panel styles */
.client-panel {
    padding: 1.5rem;
}

.client-panel h3 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.client-section {
    margin-bottom: 2rem;
}

.client-section h4 {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.client-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* Provider selection styles */
.provider-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.provider-option {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.provider-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.provider-label {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    width: 100%;
}

.provider-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: rgb(99, 102, 241);
    flex-shrink: 0;
}

.provider-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.provider-name {
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.provider-company {
    color: rgb(99, 102, 241);
    font-size: 0.85rem;
    font-weight: 500;
}

.provider-description {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-top: 0.25rem;
}

/* Provider actions */
.provider-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.provider-actions .action-btn {
    min-width: 150px;
}

/* Settings panel styles */
.settings-panel {
    padding: 1.5rem;
}

.settings-panel h3 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* AI Disclaimer */
.ai-disclaimer {
    position: sticky;
    bottom: 0;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.ai-disclaimer span {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive styles for provider selection */
@media (max-width: 768px) {
    .client-panel,
    .settings-panel {
        padding: 1rem;
    }
    
    .provider-label {
        padding: 0.75rem;
    }
    
    .provider-actions {
        flex-direction: column;
    }
    
    .provider-actions .action-btn {
        width: 100%;
        min-width: auto;
    }
    
    .ai-disclaimer {
        position: fixed;
        bottom: 110px; /* Above the floating input */
        left: 1rem;
        right: 1rem;
        border-radius: 0.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}