/* Modern CSS Variables */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
    --gradient-main: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.25rem;
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* File Upload */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: rgba(30, 41, 59, 0.3);
    cursor: pointer;
    margin-bottom: 1.5rem;
    position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.file-status {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--success);
    display: none;
    font-size: 1rem;
}

.btn {
    display: inline-block;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--gradient-main);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.4);
    opacity: 0.9;
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--border);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 0.375rem;
}

.btn-full {
    width: 100%;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Results Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Table Styling */
.table-container {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    padding: 1rem;
    margin-top: 2rem;
}

table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
    color: var(--text-main);
}

table.dataTable thead th {
    background: var(--bg-dark);
    color: var(--text-muted);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

table.dataTable tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

table.dataTable tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* DataTables Overrides */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-muted) !important;
    margin: 1rem 0;
}

.dataTables_wrapper .dataTables_filter input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 0.25rem;
}

/* Sample Data Box */
.sample-data {
    background: #000;
    color: #0f0;
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: monospace;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2rem;
    border: 1px solid var(--border);
}

/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 450px;
    height: 650px;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 2rem;
    display: none;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-header {
    padding: 1.5rem;
    background: var(--gradient-main);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: rgba(15, 23, 42, 0.2);
}

.message {
    max-width: 80%;
    padding: 1rem 1.5rem;
    border-radius: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.message.ai {
    align-self: flex-start;
    background: #e9e9eb;
    color: #000;
    border-bottom-left-radius: 0.5rem;
}

/* iMessage style tails */
.message.ai::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: -7px;
    width: 20px;
    height: 20px;
    background: #e9e9eb;
    border-bottom-right-radius: 15px 14px;
    z-index: -1;
}

.message.ai::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: -10px;
    width: 10px;
    height: 20px;
    background: var(--bg-card);
    border-bottom-right-radius: 10px;
    z-index: 0;
}

.message.user {
    align-self: flex-end;
    background: #007aff;
    color: white;
    border-bottom-right-radius: 0.5rem;
}

.message.user::before {
    content: "";
    position: absolute;
    bottom: 0;
    right: -7px;
    width: 20px;
    height: 20px;
    background: #007aff;
    border-bottom-left-radius: 15px 14px;
    z-index: -1;
}

.message.user::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: -10px;
    width: 10px;
    height: 20px;
    background: var(--bg-card);
    border-bottom-left-radius: 10px;
    z-index: 0;
}

.chat-input-area {
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 2rem;
    outline: none;
    transition: all 0.2s;
    font-size: 1rem;
}

.chat-input-area input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.chat-input-area button {
    background: #007aff;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 2rem;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 122, 255, 0.3);
}

.chat-input-area button:hover {
    background: #0063cc;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 122, 255, 0.4);
}

.chat-trigger-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--gradient-main);
    color: white;
    border: none;
    padding: 1.25rem 2.5rem;
    border-radius: 4rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 15px 25px -5px rgba(99, 102, 241, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 999;
}

.chat-trigger-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 25px 35px -5px rgba(99, 102, 241, 0.6);
}

.chat-trigger-btn span {
    font-size: 1.5rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #8e8e93;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-8px);
    }
}

@media (max-width: 480px) {
    .chat-widget {
        width: calc(100% - 2rem);
        height: calc(100% - 4rem);
        bottom: 1rem;
        right: 1rem;
    }

    .chat-trigger-btn {
        padding: 1rem 2rem;
        font-size: 1rem;
    }
}