/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #a855f7;
    --dark-color: #1e1b4b;
    --light-color: #f8fafc;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --census-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --aptos-green: #00d4aa;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
    --shadow-2xl: 0 25px 50px rgba(0,0,0,0.25);
}

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

body {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Chat App Container */
.chat-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Bar */
.header-bar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    width: 50px;
    height: 50px;
    background: var(--census-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.5rem;
    box-shadow: var(--shadow-md);
}

.brand-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.2rem;
}

.brand-info span {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: 500;
}

.status-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.aptos-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--aptos-green);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.live-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--success-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Main Chat Interface */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 2rem;
}

/* Welcome Section */
.welcome-section {
    padding: 3rem 0;
    text-align: center;
}

.welcome-content {
    max-width: 800px;
    margin: 0 auto;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--census-gradient);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 2.5rem;
    margin: 0 auto 2rem;
    box-shadow: var(--shadow-lg);
}

.welcome-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.welcome-content p {
    font-size: 1.2rem;
    color: var(--gray-700);
    margin-bottom: 3rem;
    line-height: 1.7;
}

.data-highlights {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.highlight-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
}

.highlight-item:hover {
    transform: translateY(-2px);
}

.highlight-icon {
    width: 60px;
    height: 60px;
    background: var(--census-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.5rem;
}

.highlight-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Fira Code', monospace;
}

.highlight-label {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* Messages Area */
.messages-area {
    flex: 1;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
}

.message-group {
    margin-bottom: 2rem;
}

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--census-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.message-bubble {
    background: var(--gray-50);
    border-radius: 20px;
    padding: 1.5rem;
    flex: 1;
    box-shadow: var(--shadow-sm);
}

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

.sender-name {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 1.1rem;
}

.verification-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--aptos-green);
    color: var(--white);
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.message-content p {
    margin: 0 0 1rem 0;
    line-height: 1.6;
    color: var(--gray-700);
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.service-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--white);
    border-radius: 10px;
    transition: all 0.2s ease;
    border: 1px solid var(--gray-200);
}

.service-item:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateX(5px);
    border-color: var(--primary-color);
}

.service-item i {
    color: var(--primary-color);
    font-size: 1.1rem;
    width: 20px;
}

.service-item:hover i {
    color: var(--white);
}

.service-item span {
    font-weight: 500;
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 1rem;
    display: block;
}

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

.user-message .message-bubble {
    background: var(--census-gradient);
    color: var(--white);
}

.user-message .message-avatar {
    background: var(--gray-400);
}

/* Quick Queries */
.quick-queries {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.queries-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    font-size: 1.1rem;
}

.queries-header i {
    color: var(--warning-color);
    font-size: 1.2rem;
}

.queries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.query-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: var(--gray-700);
}

.query-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.query-btn i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.query-btn:hover i {
    color: var(--white);
}

/* Chat Input Section */
.chat-input-section {
    background: var(--white);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.input-container {
    max-width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--gray-50);
    border: 2px solid var(--gray-300);
    border-radius: 25px;
    padding: 1rem 1.5rem;
    gap: 1rem;
    transition: all 0.2s ease;
    margin-bottom: 1rem;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--white);
}

.input-icon {
    color: var(--gray-500);
    font-size: 1.2rem;
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    color: var(--gray-900);
}

.input-wrapper input::placeholder {
    color: var(--gray-500);
}

.send-button {
    width: 45px;
    height: 45px;
    background: var(--census-gradient);
    border: none;
    border-radius: 50%;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

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

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.input-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.data-source {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.data-source i {
    color: var(--aptos-green);
}

.input-tips {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-style: italic;
}

/* Verification Footer */
.verification-footer {
    background: var(--gray-900);
    color: var(--white);
    padding: 2rem;
    margin-top: auto;
}

.verification-content {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.verification-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.verification-item i {
    color: var(--aptos-green);
    font-size: 1.1rem;
}

.footer-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-400);
    border-top: 1px solid var(--gray-700);
    padding-top: 1rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-animation {
    text-align: center;
    color: var(--white);
}

.census-loader {
    margin-bottom: 1.5rem;
}

.loader-chart {
    display: flex;
    align-items: end;
    gap: 0.5rem;
    justify-content: center;
    height: 60px;
}

.chart-bar {
    width: 12px;
    background: var(--primary-color);
    border-radius: 6px;
    animation: chartBounce 1.5s ease-in-out infinite;
}

.bar-1 {
    height: 20px;
    animation-delay: 0s;
}

.bar-2 {
    height: 40px;
    animation-delay: 0.2s;
}

.bar-3 {
    height: 60px;
    animation-delay: 0.4s;
}

.bar-4 {
    height: 30px;
    animation-delay: 0.6s;
}

@keyframes chartBounce {
    0%, 100% {
        transform: scaleY(1);
        background: var(--primary-color);
    }
    50% {
        transform: scaleY(1.5);
        background: var(--aptos-green);
    }
}

.loading-animation p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-bar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .status-section {
        gap: 1rem;
    }
    
    .chat-main {
        padding: 0 1rem;
    }
    
    .welcome-content h2 {
        font-size: 2rem;
    }
    
    .data-highlights {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .highlight-item {
        width: 100%;
        max-width: 300px;
    }
    
    .service-grid {
        grid-template-columns: 1fr;
    }
    
    .queries-grid {
        grid-template-columns: 1fr;
    }
    
    .verification-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .input-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .brand-section {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .brand-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .welcome-content h2 {
        font-size: 1.8rem;
    }
    
    .welcome-content p {
        font-size: 1rem;
    }
    
    .highlight-item {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }
    
    .highlight-icon {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .messages-area {
        padding: 1rem;
    }
    
    .quick-queries {
        padding: 1rem;
    }
    
    .chat-input-section {
        padding: 1rem;
    }
    
    .input-wrapper {
        flex-direction: column;
        gap: 1rem;
        padding: 1.5rem;
        border-radius: 20px;
    }
    
    .send-button {
        width: 100%;
        border-radius: 25px;
        height: 45px;
    }
}
