/* --- Meta Ad Insights AI Analyst Styles --- */

.analyst-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 13, 30, 0.75);
    backdrop-filter: blur(8px);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.analyst-overlay.active {
    opacity: 1;
    display: block;
}

.analyst-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    background: rgba(16, 25, 46, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 2rem;
    z-index: 2001;
    backdrop-filter: blur(25px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 
                inset 0 0 0 1px rgba(255, 255, 255, 0.05),
                0 0 40px rgba(59, 130, 246, 0.15);
    color: var(--text);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.analyst-modal.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.analyst-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 1rem;
}

.analyst-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #93c5fd 0%, #22d3ee 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analyst-close {
    cursor: pointer;
    color: var(--text-dim);
    font-size: 1.5rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.analyst-close:hover {
    color: white;
    transform: scale(1.1);
}

.analyst-body {
    overflow-y: auto;
    flex: 1;
    padding-right: 0.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Scrollbar styling */
.analyst-body::-webkit-scrollbar,
.analyst-report-box::-webkit-scrollbar {
    width: 6px;
}
.analyst-body::-webkit-scrollbar-track,
.analyst-report-box::-webkit-scrollbar-track {
    background: transparent;
}
.analyst-body::-webkit-scrollbar-thumb,
.analyst-report-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.analyst-body::-webkit-scrollbar-thumb:hover,
.analyst-report-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.analyst-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #93c5fd;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analyst-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 1.25rem;
}

.analyst-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-dim);
    transition: color 0.2s ease;
}

.analyst-checkbox-wrapper:hover {
    color: white;
}

.analyst-checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    position: relative;
    outline: none;
    transition: all 0.2s ease;
}

.analyst-checkbox-wrapper input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.analyst-checkbox-wrapper input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.75rem;
    font-weight: 900;
}

.analyst-shortcuts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.analyst-shortcut-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-dim);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.analyst-shortcut-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: white;
}

.analyst-row {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.analyst-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.analyst-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    padding: 0.65rem;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.analyst-select:focus {
    border-color: var(--accent);
}

.analyst-textarea {
    width: 100%;
    height: 90px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    padding: 0.75rem;
    font-size: 0.85rem;
    outline: none;
    resize: none;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.analyst-textarea:focus {
    border-color: var(--accent);
}

/* Loading State */
.analyst-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 3rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    text-align: center;
}

.analyst-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s linear infinite;
}

.analyst-loading-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: #60a5fa;
    letter-spacing: 0.02em;
    animation: analystGlow 2s ease-in-out infinite alternate;
}

@keyframes analystGlow {
    from { text-shadow: 0 0 4px rgba(59, 130, 246, 0.3); opacity: 0.7; }
    to { text-shadow: 0 0 12px rgba(59, 130, 246, 0.7); opacity: 1; }
}

/* Results Markdown Styling */
.analyst-report-box {
    display: none;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.analyst-report-box h1,
.analyst-report-box h2,
.analyst-report-box h3 {
    color: #93c5fd;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.analyst-report-box h1 { font-size: 1.35rem; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 0.4rem; }
.analyst-report-box h2 { font-size: 1.15rem; }
.analyst-report-box h3 { font-size: 1rem; }

.analyst-report-box p {
    margin-bottom: 1rem;
}

.analyst-report-box ul,
.analyst-report-box ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.analyst-report-box li {
    margin-bottom: 0.35rem;
}

.analyst-report-box strong {
    color: white;
}

.analyst-report-box table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.8rem;
}

.analyst-report-box th,
.analyst-report-box td {
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.5rem;
    text-align: left;
}

.analyst-report-box th {
    background: rgba(99, 102, 241, 0.15);
    color: white;
    font-weight: 600;
}

.analyst-report-box tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

.analyst-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1rem;
}

.analyst-selected-summary {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.analyst-buttons {
    display: flex;
    gap: 0.75rem;
}

/* UI Table Checklist columns */
.ads-check-col {
    width: 40px;
    text-align: center;
}

.ad-row-checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    position: relative;
    outline: none;
    transition: all 0.2s ease;
}

.ad-row-checkbox:checked {
    background: #22c55e;
    border-color: #22c55e;
}

.ad-row-checkbox:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: black;
    font-size: 0.7rem;
    font-weight: 900;
}

.badge-ai-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.badge-ai-btn:hover:not(:disabled) {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
    filter: brightness(1.1);
}

.badge-ai-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}
