/* ══════════════════════════════════
   AI SECURITY AUDITOR WIDGET v5.0
   Design: Regenerative Canvas 2.0 (Glassmorphism Edition)
   ══════════════════════════════════ */

:root {
    --ai-primary: #1a3cff;
    --ai-accent: #00f2ff;
    --ai-bg: rgba(10, 22, 40, 0.85); /* Increased transparency for better glass effect */
    --ai-text: #ffffff;
    --ai-border: rgba(255, 255, 255, 0.12);
    --ai-font: 'Inter', system-ui, -apple-system, sans-serif;
    --ai-heading-font: 'Poppins', sans-serif;
}

.ai-auditor-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 10001;
    font-family: var(--ai-font);
}

/* Floating Bubble */
.ai-bubble {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--ai-primary) 0%, #3b82f6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 35px rgba(26, 60, 255, 0.35);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.ai-bubble:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 45px rgba(26, 60, 255, 0.5);
}

.ai-bubble svg {
    color: white;
    width: 28px;
    height: 28px;
}

.ai-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    border: 2px solid #0a1628;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Chat Window */
.ai-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 420px;
    height: 650px;
    max-height: calc(90vh - 120px);

    background: var(--ai-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--ai-border);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
    transform: translateY(40px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.ai-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--ai-border);
}

.ai-header-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--ai-primary), #4f46e5);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(26, 60, 255, 0.3);
}

.ai-header-text h4 {
    margin: 0;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--ai-heading-font);
    letter-spacing: -0.01em;
}

.ai-header-text span {
    font-size: 0.8rem;
    color: var(--ai-accent);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-top: 2px;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background: var(--ai-accent);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--ai-accent);
    animation: pulse 2s infinite;
}

/* Chat Body */
.ai-chat-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.message {
    max-width: 90%;
    padding: 16px 20px;
    border-radius: 22px;
    font-size: 0.95rem;
    line-height: 1.65;
    animation: messageEntry 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.message.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    color: #f1f5f9;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ai-primary), #4f46e5);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 6px 20px rgba(26, 60, 255, 0.25);
}

/* Quick Actions */
.ai-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.qa-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.qa-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--ai-accent);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* Audit Results Card */
.audit-summary-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--ai-border);
    padding: 24px;
    border-radius: 20px;
    margin-top: 8px;
}

.audit-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.audit-url {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-badge {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-badge.success { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.score-badge.warning { background: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.score-badge.error { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

.findings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 15px;
}

.finding-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.finding-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.finding-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f1f5f9;
}

/* Progress Section */
.scan-container {
    padding: 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
}

.scan-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 10px;
    color: var(--ai-accent);
    font-weight: 600;
}

.scan-progress {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 18px;
}

.scan-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ai-primary), var(--ai-accent));
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

/* Chat Input */
.ai-input-area {
    padding: 24px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--ai-border);
}

.ai-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 14px 20px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-input:focus {
    border-color: var(--ai-accent);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(0, 242, 255, 0.1);
}

.ai-send-btn {
    background: linear-gradient(135deg, var(--ai-primary), #4f46e5);
    color: white;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(26, 60, 255, 0.3);
}

.ai-send-btn:hover {
    transform: scale(1.05) rotate(-5deg);
    box-shadow: 0 8px 25px rgba(26, 60, 255, 0.5);
}

/* PDF Download Button */
.btn-download-pdf {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1a3cff 100%);
    color: white;
    padding: 16px;
    border-radius: 18px;
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 24px;
    box-shadow: 0 10px 30px rgba(29, 78, 216, 0.4);
    border: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    justify-content: center;
    font-family: var(--ai-heading-font);
}

.btn-download-pdf:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(29, 78, 216, 0.6);
    filter: brightness(1.1);
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; box-shadow: 0 0 10px var(--ai-accent); }
    50% { transform: scale(1.3); opacity: 0.7; box-shadow: 0 0 25px var(--ai-accent); }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 10px var(--ai-accent); }
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .ai-window {
        width: calc(100vw - 30px);
        height: 70vh;
        bottom: 80px;
        right: -15px;
    }
}

/* Embedded Mode Fixes */
.ai-window.embedded {
    position: static;
    width: 100%;
    height: 550px;
    max-height: 550px;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: transparent;
    backdrop-filter: none;
}

.embedded-audit-container {
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 40px rgba(0,0,0,0.08);
}
