/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header h1 {
    font-size: 2.8rem;
    margin-bottom: 15px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 20px;
}

/* Card Styles */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-xl);
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.card h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Upload Section */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 50px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover::before {
    opacity: 1;
}

.upload-area:hover {
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    border-style: solid;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.upload-area.drag-over .upload-icon {
    transform: scale(1.2);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.upload-hint {
    margin: 10px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-btn {
    display: inline-block;
    padding: 14px 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 15px 0 rgba(102, 126, 234, 0.4);
    position: relative;
    z-index: 1;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(102, 126, 234, 0.6);
}

.file-info {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.upload-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    display: none;
}

.upload-status.success {
    display: block;
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.upload-status.error {
    display: block;
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid var(--danger-color);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--gradient-1);
    color: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.stat-card.green {
    background: var(--gradient-4);
}

.stat-card.blue {
    background: var(--gradient-3);
}

.stat-card.purple {
    background: var(--gradient-1);
}

.stat-card.danger {
    background: var(--gradient-2);
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Tabs */
.analysis-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--text-primary);
}

.data-table tr:hover {
    background-color: #f8fafc;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px 0 rgba(102, 126, 234, 0.4);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px 0 rgba(102, 126, 234, 0.6);
}

.btn-primary:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

/* Chat Section */
.chat-section {
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.chat-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8fafc;
    border-radius: 8px;
    margin-bottom: 20px;
    max-height: 500px;
}

.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    border-radius: 50%;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
}

.message-content {
    flex: 1;
    background-color: white;
    padding: 20px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    line-height: 1.7;
    font-size: 0.95rem;
}

.message-content p {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Markdown-style formatting in chat */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.message-content h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.message-content h3 {
    font-size: 1.15rem;
    color: #4f46e5;
}

.message-content h4 {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 28px;
}

.message-content li {
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.6;
}

.message-content strong,
.message-content b {
    font-weight: 700;
    color: var(--text-primary);
}

.message-content em,
.message-content i {
    font-style: italic;
    color: var(--text-secondary);
}

.message-content code {
    background-color: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #e11d48;
}

.message-content pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.message-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.message-content a:hover {
    border-bottom-color: var(--primary-color);
}

.message-content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 20px 0;
}

/* Numbered sections styling */
.message-content h3::before {
    content: '▸ ';
    color: var(--primary-color);
    font-weight: 900;
}

/* Better spacing for lists inside message */
.message-content ul ul,
.message-content ol ol {
    margin-top: 8px;
    margin-bottom: 8px;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    align-self: flex-end;
}

/* Chat Suggestions */
.chat-suggestions {
    margin-top: 15px;
}

.suggestions-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.suggestion-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 2px solid transparent;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.suggestion-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Recommendations */
.recommendations-content {
    line-height: 1.8;
}

.recommendations-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.recommendations-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.recommendations-content li {
    margin-bottom: 8px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 1.1rem;
}

/* Risk Badges */
.risk-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.risk-badge.low {
    background-color: #d1fae5;
    color: #065f46;
}

.risk-badge.medium {
    background-color: #fef3c7;
    color: #92400e;
}

.risk-badge.high {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .chat-section {
        position: relative;
        height: auto;
    }
    
    .chat-messages {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .analysis-tabs {
        overflow-x: auto;
    }
    
    .tab-btn {
        white-space: nowrap;
    }
}

/* Scrollbar Styles */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Alert Styles */
.alert {
    padding: 20px 30px;
    border-radius: 16px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
    border: 2px solid;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

.alert h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.alert ol {
    margin: 15px 0;
    padding-left: 20px;
}

.alert ol li {
    margin: 8px 0;
}

.alert code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.alert a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.alert a:hover {
    text-decoration: underline;
}

/* AI Recommendations Styling */
.ai-recommendations {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 24px;
    border-radius: 12px;
    margin-top: 15px;
    line-height: 1.8;
    font-size: 0.95rem;
}

.ai-recommendations h2,
.ai-recommendations h3,
.ai-recommendations h4 {
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 700;
}

.ai-recommendations h2 {
    font-size: 1.4rem;
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 8px;
    margin-top: 32px;
}

.ai-recommendations h3 {
    font-size: 1.2rem;
    color: #4f46e5;
}

.ai-recommendations h3::before {
    content: '▸ ';
    color: var(--primary-color);
    font-weight: 900;
}

.ai-recommendations h4 {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.ai-recommendations ul,
.ai-recommendations ol {
    margin: 12px 0 16px 0;
    padding-left: 32px;
}

.ai-recommendations li {
    margin-bottom: 10px;
    line-height: 1.7;
}

.ai-recommendations strong {
    color: var(--primary-color);
    font-weight: 700;
}

.ai-recommendations p {
    margin-bottom: 14px;
    color: var(--text-primary);
}

.ai-recommendations em {
    font-style: italic;
    color: var(--text-secondary);
}

.ai-recommendations code {
    background: rgba(79, 70, 229, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--primary-color);
    font-weight: 600;
}

