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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a0a;
    min-height: 100vh;
    color: #e5e5e5;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: #1a1a1a;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    color: #e5e5e5;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 100;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hamburger-menu {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-menu span {
    width: 25px;
    height: 3px;
    background: #e5e5e5;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: 1px;
}

.hamburger-menu.active span:first-child {
    transform: rotate(45deg);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:last-child {
    transform: rotate(-45deg);
}

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

.logo i {
    font-size: 1.5rem;
    color: #4f46e5;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e5e5e5;
}

.header-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: #a1a1aa;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

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

.status-dot.connected {
    background: #10b981;
}

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

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

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: #1e1e2e;
    border-right: 1px solid #374151;
    padding: 1.5rem;
    overflow-y: auto;
    z-index: 999;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.sidebar.show {
    left: 0;
}

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

.sidebar-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #e5e5e5;
    margin-bottom: 1rem;
}

.quick-queries {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-query-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #2d2d44;
    border: 1px solid #374151;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 0.875rem;
    color: #e5e5e5;
    word-wrap: break-word;
    white-space: normal;
}

.quick-query-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.quick-query-btn i {
    font-size: 1rem;
    width: 16px;
    flex-shrink: 0;
}

.db-info {
    background: #2d2d44;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #374151;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #374151;
}

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

.info-item .label {
    font-weight: 500;
    color: #a1a1aa;
}

.info-item .value {
    font-weight: 600;
    color: #e5e5e5;
    word-wrap: break-word;
    text-align: right;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0a0a0a;
    width: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #0a0a0a;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
}

.welcome-content {
    max-width: 500px;
    word-wrap: break-word;
}

.welcome-content i {
    font-size: 3rem;
    color: #4f46e5;
    margin-bottom: 1rem;
}

.welcome-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #e5e5e5;
    margin-bottom: 1rem;
}

.welcome-content p {
    color: #a1a1aa;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.example-queries {
    text-align: left;
    background: #1e1e2e;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.example-queries p {
    font-weight: 600;
    color: #e5e5e5;
    margin-bottom: 0.75rem;
}

.example-queries ul {
    list-style: none;
    padding: 0;
}

.example-queries li {
    padding: 0.5rem 0;
    color: #a1a1aa;
    border-bottom: 1px solid #374151;
    word-wrap: break-word;
}

.example-queries li:last-child {
    border-bottom: none;
}

.example-queries li:before {
    content: "💡";
    margin-right: 0.5rem;
}

/* Message Styles */
.message {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
}

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

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

.message.user .message-avatar {
    background: #4f46e5;
    color: white;
}

.message.assistant .message-avatar {
    background: #10b981;
    color: white;
}

.message-content {
    flex: 1;
    max-width: 80%;
    min-width: 200px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    width: fit-content;
    max-width: 100%;
}

.message.user .message-bubble {
    background: #4f46e5;
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.message.assistant .message-bubble {
    background: #1e1e2e;
    color: #e5e5e5;
    border: 1px solid #374151;
    border-bottom-left-radius: 4px;
}

.message-text {
    line-height: 1.6;
    margin-bottom: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.message-text:last-child {
    margin-bottom: 0;
}

/* Processing indicator */
.processing-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #a1a1aa;
    font-style: italic;
    padding: 0.5rem 0;
}

.processing-message i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Data Table */
.data-table {
    background: #1e1e2e;
    border: 1px solid #374151;
    border-radius: 8px;
    overflow: hidden;
    margin: 0.75rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    overflow-x: auto;
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 300px;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #374151;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 200px;
}

.data-table th {
    background: #2d2d44;
    font-weight: 600;
    color: #e5e5e5;
    font-size: 0.875rem;
}

.data-table td {
    color: #a1a1aa;
    font-size: 0.875rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Input Container */
.input-container {
    padding: 1.5rem;
    background: #1a1a1a;
    border-top: 1px solid #374151;
}

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

#messageInput {
    flex: 1;
    border: 2px solid #374151;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
    background: #2d2d44;
    color: #e5e5e5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#messageInput:focus {
    outline: none;
    border-color: #4f46e5;
}

#messageInput::placeholder {
    color: #a1a1aa;
}

.send-button {
    width: 44px;
    height: 44px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.send-button:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-footer {
    margin-top: 0.5rem;
    text-align: center;
}

.input-hint {
    font-size: 0.75rem;
    color: #6b7280;
}


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

.modal.show {
    display: flex;
}

.modal-content {
    background: #1e1e2e;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid #374151;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #374151;
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ef4444;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #a1a1aa;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
    color: #e5e5e5;
    word-wrap: break-word;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #374151;
    text-align: right;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        height: 100vh;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .header-left {
        gap: 0.5rem;
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .input-container {
        padding: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .welcome-content h2 {
        font-size: 1.5rem;
    }
    
    .welcome-content i {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        left: -100%;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .subtitle {
        font-size: 0.75rem;
    }
    
    .message-content {
        max-width: 90%;
    }
}

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

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #4f46e5;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4338ca;
}

/* Animation for new messages */
.message {
    animation: slideIn 0.3s ease-out;
}

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

/* Ensure all text wraps properly */
* {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Specific fixes for long text */
pre, code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Table responsive fixes */
.data-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.data-table table {
    width: 100%;
    min-width: 100%;
}

.data-table th,
.data-table td {
    white-space: normal;
    word-wrap: break-word;
    max-width: none;
}