/* ============================================================
   Academic AI Research Assistant - التصميم الاحترافي v2.0
   Glassmorphism + Neon Glow + Animations
   ============================================================ */

:root {
    --aaia-primary: #7c3aed;
    --aaia-primary-dark: #6d28d9;
    --aaia-primary-light: #a78bfa;
    --aaia-secondary: #fbbf24;
    --aaia-secondary-dark: #f59e0b;
    --aaia-bg: #0f1322;
    --aaia-card-bg: rgba(30, 41, 59, 0.85);
    --aaia-card-border: rgba(124, 58, 237, 0.15);
    --aaia-text: #ffffff;
    --aaia-muted: #8892a4;
    --aaia-radius: 14px;
    --aaia-radius-sm: 8px;
    --aaia-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --aaia-glow: 0 0 30px rgba(124, 58, 237, 0.15);
    --aaia-glow-strong: 0 0 40px rgba(124, 58, 237, 0.3);
    --aaia-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- RESET & BASE ---- */
.aaia-dashboard-wrap *,
.aaia-dashboard-wrap *::before,
.aaia-dashboard-wrap *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.aaia-dashboard-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Arabic', sans-serif;
    background: linear-gradient(160deg, var(--aaia-bg) 0%, #162033 50%, #1a1040 100%);
    color: var(--aaia-text);
    border-radius: var(--aaia-radius);
    overflow: hidden;
    margin: 28px auto;
    direction: rtl;
    line-height: 1.7;
    max-width: 1200px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(124, 58, 237, 0.05);
    position: relative;
}

/* إضاءة خلفية متوهجة */
.aaia-dashboard-wrap::before {
    content: '';
    position: absolute;
    top: -200px;
    right: -200px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.aaia-dashboard-wrap::after {
    content: '';
    position: absolute;
    bottom: -200px;
    left: -200px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ---- TYPOGRAPHY (3 sizes only) ---- */
.aaia-text-sm { font-size: 13px; line-height: 1.6; }
.aaia-text-md { font-size: 15px; line-height: 1.7; }
.aaia-text-lg { font-size: 20px; line-height: 1.5; }

/* ---- HEADER ---- */
.aaia-dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, transparent 50%, rgba(251, 191, 36, 0.04) 100%);
    border-bottom: 1px solid rgba(124, 58, 237, 0.1);
    position: relative;
    z-index: 1;
}

.aaia-header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.aaia-logo-icon {
    color: var(--aaia-primary);
    display: flex;
    align-items: center;
    filter: drop-shadow(0 0 12px rgba(124, 58, 237, 0.4));
    animation: aaiaPulse 3s ease-in-out infinite;
}

@keyframes aaiaPulse {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(124, 58, 237, 0.6)); }
}

.aaia-title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--aaia-primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.aaia-subtitle {
    font-size: 13px;
    color: var(--aaia-muted);
    margin-top: 2px;
    -webkit-text-fill-color: var(--aaia-muted);
}

.aaia-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.aaia-poster-img {
    max-height: 48px;
    border-radius: 10px;
    object-fit: contain;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ---- CREDIT DISPLAY ---- */
.aaia-credit-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(124, 58, 237, 0.06));
    padding: 10px 20px;
    border-radius: 24px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.08);
    transition: var(--aaia-transition);
}

.aaia-credit-display:hover {
    border-color: rgba(124, 58, 237, 0.4);
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.15);
}

.aaia-credit-icon {
    font-size: 16px;
    animation: aaiaSparkle 2s ease-in-out infinite;
}

@keyframes aaiaSparkle {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

.aaia-credit-count {
    font-size: 20px;
    font-weight: 800;
    color: var(--aaia-secondary);
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
    direction: ltr;
}

.aaia-credit-label {
    font-size: 12px;
    color: var(--aaia-muted);
    font-weight: 500;
}

/* ---- TAB NAVIGATION ---- */
.aaia-tabs-nav {
    display: flex;
    background: rgba(15, 19, 34, 0.6);
    border-bottom: 1px solid rgba(124, 58, 237, 0.08);
    padding: 4px 8px;
    gap: 4px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(12px);
}

.aaia-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 24px;
    background: transparent;
    border: none;
    color: var(--aaia-muted);
    cursor: pointer;
    transition: var(--aaia-transition);
    position: relative;
    font-family: inherit;
    flex: 1;
    border-radius: var(--aaia-radius-sm);
    overflow: hidden;
}

.aaia-tab-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(251, 191, 36, 0.04));
    opacity: 0;
    transition: var(--aaia-transition);
}

.aaia-tab-btn:hover {
    color: var(--aaia-text);
    background: rgba(124, 58, 237, 0.04);
}

.aaia-tab-btn:hover::before {
    opacity: 1;
}

.aaia-tab-btn.active {
    color: var(--aaia-primary);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(124, 58, 237, 0.04));
    box-shadow: inset 0 -2px 0 var(--aaia-primary), 0 4px 20px rgba(124, 58, 237, 0.1);
}

.aaia-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--aaia-primary);
    border-radius: 2px;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
}

.tab-icon {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.tab-label {
    font-size: 14px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.tab-subtitle {
    font-size: 10px;
    font-weight: 500;
    color: var(--aaia-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    position: relative;
    z-index: 1;
}

/* ---- TAB CONTENT ---- */
.aaia-tab-panel {
    display: none;
    padding: 32px;
    animation: aaiaFadeSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.aaia-tab-panel.active {
    display: block;
}

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

.aaia-tab-header {
    margin-bottom: 28px;
}

.aaia-tab-header h2 {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 60%, var(--aaia-primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.aaia-tab-desc {
    font-size: 14px;
    color: var(--aaia-muted);
    -webkit-text-fill-color: var(--aaia-muted);
    max-width: 600px;
}

/* ---- TAB STATISTICS ---- */
.aaia-tab-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.aaia-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--aaia-card-border);
    border-radius: 12px;
    padding: 14px 18px;
    transition: var(--aaia-transition);
    position: relative;
    overflow: hidden;
}

.aaia-stat-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.03), transparent);
    opacity: 0;
    transition: var(--aaia-transition);
}

.aaia-stat-item:hover {
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 20px rgba(124, 58, 237, 0.06);
}

.aaia-stat-item:hover::before {
    opacity: 1;
}

.aaia-stat-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.aaia-stat-number {
    font-size: 22px;
    font-weight: 800;
    color: var(--aaia-secondary);
    direction: ltr;
    text-shadow: 0 0 16px rgba(251, 191, 36, 0.15);
}

.aaia-stat-desc {
    font-size: 12px;
    color: var(--aaia-muted);
    margin-right: auto;
    font-weight: 500;
}

/* ---- INPUT GROUP ---- */
.aaia-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    align-items: center;
}

.aaia-search-box {
    flex: 1;
    position: relative;
}

.aaia-search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--aaia-muted);
    pointer-events: none;
    opacity: 0.6;
}

.aaia-input {
    width: 100%;
    padding: 14px 48px 14px 18px;
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.12);
    border-radius: 12px;
    color: var(--aaia-text);
    font-size: 15px;
    font-family: inherit;
    transition: var(--aaia-transition);
    outline: none;
}

.aaia-input:focus {
    border-color: var(--aaia-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12), 0 0 30px rgba(124, 58, 237, 0.06);
}

.aaia-input::placeholder {
    color: var(--aaia-muted);
    opacity: 0.5;
}

/* ---- BUTTONS ---- */
.aaia-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--aaia-transition);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.aaia-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: var(--aaia-transition);
}

.aaia-btn:hover::after {
    opacity: 1;
}

.aaia-btn-primary {
    background: linear-gradient(135deg, var(--aaia-primary), var(--aaia-primary-dark));
    color: #fff;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

.aaia-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.4);
}

.aaia-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.3);
}

.aaia-btn-secondary {
    background: rgba(124, 58, 237, 0.08);
    color: var(--aaia-primary-light);
    border: 1px solid rgba(124, 58, 237, 0.15);
    backdrop-filter: blur(8px);
}

.aaia-btn-secondary:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px);
}

.aaia-btn-outline {
    background: transparent;
    color: var(--aaia-primary-light);
    border: 1px solid rgba(124, 58, 237, 0.25);
    backdrop-filter: blur(8px);
}

.aaia-btn-outline:hover {
    background: rgba(124, 58, 237, 0.08);
    border-color: var(--aaia-primary);
    box-shadow: 0 0 24px rgba(124, 58, 237, 0.1);
    transform: translateY(-2px);
}

.aaia-btn-lg {
    padding: 14px 36px;
    font-size: 16px;
}

.aaia-btn-round {
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aaia-btn-icon-only {
    padding: 10px;
    background: var(--aaia-card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--aaia-radius-sm);
    color: var(--aaia-muted);
    cursor: pointer;
    transition: var(--aaia-transition);
    display: flex;
    align-items: center;
    position: absolute;
    top: 12px;
    left: 12px;
}

.aaia-btn-icon-only:hover {
    background: rgba(124, 58, 237, 0.1);
    color: var(--aaia-primary-light);
    border-color: rgba(124, 58, 237, 0.2);
    transform: scale(1.05);
}

/* ---- RESULTS / PLACEHOLDER ---- */
.aaia-results-area {
    min-height: 120px;
}

.aaia-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--aaia-muted);
    text-align: center;
}

.aaia-placeholder-icon {
    margin-bottom: 16px;
    opacity: 0.25;
}

.aaia-placeholder p {
    font-size: 14px;
    opacity: 0.6;
}

/* ---- PAPER CARDS (Literature Review Matrix) ---- */
.aaia-matrix-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.aaia-paper-card {
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 14px;
    padding: 24px;
    transition: var(--aaia-transition);
    position: relative;
    overflow: hidden;
}

.aaia-paper-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--aaia-primary), transparent);
    opacity: 0;
    transition: var(--aaia-transition);
}

.aaia-paper-card:hover {
    border-color: rgba(124, 58, 237, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 24px rgba(124, 58, 237, 0.04);
    transform: translateY(-2px);
}

.aaia-paper-card:hover::before {
    opacity: 1;
}

.aaia-paper-header {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.aaia-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.aaia-badge-year {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(124, 58, 237, 0.06));
    color: var(--aaia-primary-light);
    border: 1px solid rgba(124, 58, 237, 0.1);
}

.aaia-badge-authors {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(251, 191, 36, 0.04));
    color: var(--aaia-secondary);
    border: 1px solid rgba(251, 191, 36, 0.1);
}

.aaia-badge-citations {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.12), rgba(52, 211, 153, 0.04));
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.1);
}

.aaia-paper-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.5;
}

.aaia-paper-title a {
    color: var(--aaia-text);
    text-decoration: none;
    transition: var(--aaia-transition);
}

.aaia-paper-title a:hover {
    color: var(--aaia-primary-light);
    text-shadow: 0 0 16px rgba(124, 58, 237, 0.2);
}

.aaia-paper-insights {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.aaia-insight-block {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.aaia-insight-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--aaia-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.aaia-insight-block p {
    font-size: 13px;
    color: var(--aaia-muted);
    line-height: 1.6;
}

/* ---- PDF SPLIT LAYOUT ---- */
.aaia-pdf-split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    min-height: 520px;
}

.aaia-pdf-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.aaia-pdf-upload-area {
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 14px;
    padding: 24px;
}

.aaia-upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    border: 2px dashed rgba(124, 58, 237, 0.15);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--aaia-transition);
}

.aaia-upload-dropzone:hover,
.aaia-upload-dropzone.dragover {
    border-color: var(--aaia-primary);
    background: rgba(124, 58, 237, 0.04);
    box-shadow: 0 0 40px rgba(124, 58, 237, 0.06);
}

.aaia-upload-icon {
    color: var(--aaia-primary);
    margin-bottom: 16px;
    opacity: 0.5;
    transition: var(--aaia-transition);
}

.aaia-upload-dropzone:hover .aaia-upload-icon {
    opacity: 0.8;
    transform: scale(1.05);
}

.aaia-upload-dropzone h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.aaia-upload-hint {
    font-size: 13px;
    color: var(--aaia-muted);
    margin-bottom: 16px;
}

.aaia-file-input {
    display: none;
}

.aaia-upload-info {
    font-size: 12px;
    color: var(--aaia-muted);
    margin-top: 16px;
    opacity: 0.6;
}

.aaia-pdf-info {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.06), rgba(124, 58, 237, 0.02));
    border: 1px solid rgba(124, 58, 237, 0.12);
    border-radius: 10px;
    padding: 14px 18px;
}

.aaia-pdf-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aaia-pdf-icon {
    color: var(--aaia-primary);
    display: flex;
    opacity: 0.7;
}

.aaia-pdf-file-info div {
    flex: 1;
}

.aaia-pdf-file-info strong {
    display: block;
    font-size: 14px;
    color: var(--aaia-text);
}

.aaia-pdf-status {
    font-size: 12px;
    color: #34d399;
    font-weight: 500;
}

.aaia-btn-icon {
    background: transparent;
    border: none;
    color: var(--aaia-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--aaia-transition);
}

.aaia-btn-icon:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.aaia-pdf-preview {
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 20px;
    flex: 1;
    overflow: auto;
    max-height: 380px;
}

.aaia-pdf-text-preview h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--aaia-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.aaia-pdf-text-content {
    font-size: 13px;
    color: var(--aaia-muted);
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    opacity: 0.7;
}

/* ---- CHAT CONTAINER ---- */
.aaia-pdf-right {
    display: flex;
    flex-direction: column;
}

.aaia-chat-container {
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 520px;
    overflow: hidden;
}

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

.aaia-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    margin: auto;
}

.aaia-welcome-icon {
    color: var(--aaia-primary);
    opacity: 0.3;
    margin-bottom: 20px;
}

.aaia-chat-welcome h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.aaia-chat-welcome > p {
    font-size: 14px;
    color: var(--aaia-muted);
    margin-bottom: 24px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.aaia-chat-tips {
    text-align: right;
    max-width: 360px;
    margin: 0 auto;
}

.aaia-chat-tips p {
    font-size: 13px;
    color: var(--aaia-muted);
    margin-bottom: 8px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Chat Messages */
.aaia-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: aaiaMsgSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.aaia-msg-ai {
    align-self: flex-start;
}

.aaia-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
}

.aaia-msg-user .aaia-msg-avatar {
    background: linear-gradient(135deg, var(--aaia-primary), var(--aaia-primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.aaia-msg-ai .aaia-msg-avatar {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.06));
    color: var(--aaia-secondary);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.aaia-msg-content {
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.7;
}

.aaia-msg-user .aaia-msg-content {
    background: linear-gradient(135deg, var(--aaia-primary), var(--aaia-primary-dark));
    color: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.15);
}

.aaia-msg-ai .aaia-msg-content {
    background: rgba(0, 0, 0, 0.2);
    color: var(--aaia-text);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.aaia-msg-content p {
    margin-bottom: 8px;
}

.aaia-msg-content p:last-child {
    margin-bottom: 0;
}

.aaia-msg-content strong {
    color: var(--aaia-primary-light);
}

.aaia-msg-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.aaia-msg-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.aaia-msg-time {
    font-size: 11px;
    color: var(--aaia-muted);
    opacity: 0.5;
    margin-top: 6px;
    display: block;
}

.aaia-typing-indicator {
    display: flex;
    gap: 6px;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 14px;
    align-self: flex-start;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.aaia-typing-dot {
    width: 9px;
    height: 9px;
    background: var(--aaia-muted);
    border-radius: 50%;
    animation: aaiaTypingBounce 1.4s infinite ease-in-out;
}

.aaia-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.aaia-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes aaiaTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Chat Input */
.aaia-chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(124, 58, 237, 0.06);
    background: rgba(0, 0, 0, 0.1);
}

.aaia-chat-input {
    flex: 1;
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    color: var(--aaia-text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: var(--aaia-transition);
    line-height: 1.5;
}

.aaia-chat-input:focus {
    border-color: var(--aaia-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.aaia-chat-input::placeholder {
    color: var(--aaia-muted);
    opacity: 0.4;
}

.aaia-chat-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.aaia-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- ACADEMIC WRITER ---- */
.aaia-writer-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.aaia-writer-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aaia-field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.aaia-label-text {
    font-size: 14px;
    font-weight: 600;
}

.aaia-label-badge {
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(124, 58, 237, 0.04));
    color: var(--aaia-primary-light);
    font-weight: 600;
    border: 1px solid rgba(124, 58, 237, 0.1);
}

.aaia-badge-success {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.1), rgba(52, 211, 153, 0.04));
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.1);
}

.aaia-writer-textarea {
    width: 100%;
    padding: 18px;
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 12px;
    color: var(--aaia-text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.8;
    resize: vertical;
    outline: none;
    transition: var(--aaia-transition);
    min-height: 360px;
}

.aaia-writer-textarea:focus {
    border-color: var(--aaia-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.aaia-writer-textarea::placeholder {
    color: var(--aaia-muted);
    opacity: 0.4;
}

.aaia-writer-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.aaia-writer-controls .aaia-select {
    flex: 1;
    padding: 12px 16px;
    background: var(--aaia-card-bg);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 12px;
    color: var(--aaia-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: var(--aaia-transition);
    appearance: auto;
}

.aaia-writer-controls .aaia-select:focus {
    border-color: var(--aaia-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.aaia-writer-output-wrap {
    position: relative;
    flex: 1;
}

.aaia-writer-output {
    width: 100%;
    min-height: 360px;
    padding: 18px;
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    color: var(--aaia-text);
    font-size: 14px;
    line-height: 1.8;
    overflow-y: auto;
}

.aaia-writer-output .aaia-placeholder {
    padding: 80px 20px;
}

.aaia-writer-output p {
    margin-bottom: 12px;
}

.aaia-writer-output strong {
    color: var(--aaia-primary-light);
}

/* ---- STAR RATING ---- */
.aaia-ratings-section {
    padding: 40px 32px 32px;
    border-top: 1px solid rgba(124, 58, 237, 0.06);
    text-align: center;
    position: relative;
    z-index: 1;
}

.aaia-ratings-divider {
    margin-bottom: 20px;
}

.aaia-divider-icon {
    font-size: 36px;
    color: var(--aaia-secondary);
    opacity: 0.3;
}

.aaia-ratings-content {
    max-width: 480px;
    margin: 0 auto;
}

.aaia-ratings-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.aaia-ratings-desc {
    font-size: 14px;
    color: var(--aaia-muted);
    margin-bottom: 24px;
}

.aaia-stars-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.aaia-star {
    cursor: pointer;
    transition: var(--aaia-transition);
    color: rgba(255, 255, 255, 0.06);
    display: flex;
}

.aaia-star svg {
    transition: var(--aaia-transition);
}

.aaia-star:hover svg,
.aaia-star.active svg,
.aaia-star.hover svg {
    color: var(--aaia-secondary);
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.4));
    transform: scale(1.12);
}

.aaia-ratings-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.aaia-avg-rating {
    font-size: 30px;
    font-weight: 800;
    color: var(--aaia-secondary);
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

.aaia-stars-display {
    display: flex;
    gap: 3px;
}

.aaia-star-filled {
    color: var(--aaia-secondary);
}

.aaia-star-empty {
    color: rgba(255, 255, 255, 0.06);
}

.aaia-count-rating {
    font-size: 14px;
    color: var(--aaia-muted);
}

.aaia-rating-feedback {
    margin-top: 14px;
    font-size: 14px;
    color: #34d399;
    font-weight: 600;
    animation: aaiaFadeSlideIn 0.3s ease;
}

/* ---- TOOL SECTION (Poster + Title + Description) ---- */
.aaia-tool-section {
    padding: 20px 32px 36px;
    text-align: center;
    position: relative;
    z-index: 1;
    border-top: 1px solid rgba(124, 58, 237, 0.06);
}

.aaia-tool-poster {
    width: 420px;
    max-width: 90%;
    height: auto;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 40px rgba(124, 58, 237, 0.08);
    transition: all 0.4s ease;
    margin-bottom: 20px;
}

.aaia-tool-poster:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(124, 58, 237, 0.12);
}

.aaia-tool-heading {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--aaia-primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.aaia-tool-desc {
    font-size: 15px;
    color: var(--aaia-muted);
    -webkit-text-fill-color: var(--aaia-muted);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.8;
}

/* ---- FAQ SECTION ---- */
.aaia-faq-section {
    padding: 20px 32px 36px;
    border-top: 1px solid rgba(124, 58, 237, 0.06);
    position: relative;
    z-index: 1;
}

.aaia-faq-divider {
    text-align: center;
    margin-bottom: 20px;
}

.aaia-faq-content {
    max-width: 720px;
    margin: 0 auto;
}

.aaia-faq-content h3 {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
}

.aaia-faq-desc {
    text-align: center;
    font-size: 14px;
    color: var(--aaia-muted);
    margin-bottom: 28px;
}

.aaia-faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aaia-faq-list-item {
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.06);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--aaia-transition);
}

.aaia-faq-list-item:hover {
    border-color: rgba(124, 58, 237, 0.12);
}

.aaia-faq-question-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 18px 22px;
    background: none;
    border: none;
    color: var(--aaia-text);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: right;
    transition: var(--aaia-transition);
}

.aaia-faq-question-btn:hover {
    background: rgba(124, 58, 237, 0.03);
}

.aaia-faq-q-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.aaia-faq-q-text {
    flex: 1;
}

.aaia-faq-toggle {
    font-size: 22px;
    font-weight: 300;
    color: var(--aaia-primary-light);
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.aaia-faq-question-btn.active .aaia-faq-toggle {
    transform: rotate(45deg);
}

.aaia-faq-answer-box {
    display: none;
    padding: 0 22px 20px 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin: 0 12px;
}

.aaia-faq-answer-box p {
    font-size: 14px;
    color: var(--aaia-muted);
    line-height: 1.8;
    padding-top: 14px;
}

/* ---- LOADING OVERLAY ---- */
.aaia-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 19, 34, 0.8);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aaia-loading-spinner {
    text-align: center;
}

.aaia-spinner-ring {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    border: 3px solid rgba(124, 58, 237, 0.08);
    border-top-color: var(--aaia-primary);
    border-right-color: var(--aaia-secondary);
    border-radius: 50%;
    animation: aaiaSpin 0.8s linear infinite;
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.1);
}

@keyframes aaiaSpin {
    to { transform: rotate(360deg); }
}

.aaia-loading-spinner p {
    font-size: 16px;
    color: var(--aaia-muted);
    animation: aaiaPulse 2s ease-in-out infinite;
}

/* ---- LOGIN PROMPT ---- */
.aaia-login-prompt {
    background: linear-gradient(160deg, var(--aaia-bg) 0%, #1a1040 100%);
    border-radius: var(--aaia-radius);
    padding: 100px 32px;
    margin: 28px auto;
    max-width: 600px;
    text-align: center;
    box-shadow: var(--aaia-shadow);
}

.aaia-login-card {
    max-width: 400px;
    margin: 0 auto;
}

.aaia-login-icon {
    color: var(--aaia-primary);
    opacity: 0.3;
    margin-bottom: 28px;
}

.aaia-login-card h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 14px;
    line-height: 1.5;
}

.aaia-login-card p {
    font-size: 15px;
    color: var(--aaia-muted);
    margin-bottom: 32px;
    line-height: 1.7;
}

.aaia-login-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
}

/* ---- DISABLED NOTICE ---- */
.aaia-disabled-notice {
    background: var(--aaia-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(251, 191, 36, 0.1);
    border-radius: var(--aaia-radius);
    padding: 28px;
    text-align: center;
    margin: 28px auto;
    max-width: 500px;
    color: var(--aaia-secondary);
    font-weight: 600;
}

/* ---- SCROLLBAR ---- */
.aaia-chat-messages::-webkit-scrollbar,
.aaia-writer-output::-webkit-scrollbar,
.aaia-pdf-preview::-webkit-scrollbar {
    width: 5px;
}

.aaia-chat-messages::-webkit-scrollbar-track,
.aaia-writer-output::-webkit-scrollbar-track,
.aaia-pdf-preview::-webkit-scrollbar-track {
    background: transparent;
}

.aaia-chat-messages::-webkit-scrollbar-thumb,
.aaia-writer-output::-webkit-scrollbar-thumb,
.aaia-pdf-preview::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.15);
    border-radius: 4px;
}

.aaia-chat-messages::-webkit-scrollbar-thumb:hover,
.aaia-writer-output::-webkit-scrollbar-thumb:hover,
.aaia-pdf-preview::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.3);
}

/* ---- HTML Tables in Results ---- */
.aaia-results-area table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.aaia-results-area table thead th {
    background: rgba(124, 58, 237, 0.08);
    color: var(--aaia-text);
    padding: 14px 18px;
    text-align: right;
    font-weight: 700;
    border-bottom: 2px solid rgba(124, 58, 237, 0.15);
    font-size: 13px;
}

.aaia-results-area table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--aaia-muted);
    font-size: 13px;
}

.aaia-results-area table tbody tr:hover {
    background: rgba(124, 58, 237, 0.03);
}

.aaia-results-area table a {
    color: var(--aaia-primary-light);
    text-decoration: none;
    transition: var(--aaia-transition);
}

.aaia-results-area table a:hover {
    color: var(--aaia-primary);
    text-shadow: 0 0 12px rgba(124, 58, 237, 0.2);
}

/* ---- ERROR MESSAGES ---- */
.aaia-error-msg {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.12);
    color: #f87171;
    padding: 14px 20px;
    border-radius: 10px;
    margin: 12px 0;
    font-size: 14px;
    animation: aaiaFadeSlideIn 0.3s ease;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
    .aaia-pdf-split-layout {
        grid-template-columns: 1fr;
    }
    .aaia-writer-layout {
        grid-template-columns: 1fr;
    }
    .aaia-paper-insights {
        grid-template-columns: 1fr;
    }
    .aaia-tab-panel {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .aaia-dashboard-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 20px;
    }
    .aaia-header-brand {
        flex-direction: column;
    }
    .aaia-header-left {
        flex-direction: column;
        gap: 12px;
    }
    .aaia-tabs-nav {
        flex-direction: column;
        gap: 2px;
    }
    .aaia-tab-btn {
        flex-direction: row;
        padding: 12px 18px;
        border-radius: 8px;
    }
    .aaia-tab-btn.active {
        box-shadow: inset 3px 0 0 var(--aaia-primary);
    }
    .aaia-tab-btn.active::after {
        display: none;
    }
    .aaia-input-group {
        flex-direction: column;
    }
    .aaia-tab-panel {
        padding: 18px;
    }
    .aaia-tab-stats {
        grid-template-columns: 1fr 1fr;
    }
    .aaia-login-buttons {
        flex-direction: column;
    }
    .aaia-ratings-section,
    .aaia-faq-section,
    .aaia-tool-section {
        padding: 28px 18px;
    }
    .aaia-tool-poster {
        width: 100%;
        max-width: 320px;
    }
}

@media (max-width: 480px) {
    .aaia-tab-stats {
        grid-template-columns: 1fr;
    }
    .aaia-stat-item {
        min-width: auto;
    }
    .aaia-tool-heading {
        font-size: 22px;
    }
    .aaia-tool-poster {
        max-width: 280px;
    }
}
