/**
 * ================================================================================
 * AI Post Context - Bottom Sheet Modal Styles
 * ================================================================================
 */

/* AI Context Trigger Icon in Header */
.timeline-header__botline .rp .nav-link-holder .ai-context-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    cursor: pointer;
    position: relative;
    border-radius: 100%;
    transition: all 0.27s ease;
}

.timeline-header__botline .rp .nav-link-holder .ai-context-trigger::before {
    content: '';
    width: 34px;
    height: 34px;
    border-radius: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background: transparent;
    transition: all 0.27s ease;
}

.timeline-header__botline .rp .nav-link-holder .ai-context-trigger svg {
    width: 20px;
    height: 20px;
    position: relative;
    z-index: 2;
}

.timeline-header__botline .rp .nav-link-holder .ai-context-trigger svg path {
    fill: var(--km-secondary-text-color);
    transition: all 0.27s ease;
}

.timeline-header__botline .rp .nav-link-holder .ai-context-trigger:hover::before,
.timeline-header__botline .rp .nav-link-holder .ai-context-trigger:active::before {
    background: var(--km-primary-link-color-alpha);
}

.timeline-header__botline .rp .nav-link-holder .ai-context-trigger:hover > svg,
.timeline-header__botline .rp .nav-link-holder .ai-context-trigger:active > svg {
    transform: scale(1.1);
}

.timeline-header__botline .rp .nav-link-holder .ai-context-trigger:hover > svg path,
.timeline-header__botline .rp .nav-link-holder .ai-context-trigger:active > svg path {
    fill: var(--km-primary-link-color);
}

/* Bottom Sheet Modal Container */
.ai-context-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    pointer-events: none;
}

.ai-context-modal.active {
    pointer-events: all;
}

/* Dark Overlay */
.ai-context-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-context-modal.active .ai-context-overlay {
    opacity: 1;
}

/* Bottom Sheet */
.ai-context-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--km-primary-bg-color);
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.ai-context-modal.active .ai-context-sheet {
    transform: translateY(0);
}

/* Desktop: Center the sheet with max-width */
@media (min-width: 768px) {
    .ai-context-sheet {
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        max-width: 600px;
        border-radius: 20px;
        bottom: 20px;
        max-height: 80vh;
    }
    
    .ai-context-modal.active .ai-context-sheet {
        transform: translateX(-50%) translateY(0);
    }
}

/* Modal Header */
.ai-context-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid var(--km-primary-border-color);
    flex-shrink: 0;
}

.ai-context-header__title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-context-header__title .ai-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--km-primary-link-color-alpha);
    border-radius: 10px;
}

.ai-context-header__title .ai-icon svg {
    width: 20px;
    height: 20px;
}

.ai-context-header__title .ai-icon svg path {
    fill: var(--km-primary-link-color);
}

.ai-context-header__title h3 {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--km-primary-text-color);
}

.ai-context-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 100%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-context-close svg {
    width: 20px;
    height: 20px;
}

.ai-context-close svg path {
    stroke: var(--km-secondary-text-color);
}

.ai-context-close:hover {
    background: var(--km-primary-border-color);
}

.ai-context-close:hover svg path {
    stroke: var(--km-primary-text-color);
}

/* Author Section */
.ai-author-section {
    padding: 2px 15px;
    border-bottom: 1px solid var(--km-primary-border-color);
    background: var(--km-secondary-bg-color);
    flex-shrink: 0;
}

.ai-author-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.ai-author-link:hover {
    opacity: 0.8;
}

.ai-author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 100%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--km-primary-border-color);
}

.ai-author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-author-info {
    flex: 1;
    min-width: 0;
}

.ai-author-name {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.ai-author-name span:first-child {
    font-size: 16px;
    font-weight: 600;
    color: var(--km-primary-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-author-name .verified-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-author-name .verified-badge svg {
    width: 16px;
    height: 16px;
}

.ai-author-name .verified-badge svg path {
    fill: var(--km-primary-link-color);
}

.ai-author-username {
    font-size: 14px;
    color: var(--km-secondary-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal Body */
.ai-context-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
}

/* Loading State */
.ai-context-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin-bottom: 20px;
}

.spinner {
    animation: rotate 2s linear infinite;
}

.spinner .path {
    stroke: var(--km-primary-link-color);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.ai-context-loading p {
    margin: 0;
    font-size: 15px;
    color: var(--km-secondary-text-color);
}

/* AI Sections */
.ai-section {
    margin-bottom: 25px;
}

.ai-section:last-child {
    margin-bottom: 0;
}

.ai-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.ai-section-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-section-icon svg {
    width: 18px;
    height: 18px;
}

.ai-section-icon svg path,
.ai-section-icon svg circle {
    stroke: var(--km-primary-link-color);
}

.ai-section-header h4 {
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--km-primary-text-color);
}

.ai-section-content {
    padding-left: 34px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--km-primary-text-color);
}

.ai-section-content p {
    margin: 0 0 10px 0;
}

.ai-section-content p:last-child {
    margin-bottom: 0;
}

/* Key Points List */
.ai-section-content ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ai-section-content ul li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
}

.ai-section-content ul li:before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--km-primary-link-color);
    font-weight: bold;
}

/* Sentiment Badge */
.sentiment-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.sentiment-badge.positive {
    background: rgba(46, 213, 115, 0.1);
    color: #2ed573;
}

.sentiment-badge.negative {
    background: rgba(255, 71, 87, 0.1);
    color: #ff4757;
}

.sentiment-badge.neutral {
    background: rgba(136, 136, 136, 0.1);
    color: #888;
}

.sentiment-badge .emoji {
    font-size: 16px;
}

/* Topics/Tags */
.topics-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--km-primary-link-color-alpha);
    color: var(--km-primary-link-color);
    border-radius: 15px;
    font-size: 13px;
    font-weight: 500;
}

/* Error State */
.ai-context-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.ai-context-error .error-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
    background: rgba(255, 71, 87, 0.1);
    border-radius: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-context-error .error-icon svg {
    width: 30px;
    height: 30px;
}

.ai-context-error .error-icon svg path,
.ai-context-error .error-icon svg circle {
    stroke: #ff4757;
}

.ai-context-error p {
    margin: 0 0 20px 0;
    font-size: 15px;
    color: var(--km-secondary-text-color);
}

/* Mobile Optimizations */
@media (max-width: 767px) {
    .ai-context-sheet {
        max-height: 90vh;
    }
    
    .ai-context-header {
        padding: 10px 16px 10px 16px;
    }
    
    .ai-context-body {
        padding: 16px;
    }
    
    .ai-section-content {
        padding-left: 28px;
    }
}

/* Scrollbar Styling */
.ai-context-body::-webkit-scrollbar {
    width: 6px;
}

.ai-context-body::-webkit-scrollbar-track {
    background: transparent;
}

.ai-context-body::-webkit-scrollbar-thumb {
    background: var(--km-primary-border-color);
    border-radius: 3px;
}

.ai-context-body::-webkit-scrollbar-thumb:hover {
    background: var(--km-secondary-text-color);
}

/* Animation for content appearing */
.ai-context-data {
    animation: fadeIn 0.3s ease;
}

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

/* Dark theme adjustments */
body[data-bg="dark"] .ai-context-sheet {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

/* Clickable topics styling */
.topic-tag.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.topic-tag.clickable:hover {
    background: var(--km-primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.topic-tag.clickable:active {
    transform: translateY(0);
}

/* Fact Check Section Styling */
.ai-section-fact-check {
    background: linear-gradient(135deg, #f8f9ff 0%, #fff5f5 100%);
    border-left: 4px solid #3b82f6;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.ai-section-fact-check .ai-section-header {
    color: #3b82f6;
}

.ai-section-fact-check .fact-check-content {
    color: #1e40af;
    line-height: 1.6;
    font-size: 14px;
    margin: 10px 0 0;
}

/* AI Insights Section Styling */
.ai-section-insights {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left: 4px solid #f59e0b;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.ai-section-insights .ai-section-header {
    color: #f59e0b;
}

.ai-section-insights .ai-insights-content {
    color: #92400e;
    line-height: 1.6;
    font-size: 14px;
    margin: 10px 0 0;
}

/* Dark theme adjustments for new sections */
body[data-bg="dark"] .ai-section-fact-check {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-left-color: #60a5fa;
}

body[data-bg="dark"] .ai-section-fact-check .ai-section-header {
    color: #93c5fd;
}

body[data-bg="dark"] .ai-section-fact-check .fact-check-content {
    color: #bfdbfe;
}

body[data-bg="dark"] .ai-section-insights {
    background: linear-gradient(135deg, #422006 0%, #713f12 100%);
    border-left-color: #fbbf24;
}

body[data-bg="dark"] .ai-section-insights .ai-section-header {
    color: #fcd34d;
}

body[data-bg="dark"] .ai-section-insights .ai-insights-content {
    color: #fde68a;
}
