/* Article Detail Page Styles */

/* Layout Styles - Using unique class names to avoid conflicts */
.article-left-content {
    flex: 1;
    min-width: 0;
    margin-top: 20px;
}

.article-detail-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* Mobile optimizations for article container */
@media (max-width: 767px) {
    .article-detail-container {
        padding: 0;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }
}

/* Ensure proper spacing on mobile */
@media (max-width: 992px) {
    .article-left-content {
        margin-right: 0;
        margin-top: 20px;
    }
}

/* Remove top margin on mobile for better spacing */
@media (max-width: 767px) {
    .article-left-content {
        margin-top: 0px;
    }
    
    /* Override mobile menu fixes - remove extra padding for article pages */
    main {
        padding-top: 20px !important;
    }
}

/* Article Header Styles */
.article-detail-header {
    margin-bottom: 20px;
    background: transparent;
}

/* Fix mobile black background issue and ensure no conflicts */
@media (max-width: 767px) {
    .article-detail-header {
        position: static !important;
        background: transparent !important;
        background-color: transparent !important;
        color: inherit !important;
        margin-bottom: 5px !important;
        padding: 0 15px !important;
        box-shadow: none !important;
        border: none !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        z-index: auto !important;
    }
}

.article-detail-meta {
    margin-bottom: 10px;
    color: #777;
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* Mobile-specific meta styling */
@media (max-width: 767px) {
    .article-detail-meta {
        font-size: 14px;
        color: #666;
        margin-bottom: 5px;
        gap: 8px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }
    
    /* Hide icons on mobile for cleaner look */
    .article-detail-meta i {
        display: none;
    }
    
    /* Simple text styling for meta items */
    .article-detail-meta span {
        color: #555;
        font-size: 14px;
        line-height: 1.2;
    }
    
    .article-detail-meta a {
        color: #0066cc;
        text-decoration: none;
    }
    
    .article-detail-meta a:hover {
        text-decoration: underline;
    }
}

.article-detail-title {
    font-size: 2em;
    margin: 0 0 15px 0;
    line-height: 1.3;
}

@media (max-width: 767px) {
    .article-detail-title {
        font-size: 1.5em;
        line-height: 1.3;
        margin: 0 0 10px 0;
        word-break: break-word;
        padding: 0 15px;
        color: #222;
    }
}

/* Article Content Styles */
.article-detail-content blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    border-left: 5px solid #a61e22;
    color: #666;
    font-style: italic;
    background-color: #f9f9f9;
}

.article-detail-featured-image {
    margin-bottom: 20px;
}

/* Mobile optimizations for featured image */
@media (max-width: 767px) {
    .article-detail-featured-image {
        margin: 0 0 15px 0;
        padding: 0;
    }
    
    .article-detail-featured-image img {
        border-radius: 0;
        width: 100%;
        height: auto;
    }
}

/* Prevent text overflow and layout breaking */
.article-detail-container,
.article-detail-content,
.article-detail-content p,
.article-detail-content div,
.comment-text,
.comment-content {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}

/* Handle long URLs and code blocks */
.article-detail-content a,
.article-detail-content code,
.article-detail-content pre {
    word-break: break-all;
    overflow-wrap: break-word;
}

.article-detail-content pre {
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Ensure containers don't overflow */
.article-left-content {
    min-width: 0; /* Allow flex item to shrink below content size */
}

/* Handle tables and wide content */
.article-detail-content table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-detail-content table td,
.article-detail-content table th {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 0;
}

/* Handle embedded content and iframes */
.article-detail-content iframe,
.article-detail-content video,
.article-detail-content embed,
.article-detail-content object {
    max-width: 100%;
    height: auto;
    display: block !important;
    visibility: visible !important;
}

/* Fix for article video container - Responsive aspect ratio */
.article-video {
    margin: 20px 0;
    width: 100%;
    display: block !important;
    visibility: visible !important;
}

/* Don't override .video-container - it's already defined in style.css and working */
/* Only add visibility fixes if videos are being hidden */
.video-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.video-container iframe,
.video-container video,
.video-container embed,
.video-container object {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force iframe to fill container completely - override any inline styles */
.video-container iframe[width][height] {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Additional specific targeting for Facebook iframes */
.video-container iframe[src*="facebook.com"] {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    border: none !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* Fallback for direct video elements in article-video */
.article-video iframe,
.article-video video,
.article-video embed,
.article-video object {
    width: 100% !important;
    height: auto !important;
    min-height: 315px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Responsive wrapper for embedded content */
.article-detail-content .embed-responsive {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.article-detail-content .embed-responsive::before {
    content: "";
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.article-detail-content .embed-responsive iframe,
.article-detail-content .embed-responsive video,
.article-detail-content .embed-responsive embed,
.article-detail-content .embed-responsive object {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.article-detail-featured-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.article-detail-banner {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
}

.article-detail-banner a {
    display: block;
}

.article-detail-banner img {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
}

.article-detail-content {
    line-height: 1.6;
    font-size: 1.1em;
    margin-bottom: 20px;
}

/* Mobile optimizations for article content */
@media (max-width: 767px) {
    .article-detail-content {
        line-height: 1.6;
        font-size: 1.1em;
        margin-bottom: 20px;
        padding: 0 15px;
        color: #333;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    .article-detail-content p {
        margin-bottom: 15px;
    }
    
    .article-detail-content h2,
    .article-detail-content h3,
    .article-detail-content h4 {
        margin-top: 20px;
        margin-bottom: 10px;
        color: #222;
    }
    
    .article-detail-content blockquote {
        margin: 15px 0;
        padding: 10px 15px;
        border-left: 4px solid #ddd;
        background-color: #f9f9f9;
        color: #666;
        font-style: italic;
    }
}

.article-detail-content img {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
}

/* Article Tags */
.article-detail-tags {
    margin-bottom: 20px;
}

.article-detail-tag {
    display: inline-block;
    margin-right: 8px;
    margin-bottom: 8px;
    padding: 4px 10px;
    background-color: #f5f5f5;
    border-radius: 20px;
    color: #555;
    font-size: 0.85em;
    text-decoration: none;
}

/* Mobile optimizations for tags */
@media (max-width: 767px) {
    .article-detail-tags {
        margin: 15px 0;
        padding: 0 15px;
    }
    
    .article-detail-tag {
        margin-right: 8px;
        margin-bottom: 8px;
        padding: 4px 10px;
        font-size: 0.85em;
        border-radius: 20px;
        background-color: #f5f5f5;
        color: #555;
    }
    
    .article-detail-tag:hover {
        background-color: #e0e0e0;
        color: #444;
    }
}

/* Social Share Section */
.article-share-section {
    padding-top: 20px;
    padding-bottom: 20px;
    border-top: 1px solid #eee;
    background-color: #fff;
    margin-top: 20px;
}

/* Mobile optimizations for social share */
@media (max-width: 767px) {
    .article-share-section {
        padding: 15px;
        margin-top: 15px;
        border-top: 1px solid #eee;
        background-color: transparent;
    }
}

.share-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-start;
}

.share-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    text-decoration: none;
    position: relative;
}

.share-button i {
    margin-right: 8px;
}

.share-button span {
    font-size: 0.9em;
}

.facebook {
    color: #1877f2;
}

.twitter {
    color: #1da1f2;
}

/* Comments Section */
.comments-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.comments-section h2 {
    font-size: 1.5em;
    margin-bottom: 15px;
}

.comments-disabled-message {
    background-color: #f8f8f8;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #e57373;
    margin-bottom: 20px;
}

.comments-disabled-message p {
    margin: 0;
    color: #d32f2f;
    font-weight: 500;
}

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

.comment-form textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

.comment-form button {
    background: #1976d2;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.login-message {
    margin-bottom: 20px;
}

.login-message a {
    color: #1976d2;
    text-decoration: none;
}

.comments-list {
    margin-top: 20px;
}

.comment {
    padding: 15px;
    border-bottom: 1px solid #eee;
    margin-left: var(--comment-indent, 0em);
}

.comment-meta {
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #777;
}

.comment-content {
    line-height: 1.4;
}

.reply-button {
    background: #f0f0f0;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    margin-top: 10px;
    cursor: pointer;
}

.reply-form {
    margin-top: 10px;
}

.reply-form.hidden {
    display: none;
}

.reply-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

.reply-form button {
    background: #1976d2;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

/* Category Tags for Related Articles */
.article-categories {
    margin-top: 5px;
}

.category-tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 6px;
    margin-right: 5px;
    background-color: #f0f0f0;
    border-radius: 12px;
    color: #555;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.category-tag:hover {
    background-color: #e0e0e0;
    color: #333;
}

/* AI News Section Styles */
.ai-news-section {
    border-top: 3px solid #6200ea;
    background-color: #f5f0ff;
}

.ai-news-section .section-title {
    color: #6200ea;
}

/* Sidebar styles handled by homepage CSS - no custom styles needed */

/* Photo Gallery Styles */
.article-gallery-section {
    margin: 20px 0;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
}

.gallery-title {
    font-size: 1.4em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    color: #333;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.gallery-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 15px 10px 10px;
    font-size: 0.9em;
    line-height: 1.3;
}

/* Lightbox Styles */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    animation: fadeIn 0.3s ease;
}

.lightbox-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 90%;
    max-width: 1000px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
}

.lightbox-close:hover {
    color: #ccc;
}

#lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.lightbox-prev,
.lightbox-next {
    background-color: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 15px 20px;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    pointer-events: all;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(255,255,255,0.4);
}

.lightbox-caption {
    color: white;
    text-align: center;
    margin-top: 15px;
    font-size: 1.1em;
    line-height: 1.4;
}

.lightbox-counter {
    color: white;
    text-align: center;
    margin-top: 10px;
    font-size: 0.9em;
    opacity: 0.8;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive adjustments for gallery */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .gallery-item img {
        height: 150px;
    }
    
    .lightbox-content {
        padding: 10px;
    }
    
    .lightbox-nav {
        padding: 0 10px;
    }
    
    .lightbox-prev,
    .lightbox-next {
        padding: 10px 15px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .gallery-item img {
        height: 120px;
    }
}

/* COMPLETELY DISABLE STICKY ON ARTICLE PAGES */
/* Force static positioning for all sticky elements */
.right-content,
.sidebar-sections,
.main-content .right-content,
.main-content .sidebar-sections {
    position: static !important;
    top: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
}

/* Use flexbox layout for article pages */
.main-content {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    align-items: flex-start !important;
    position: relative !important;
}

/* Left content takes available space */
.article-left-content {
    flex: 1 !important;
    min-width: 0 !important;
}

/* Right content fixed width, no sticky */
.right-content {
    width: 380px !important;
    flex-shrink: 0 !important;
    position: static !important;
    top: auto !important;
    height: auto !important;
    padding-top: 20px !important;
    background: transparent !important;
    padding-right: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
}

/* Sidebar sections - completely static */
.sidebar-sections {
    position: static !important;
    top: auto !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
}

/* Individual sections normal behavior */
.sidebar-sections .section-list {
    max-height: 600px !important;
    overflow: hidden !important;
}

.sidebar-sections .section-content {
    flex: 1 !important;
    overflow-y: auto !important;
    max-height: 400px !important;
}

/* Mobile - switch to single column layout */
@media (max-width: 992px) {
    .main-content {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        gap: 10px !important;
    }
    
    /* Ensure videos are visible on mobile */
    .article-video,
    .video-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        margin: 15px 0 !important;
    }
    
    /* Let style.css handle video container layout - just ensure visibility */
    .video-container,
    .video-container iframe,
    .video-container video,
    .article-video iframe,
    .article-video video {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 1 !important;
    }
    
    .article-video iframe,
    .article-video video {
        width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
        position: relative !important;
    }
    
    .article-left-content {
        grid-column: unset !important;
        order: 1 !important;
    }
    
    .right-content {
        grid-column: unset !important;
        order: 2 !important;
        position: static !important;
        top: auto !important;
        height: auto !important;
        padding-top: 0 !important;
        width: 100% !important;
    }
    
    .sidebar-sections {
        position: static !important;
        top: auto !important;
    }
}

/* NUCLEAR OPTION: Override ALL sticky positioning on article pages */
/* This targets any element that might have sticky positioning */
*[class*="right-content"],
*[class*="sidebar"],
*[class*="sticky"],
.right-content *,
.sidebar-sections *,
.main-content *[style*="position"],
.main-content *[style*="sticky"] {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
}

/* Ensure videos and embedded content are never hidden by other rules */
.article-video,
.article-video *,
.video-container,
.video-container *,
.article-detail-content iframe,
.article-detail-content video,
.article-detail-content embed,
.article-detail-content object {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1 !important;
}

/* Let style.css handle video container positioning, just ensure visibility */

/* Fallback positioning for direct embedded content */
.article-video iframe,
.article-video video,
.article-video embed,
.article-video object {
    position: relative !important;
}

/* Force normal document flow for all elements */
.main-content,
.main-content * {
    position: static !important;
}

/* Exception: allow relative positioning for basic layout */
.main-content {
    position: relative !important;
}

/* CRITICAL: Exception for video containers - they MUST have relative/absolute positioning */
.main-content .video-container {
    position: relative !important;
}

.main-content .video-container iframe,
.main-content .video-container video,
.main-content .video-container embed,
.main-content .video-container object {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    overflow: hidden !important;
}

.article-left-content {
    position: static !important;
}

.right-content {
    position: static !important;
}
