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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #F1F1F8;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* ============= AUTH MODAL ============= */

.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #001756 0%, #002a7a 50%, #001756 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    overflow: hidden;
}

.auth-modal::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    top: -200px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.auth-modal::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    bottom: -150px;
    left: -100px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(30px, 30px) scale(1.1);
    }
}

.auth-modal-content {
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 440px;
    width: 90%;
    overflow: hidden;
    animation: slideUp 0.4s ease-out;
    position: relative;
    z-index: 1;
}

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

.auth-header {
    text-align: center;
    padding: 48px 40px 32px;
    background: #001756;
    color: white;
    border-radius: 24px 24px 0 0;
}

.auth-logo {
    width: 100%;
    height: 50px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo img {
    height: 100%;
    max-width: 180px;
    width: auto;
    object-fit: contain;
}

.auth-subtitle {
    font-size: 15px;
    opacity: 0.95;
    margin: 0;
}

.auth-body {
    padding: 40px;
}

.auth-btn {
    width: 100%;
    padding: 16px 24px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    border: none;
}

.auth-btn.primary {
    background: #001756;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 23, 86, 0.4);
}

.auth-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 23, 86, 0.5);
    background: #002a7a;
}

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

.auth-btn.secondary:hover {
    background: #F1F1F8;
    border-color: #001756;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: #9ca3af;
    font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.auth-divider span {
    padding: 0 16px;
}

.auth-footer {
    text-align: center;
    padding: 24px 40px 32px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 24px 24px;
}

.auth-footer p {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}

/* ============= ACCESS DENIED ============= */

.access-denied {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #F1F1F8;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.access-denied-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 480px;
    width: 90%;
    padding: 48px 40px;
    text-align: center;
    animation: slideUp 0.4s ease-out;
}

.denied-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: #fee2e2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc2626;
}

.access-denied-content h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 12px;
    color: #1f2937;
}

.access-denied-content p {
    font-size: 15px;
    color: #6b7280;
    margin: 0 0 8px;
}

.denied-subtitle {
    font-weight: 500;
    color: #374151;
    margin-bottom: 32px !important;
}

.denied-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 32px 0 24px;
}

.btn-demo {
    padding: 14px 28px;
    background: #001756;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-demo:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 23, 86, 0.4);
    background: #002a7a;
}

.btn-retry {
    padding: 12px 24px;
    background: white;
    color: #001756;
    border: 2px solid #001756;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-retry:hover {
    background: #F1F1F8;
    border-color: #001756;
}

.denied-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.denied-footer p {
    font-size: 13px;
    color: #9ca3af;
}

.denied-footer a {
    color: #001756;
    text-decoration: none;
    font-weight: 600;
}

.denied-footer a:hover {
    text-decoration: underline;
}

/* ============= MAIN APP (CHATGPT STYLE) ============= */

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: #001756;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
    padding: 12px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    margin-bottom: 8px;
}

.sidebar-logo img {
    height: 24px;
    width: auto;
}

.new-conversation-btn {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.conversations-list::-webkit-scrollbar {
    width: 6px;
}

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

.conversations-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

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

.conversation-item {
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid transparent;
}

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

.conversation-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 500;
}

.conversation-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-actions {
    display: none;
    gap: 4px;
}

.conversation-item:hover .conversation-actions {
    display: flex;
}

.conversation-btn {
    padding: 4px 8px;
    background: transparent;
    color: #ececf1;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

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

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

.user-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-email {
    color: #ececf1;
    font-size: 13px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    color: #ececf1;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #F1F1F8;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(0, 23, 86, 0.1);
    background: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-btn {
    display: none !important; /* Hidden on desktop - force override */
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #001756;
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important; /* Ensure hidden on desktop and larger screens */
    }
}

.chat-header-logo {
    height: 20px;
    width: auto;
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #001756;
    margin: 0;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.6;
}

.message.user .message-content {
    background: #001756;
    color: white;
}

.message.assistant .message-content {
    background: #f3f4f6;
    color: #1f2937;
    white-space: pre-wrap; /* Preserve line breaks */
}

.message.assistant ul {
    margin: 10px 0;
    padding-left: 20px;
}

.message.assistant li {
    margin: 5px 0;
}

/* Better formatting for assistant messages with spacing */
.message.assistant .message-content br {
    line-height: 1.8;
}

.message.assistant .message-content strong {
    font-weight: 600;
    color: #111827;
}

/* Data Display */
/* Data table section header */
.data-header {
    margin: 16px 0 8px 0;
    padding: 8px 12px;
    background: linear-gradient(135deg, #A39AEA 0%, #001756 100%);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s ease;
}

.data-header:hover {
    opacity: 0.9;
}

.data-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: normal;
    margin-right: 6px;
}

.toggle-icon {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.data-container {
    margin: 0 0 10px 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: auto;
    max-width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-height: 500px;
    min-height: 300px;
    background: white;
}

.data-container table {
    display: table !important;
    width: 100%;
    table-layout: auto;
}

.data-container th,
.data-container td {
    display: table-cell !important;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    color: #1f2937;
}

tbody tr:hover {
    background-color: #f9fafb;
    transition: background-color 0.15s ease;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Download Buttons */
.download-buttons {
    display: flex;
    gap: 10px;
    margin: 12px 0 16px 0;
    padding: 0;
}

.download-btn {
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    gap: 6px;
}

.download-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
}

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

/* SQL Details */
.sql-details {
    margin: 10px 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.sql-details summary {
    background: #f9fafb;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
}

.sql-details pre {
    margin: 0;
    padding: 12px;
    background: #1f2937;
    color: #f9fafb;
    overflow-x: auto;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

/* Input Container */
.input-container {
    display: flex;
    padding: 16px 24px;
    gap: 12px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

#question-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #F0F0F0;
}

#question-input:focus {
    border-color: #001756;
    background: white;
}

#send-btn {
    padding: 12px 16px;
    background: #001756;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:hover:not(:disabled) {
    background: #002a7a;
}

#send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #001756;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    padding: 40px;
    text-align: center;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #6b7280;
}

.empty-state p {
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex !important; /* Show on mobile only */
    }
    
    .sidebar {
        position: absolute;
        left: -260px;
        z-index: 100;
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .auth-modal-content,
    .access-denied-content {
        margin: 20px;
    }
}
