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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    height: 100vh;
    overflow: hidden;
    display: flex;
    margin: 0;
    padding: 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h2 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 24px;
    font-weight: 700;
}

.modal-content > p {
    color: #666;
    margin-bottom: 24px;
    font-size: 16px;
}

.upload-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.upload-option {
    padding: 24px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-option:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
}

.upload-option h3 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 600;
}

.upload-option p {
    color: #666;
    margin-bottom: 16px;
    font-size: 14px;
}

.file-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.file-upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.file-upload-area.dragover {
    border-color: #667eea;
    background: #f0f2ff;
    transform: scale(1.02);
}

.upload-content .upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-content p {
    color: #4b5563;
    font-weight: 500;
    margin-bottom: 4px;
}

.upload-content small {
    color: #6b7280;
    font-size: 12px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.upload-status {
    text-align: center;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
    display: none;
}

.upload-status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.upload-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.upload-status.loading {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

@media (max-width: 768px) {
    .upload-options {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .modal-content {
        padding: 24px;
        margin: 16px;
    }
}

/* Data Preview Styles */
.data-preview {
    margin-top: 24px;
    padding: 24px;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    background: #f8f9fa;
}

.data-preview h3 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 600;
}

.data-preview > p {
    color: #666;
    margin-bottom: 16px;
    font-size: 14px;
}

.preview-table-container {
    max-height: 300px;
    overflow: auto;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    padding: 12px 8px;
    border-bottom: 2px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    text-align: left;
}

.preview-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f3f4;
    border-right: 1px solid #f1f3f4;
    color: #333;
}

.preview-table tr:hover {
    background: #f8f9ff;
}

.preview-table th:last-child,
.preview-table td:last-child {
    border-right: none;
}

.preview-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

@media (max-width: 480px) {
    .preview-actions {
        flex-direction: column;
    }
    
    .preview-table {
        font-size: 11px;
    }
    
    .preview-table th,
    .preview-table td {
        padding: 8px 6px;
    }
}

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

.sidebar {
    width: 260px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.diva-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.diva-logo:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.sidebar-header h1 {
    font-size: 24px;
    margin: 0;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    color: white;
}

.sidebar-header p {
    opacity: 0.9;
    font-size: 14px;
    font-weight: 400;
    margin: 0;
    line-height: 1.4;
}

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

.session-section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.session-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #ecf0f1;
}

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

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

.session-row:last-child {
    border-bottom: none;
}

.session-label {
    font-weight: 500;
    opacity: 0.8;
    font-size: 13px;
}

.session-value {
    font-weight: 600;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.status-active {
    color: #2ecc71;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.toggle-sidebar {
    position: absolute;
    top: 50%;
    right: -15px;
    background: #2c3e50;
    color: white;
    border: none;
    width: 30px;
    height: 60px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transform: translateY(-50%);
    transition: all 0.3s ease;
    z-index: 1001;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    display: none;
}

.toggle-sidebar:hover {
    background: #34495e;
}

.chat-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 20px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.chat-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #2c3e50;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: #2c3e50;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    min-width: 30px;
}

/* Profile Section Styles */
.profile-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.profile-avatar {
    position: relative;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.avatar-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.avatar-text {
    color: white;
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.profile-info {
    flex: 1;
}

.profile-name-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #2c3e50;
    letter-spacing: 0.5px;
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: help;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.verified-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.4);
}

.profile-status {
    font-size: 12px;
    color: #6c757d;
    margin: 0;
    font-weight: 500;
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
}

.chat-subtitle {
    font-size: 12px;
    opacity: 0.6;
    margin: 0;
}

.chat-messages {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: linear-gradient(180deg, #fafbfc 0%, #f8f9fa 100%);
    position: relative;
    min-height: 0;
}

.chat-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.message {
    margin-bottom: 25px;
    display: flex;
    align-items: flex-start;
    animation: fadeInUp 0.4s ease-out;
}

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

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

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

.message-content {
    max-width: 75%;
    padding: 18px 24px;
    border-radius: 20px;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 8px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.message.assistant .message-content {
    background: white;
    color: #2c3e50;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.message-images {
    width: 100%;
    max-width: 75%;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chart-image {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin: 0;
    display: block;
}

.chart-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

/* Markdown styling */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-content th,
.message-content td {
    border: 1px solid #e1e8ed;
    padding: 10px 12px;
    text-align: left;
}

.message-content th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 600;
    color: #495057;
}

.message-content tr:nth-child(even) {
    background-color: #f8f9fa;
}

.message-content tr:hover {
    background-color: #e3f2fd;
}

.message-content strong {
    color: #2c3e50;
    font-weight: 600;
}

.message-content em {
    color: #6c757d;
    font-style: italic;
}

.message-content code {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #d63384;
}

.message-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 12px;
    margin: 10px 0;
    color: #6c757d;
    font-style: italic;
}

.clear-button {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
}

.clear-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(255, 107, 107, 0.4);
}

.message.assistant .message-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 85%;
}

.message-time {
    font-size: 12px;
    opacity: 0.6;
    margin: 8px 12px 0;
    font-weight: 500;
}

.chat-input-container {
    padding: 20px 25px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 15px;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.chat-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 25px;
    outline: none;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 90px;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

.send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(102, 126, 234, 0.5);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.8;
    padding: 18px 24px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out;
}

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

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

.error-message {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    margin: 15px 0;
    border: none;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
    animation: fadeInUp 0.4s ease-out;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        overflow: hidden;
    }

    .app-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        width: 100vw;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }

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

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .chat-container {
        margin: 0;
        border-radius: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        position: fixed;
        top: 0;
        left: 0;
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        padding: 12px 16px;
        min-height: 60px;
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }

    .mobile-toggle {
        display: block;
    }

    .profile-section {
        gap: 8px;
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .avatar-circle {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .avatar-text {
        font-size: 14px;
    }

    .profile-info {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .profile-name-wrapper {
        gap: 6px;
        margin-bottom: 1px;
    }

    .profile-name {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .verified-badge {
        width: 16px;
        height: 16px;
        font-size: 10px;
        flex-shrink: 0;
    }

    .profile-status {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 0.8;
    }

    .chat-messages {
        padding: 15px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .message-content {
        max-width: 90%;
        padding: 12px 16px;
        font-size: 14px;
    }

    .chat-input-container {
        padding: 15px;
        flex-shrink: 0;
        position: relative;
        bottom: 0;
    }

    .message-time {
        display: none;
    }
}

@media (max-width: 480px) {
    .mobile-header {
        gap: 8px;
    }

    .mobile-toggle {
        font-size: 16px;
        padding: 3px;
        min-width: 26px;
    }

    .profile-section {
        gap: 6px;
    }

    .avatar-circle {
        width: 28px;
        height: 28px;
    }

    .avatar-text {
        font-size: 12px;
    }

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

    .verified-badge {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }

    .profile-status {
        font-size: 9px;
    }

    .chat-header {
        padding: 10px 12px;
        min-height: 55px;
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }

    .chat-messages {
        padding: 12px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .chat-input-container {
        padding: 12px;
        flex-shrink: 0;
        position: relative;
        bottom: 0;
    }

    .chat-input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .send-button {
        padding: 12px 20px;
        font-size: 14px;
        min-width: 80px;
    }

    .message-time {
        display: none;
    }
}

@media (min-width: 769px) {
    .mobile-toggle {
        display: none;
    }

    .sidebar-overlay {
        display: none;
    }
}

/* Smooth focus transitions */
* {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Professional loading state */
.message.loading .message-content {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
