/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    --bg-dark: #090d16;
    --bg-card: rgba(15, 23, 42, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --primary: #6366f1; /* Indigo 500 */
    --primary-hover: #4f46e5; /* Indigo 600 */
    --primary-glow: rgba(99, 102, 241, 0.35);
    
    --secondary: #1e293b;
    --secondary-hover: #334155;
    
    /* Risk Levels */
    --risk-high: #ef4444;
    --risk-high-glow: rgba(239, 68, 68, 0.25);
    --risk-medium: #f97316;
    --risk-medium-glow: rgba(249, 115, 22, 0.25);
    --risk-low: #10b981;
    --risk-low-glow: rgba(16, 185, 129, 0.25);
    
    /* Text colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   BASE STYLES & LAYOUT
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Glowing Backgrounds */
.glow-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-1 {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
    top: -200px;
    left: -200px;
}

.glow-2 {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: -100px;
    right: -100px;
}

/* Navbar */
.navbar {
    border-bottom: 1px solid var(--border-color);
    background: rgba(9, 13, 22, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}

.brand-icon {
    color: var(--primary);
    font-size: 1.6rem;
    margin-right: 10px;
    filter: drop-shadow(0 0 8px var(--primary));
}

.nav-badge {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--risk-low);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-success {
    color: var(--risk-low);
}

/* Main Layout */
.main-content {
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(9, 13, 22, 0.9);
}

/* ==========================================================================
   GLASSMORPHIC CARDS
   ========================================================================== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
   UPLOAD PAGE (INDEX)
   ========================================================================== */
.upload-container {
    max-width: 760px;
    margin: 0 auto;
}

.hero-section {
    text-align: center;
    margin-bottom: 35px;
}

.hero-section h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 30%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: var(--transition-smooth);
    position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.04);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.drop-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    transition: var(--transition-smooth);
}

.drop-zone:hover .drop-icon {
    color: var(--primary);
    transform: translateY(-5px);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.drop-zone h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.browse-btn {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

.file-limits {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 10px;
}

.file-input {
    display: none;
}

/* Selected File Panel */
.selected-file-container {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-type-icon {
    font-size: 2.2rem;
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.remove-file-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.remove-file-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Accordion Advanced Configuration */
.settings-accordion {
    margin: 25px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.accordion-toggle {
    background: none;
    border: none;
    width: 100%;
    padding: 15px 0;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-smooth);
}

.accordion-toggle i {
    color: var(--text-secondary);
}

.chevron-icon {
    transition: var(--transition-smooth);
}

.accordion-toggle.active .chevron-icon {
    transform: rotate(180deg);
}

.accordion-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Tooltips */
.tooltip {
    position: relative;
    cursor: help;
    display: inline-block;
    color: var(--text-muted);
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 220px;
    background-color: #1e293b;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 10;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    font-weight: 400;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.form-group input[type="text"] {
    width: 100%;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Checkbox Custom styling */
.checkbox-group {
    margin-top: 15px;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    cursor: pointer;
    user-select: none;
    gap: 12px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    position: relative;
    transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
}

.checkbox-sublabel {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: 8px;
    padding: 14px;
    color: white;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
    filter: brightness(1.1);
}

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

/* Alert styles */
.alert {
    border-radius: 8px;
    padding: 16px;
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    animation: slideDown 0.3s ease-out;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.alert-icon {
    font-size: 1.4rem;
    margin-top: 2px;
}

.alert-body h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-body p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ==========================================================================
   RESULTS PAGE
   ========================================================================== */
.results-container {
    animation: fadeIn 0.4s ease-out;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
    flex-wrap: wrap;
    gap: 20px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    transition: var(--transition-smooth);
}

.back-link:hover {
    color: var(--primary);
    transform: translateX(-3px);
}

.results-header h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.file-name-meta {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.header-right {
    display: flex;
    gap: 12px;
}

.btn {
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Results Grid Structure (3 Columns on Desktop) */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1.1fr;
    gap: 30px;
    align-items: start;
}

.grid-left {
    display: flex;
    flex-direction: column;
    gap: 30px;
    grid-column: 1;
}

.summary-card {
    grid-column: 2;
}

.chat-card {
    grid-column: 3;
    height: 520px;
}

/* Tablet Layout (2 Columns) */
@media (max-width: 1150px) {
    .results-grid {
        grid-template-columns: 1.1fr 1.9fr;
        align-items: start;
    }
    .grid-left {
        grid-column: 1;
    }
    .summary-card {
        grid-column: 2;
    }
    .chat-card {
        grid-column: 2;
    }
}

/* Risk Card Borders & Glows */
.risk-card {
    border-width: 1px;
}

.risk-card.risk-high {
    border-color: rgba(239, 68, 68, 0.35);
    background: radial-gradient(circle at top left, rgba(239, 68, 68, 0.05), var(--bg-card));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 15px var(--risk-high-glow);
}

.risk-card.risk-medium {
    border-color: rgba(249, 115, 22, 0.35);
    background: radial-gradient(circle at top left, rgba(249, 115, 22, 0.05), var(--bg-card));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 15px var(--risk-medium-glow);
}

.risk-card.risk-low {
    border-color: rgba(16, 185, 129, 0.35);
    background: radial-gradient(circle at top left, rgba(16, 185, 129, 0.05), var(--bg-card));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 15px var(--risk-low-glow);
}

.risk-badge-wrapper {
    margin-bottom: 15px;
}

.risk-badge {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 6px 16px;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
}

.badge-high {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--risk-high);
    color: var(--risk-high);
}

.badge-medium {
    background: rgba(249, 115, 22, 0.15);
    border: 1px solid var(--risk-medium);
    color: var(--risk-medium);
}

.badge-low {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--risk-low);
    color: var(--risk-low);
}

.risk-reasons h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.risk-reasons ul {
    list-style-type: none;
}

.risk-reasons li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.risk-reasons li::before {
    content: "•";
    position: absolute;
    left: 5px;
    color: var(--primary);
}

/* Findings Card */
.findings-card h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary);
    padding-left: 10px;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.findings-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.findings-table th {
    background: #0f172a;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.findings-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.findings-table tr:hover {
    background: rgba(255,255,255,0.015);
}

/* PII Type Badge color themes */
.pii-type-label {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}

.label-aadhaar { background: rgba(225, 29, 72, 0.1); border-color: rgba(225, 29, 72, 0.2); color: #f43f5e; }
.label-pan { background: rgba(217, 70, 239, 0.1); border-color: rgba(217, 70, 239, 0.2); color: #e879f9; }
.label-email { background: rgba(14, 165, 233, 0.1); border-color: rgba(14, 165, 233, 0.2); color: #38bdf8; }
.label-phone { background: rgba(234, 179, 8, 0.1); border-color: rgba(234, 179, 8, 0.2); color: #facc15; }
.label-credit-card { background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); color: #fb7185; }
.label-bank-account { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); color: #34d399; }
.label-ifsc { background: rgba(45, 212, 191, 0.1); border-color: rgba(45, 212, 191, 0.2); color: #2dd4bf; }
.label-api-key { background: rgba(168, 85, 247, 0.1); border-color: rgba(168, 85, 247, 0.2); color: #c084fc; }
.label-password { background: rgba(244, 63, 94, 0.15); border-color: rgba(244, 63, 94, 0.25); color: #fda4af; }
.label-employee-id { background: rgba(249, 115, 22, 0.1); border-color: rgba(249, 115, 22, 0.2); color: #ffedd5; }
.label-confidential-term { background: rgba(225, 29, 72, 0.15); border-color: rgba(225, 29, 72, 0.25); color: #fda4af; }
.label-organization { background: rgba(99, 102, 241, 0.1); border-color: rgba(99, 102, 241, 0.2); color: #818cf8; }
.label-money { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.2); color: #4ade80; }

.match-count-cell {
    font-weight: 600;
}

.masked-val-cell code {
    background: #090d16;
    border: 1px solid var(--border-color);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    color: rgba(255,255,255,0.05);
}

/* Right Column Panels */
.summary-card {
    border-color: rgba(255, 255, 255, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-mode-badge, .opt-in-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
}

.mode-llm { background: rgba(99, 102, 241, 0.12); border: 1px solid var(--primary); color: #818cf8; }
.mode-heuristic { background: rgba(148, 163, 184, 0.1); border: 1px solid var(--text-muted); color: var(--text-secondary); }

.opt-in-active { background: rgba(249, 115, 22, 0.1); border: 1px solid var(--risk-medium); color: var(--risk-medium); }
.opt-in-inactive { background: rgba(16, 185, 129, 0.1); border: 1px solid var(--risk-low); color: var(--risk-low); }

/* Markdown Styles in Summary */
.markdown-body h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-top: 22px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 4px;
}

.markdown-body h3:first-of-type {
    margin-top: 0;
}

.markdown-body p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.markdown-body ul {
    margin-left: 20px;
    margin-bottom: 16px;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.markdown-body li {
    margin-bottom: 6px;
}

/* ==========================================================================
   CHAT ASSISTANT PANEL
   ========================================================================== */
.chat-card {
    height: 520px;
    display: flex;
    flex-direction: column;
    padding: 24px 0 0 0; /* Adjust padding to expand chat area */
}

.chat-card .card-header {
    margin-left: 24px;
    margin-right: 24px;
    margin-bottom: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 85%;
    animation: bubbleUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1e293b;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.user-message .msg-avatar {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

.msg-bubble {
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.92rem;
}

.user-message .msg-bubble {
    background: var(--primary);
    color: white;
    border-top-right-radius: 0;
}

.assistant-message .msg-bubble {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-top-left-radius: 0;
}

.msg-bubble p {
    margin-bottom: 8px;
}
.msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-bubble ul {
    margin-left: 18px;
    margin-top: 4px;
}
.msg-bubble li {
    margin-bottom: 4px;
}

/* Quick Queries inside Welcome Message */
.quick-queries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-query-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 50px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.quick-query-btn:hover {
    background: var(--primary);
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
}

/* Chat Input Bar */
.chat-input-area {
    border-top: 1px solid var(--border-color);
    background: rgba(9, 13, 22, 0.4);
    padding: 15px 24px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

.chat-input-area input {
    flex: 1;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: white;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    transition: var(--transition-smooth);
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--primary);
}

.send-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.05rem;
    transition: var(--transition-smooth);
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.03);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Typing Dots Animation */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 6px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typeBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ==========================================================================
   ANIMATIONS & EFFECTS
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bubbleUp {
    from { opacity: 0; transform: scale(0.95) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes typeBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Double Bounce Spinner for Upload overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 13, 22, 0.92);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease-out;
}

.loading-overlay h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 25px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 40%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
    max-width: 450px;
}

.loading-spinner-container {
    width: 60px;
    height: 60px;
    position: relative;
}

.double-bounce1, .double-bounce2 {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--primary);
    opacity: 0.6;
    position: absolute;
    top: 0;
    left: 0;
    animation: sk-bounce 2.0s infinite ease-in-out;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.double-bounce2 {
    animation-delay: -1.0s;
}

@keyframes sk-bounce {
    0%, 100% { transform: scale(0.0); }
    50% { transform: scale(1.0); }
}

/* ==========================================================================
   ENHANCED UI COMPONENT EXTENSIONS
   ========================================================================== */

/* 1. Checklist in the upload page loading overlay */
.scanning-checklist {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 480px;
    width: 100%;
    text-align: left;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    font-size: 0.92rem;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
}

.check-item.pending {
    color: var(--text-muted);
}

.check-item.active {
    color: var(--primary);
    font-weight: 500;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.check-item.completed {
    color: var(--risk-low);
}

/* 2. Circular Risk Gauge styling */
.gauge-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.gauge {
    position: relative;
    width: 200px;
    height: 100px;
    overflow: hidden;
}

.gauge-body {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    border-radius: 50%;
    background: #1e293b;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    border-radius: 50%;
    transform-origin: center top;
    transform: rotate(0.5turn);
    transition: transform 0.5s ease-out;
}

.fill-low {
    background: linear-gradient(to right, var(--risk-low), #34d399);
    transform: rotate(0.58turn); /* Rotate needle 15% range */
}

.fill-medium {
    background: linear-gradient(to right, var(--risk-low) 0%, var(--risk-medium) 100%);
    transform: rotate(0.75turn); /* Rotate needle 50% range */
}

.fill-high {
    background: linear-gradient(to right, var(--risk-low) 0%, var(--risk-medium) 50%, var(--risk-high) 100%);
    transform: rotate(0.92turn); /* Rotate needle 85% range */
}

.gauge-cover {
    position: absolute;
    width: 75%;
    height: 150%;
    background: var(--bg-dark);
    border-radius: 50%;
    top: 25%;
    left: 12.5%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-needle {
    position: absolute;
    width: 4px;
    height: 90px;
    background: #f8fafc;
    border-radius: 4px;
    bottom: 0;
    left: calc(50% - 2px);
    transform-origin: center bottom;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.needle-low {
    transform: rotate(-60deg);
}

.needle-medium {
    transform: rotate(0deg);
}

.needle-high {
    transform: rotate(60deg);
}

.gauge-badge {
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.95rem;
    padding: 6px 16px;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* 3. Tab Switcher styling */
.header-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0 !important;
}

.tab-buttons {
    display: flex;
    gap: 20px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.05rem;
    padding: 15px 0;
    cursor: pointer;
    position: relative;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.tab-content {
    animation: fadeIn 0.3s ease-out;
}

/* 4. Redacted Text Preview styling */
.redacted-preview-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.preview-info-banner {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-text-wrapper {
    background: #090d16;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.redacted-text-box {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* 5. Density Bars styling */
.match-count-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 80px;
}

.match-count-value {
    font-weight: 700;
    font-size: 0.95rem;
}

.density-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    overflow: hidden;
}

.density-bar {
    height: 100%;
    border-radius: 20px;
}

.density-bar.bar-aadhaar { background-color: #f43f5e; }
.density-bar.bar-pan { background-color: #e879f9; }
.density-bar.bar-email { background-color: #38bdf8; }
.density-bar.bar-phone { background-color: #facc15; }
.density-bar.bar-credit-card { background-color: #fb7185; }
.density-bar.bar-bank-account { background-color: #34d399; }
.density-bar.bar-ifsc { background-color: #2dd4bf; }
.density-bar.bar-api-key { background-color: #c084fc; }
.density-bar.bar-password { background-color: #fda4af; }
.density-bar.bar-employee-id { background-color: #ffedd5; }
.density-bar.bar-confidential-term { background-color: #fda4af; }
.density-bar.bar-organization { background-color: #818cf8; }
.density-bar.bar-money { background-color: #4ade80; }

/* Export Format Selector Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 13, 22, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease-out;
}

.modal-content {
    max-width: 480px;
    width: 90%;
    padding: 30px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    margin: 0;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    line-height: 1;
}

.close-modal-btn:hover {
    color: var(--risk-high);
}

.modal-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modal-action-btn {
    text-decoration: none;
    justify-content: center;
}

.modal-cancel-btn {
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
}

.modal-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

@keyframes scaleUp {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 860px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    .navbar .nav-badge {
        display: none; /* Hide badge on very narrow screens */
    }
}

@media (max-width: 600px) {
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    .hero-section h1 {
        font-size: 1.8rem;
    }
}
