/**
 * Modern Article Enhancements for Article.Pk
 * Phase 1: Core Enhancements
 *
 * Features:
 * - Sticky Sidebar
 * - Enhanced Author Card
 * - Font Size Controls
 * - Dynamic Reading Time
 *
 * Brand Colors: #0052cc (blue), #00c453 (green), #2a323a (dark)
 */

/* ==========================================
   1. SMART STICKY SIDEBAR (Only Ads)
   ========================================== */

/* Remove sticky from entire sidebar */
.sticky-element {
    position: relative;
}

/* Make only ad widgets sticky */
.sticky-element .widget.ad,
.sticky-element .widget:has([class*="ad"]),
.sticky-element .widget:has([id*="ad"]) {
    position: -webkit-sticky;
    position: sticky;
    top: 100px; /* Below fixed header */
    z-index: 100;
    transition: all 0.3s ease;
}

/* Prevent sidebar from overlapping footer */
.article-main-content {
    position: relative;
}

@media (max-width: 991px) {
    .sticky-element .widget.ad,
    .sticky-element .widget:has([class*="ad"]),
    .sticky-element .widget:has([id*="ad"]) {
        position: relative;
        top: 0;
    }
}

/* ==========================================
   2. ENHANCED AUTHOR CARD
   ========================================== */

.author-card {
    background: linear-gradient(135deg, rgba(0, 82, 204, 0.05) 0%, rgba(0, 196, 83, 0.05) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 82, 204, 0.1);
    border-radius: 16px;
    padding: 24px;
    margin: 30px 0;
    box-shadow: 0 4px 20px rgba(0, 82, 204, 0.08);
    transition: all 0.3s ease;
}

.author-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 82, 204, 0.12);
}

.author-card-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.author-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #0052cc, #00c453) border-box;
    box-shadow: 0 4px 12px rgba(0, 82, 204, 0.2);
}

.author-avatar-fallback {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0052cc, #00c453);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 82, 204, 0.2);
}

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

.author-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #1c1c1c);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-verified {
    color: #0052cc;
    font-size: 16px;
}

.author-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary, #6c757d);
    flex-wrap: wrap;
}

.author-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.author-meta-item i {
    font-size: 12px;
}

.author-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #0052cc, #00c453);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.author-bio {
    color: var(--text-secondary, #6c757d);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 16px 0;
}

.author-social {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.author-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(0, 82, 204, 0.1);
    color: #0052cc;
    border-radius: 50%;
    font-size: 16px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.author-social-link:hover {
    background: linear-gradient(135deg, #0052cc, #00c453);
    color: white;
    transform: translateY(-2px);
    text-decoration: none;
}

.author-follow-btn {
    width: 100%;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0052cc, #00c453);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.author-follow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 82, 204, 0.3);
}

.author-follow-btn i {
    font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 576px) {
    .author-card {
        padding: 20px;
    }

    .author-card-header {
        flex-direction: column;
        text-align: center;
    }

    .author-avatar,
    .author-avatar-fallback {
        width: 70px;
        height: 70px;
    }

    .author-avatar-fallback {
        font-size: 28px;
    }

    .author-meta {
        justify-content: center;
    }

    .author-social {
        justify-content: center;
    }
}

/* ==========================================
   3. FONT SIZE CONTROLS
   ========================================== */

.font-size-controls {
    position: fixed;
    top: 120px;
    right: 20px;
    z-index: 999;
    background: white;
    border-radius: 24px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
}

.font-size-controls.visible {
    opacity: 1;
    transform: translateX(0);
}

.font-size-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6c757d);
    font-size: 14px;
    font-weight: 600;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.font-size-btn:hover {
    background: rgba(0, 82, 204, 0.1);
    color: #0052cc;
}

.font-size-btn.active {
    background: linear-gradient(135deg, #0052cc, #00c453);
    color: white;
}

.font-size-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Font size labels */
.font-size-btn[data-size="small"] {
    font-size: 12px;
}

.font-size-btn[data-size="medium"] {
    font-size: 16px;
}

.font-size-btn[data-size="large"] {
    font-size: 20px;
}

/* Tooltip */
.font-size-btn::before {
    content: attr(title);
    position: absolute;
    right: 100%;
    margin-right: 10px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.font-size-btn:hover::before {
    opacity: 1;
}

/* Font size transitions on content */
.article-content {
    transition: font-size 0.3s ease;
}

.article-content.font-small {
    font-size: 16px;
}

.article-content.font-medium {
    font-size: 18px;
}

.article-content.font-large {
    font-size: 20px;
}

/* Mobile: Show as horizontal bar at bottom */
@media (max-width: 768px) {
    .font-size-controls {
        top: auto;
        bottom: 80px;
        right: 50%;
        transform: translateX(50%) translateY(100px);
        flex-direction: row;
        padding: 6px;
    }

    .font-size-controls.visible {
        transform: translateX(50%) translateY(0);
    }

    .font-size-btn::before {
        right: auto;
        bottom: 100%;
        margin-right: 0;
        margin-bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ==========================================
   4. DYNAMIC READING TIME
   ========================================== */

.reading-time-dynamic {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(0, 82, 204, 0.1), rgba(0, 196, 83, 0.1));
    border: 1px solid rgba(0, 82, 204, 0.2);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1c1c1c);
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.reading-time-dynamic i {
    color: #0052cc;
    font-size: 14px;
}

.reading-time-text {
    display: flex;
    align-items: center;
    gap: 4px;
}

.reading-time-remaining {
    color: #00c453;
    font-weight: 700;
}

.reading-time-progress {
    display: inline-block;
    min-width: 40px;
    color: #0052cc;
}

/* Completion state */
.reading-time-dynamic.completed {
    background: linear-gradient(135deg, rgba(0, 196, 83, 0.15), rgba(0, 196, 83, 0.05));
    border-color: rgba(0, 196, 83, 0.3);
}

.reading-time-dynamic.completed i {
    color: #00c453;
}

/* Sticky Reading Time Widget */
.reading-time-sticky {
    position: fixed;
    top: 268px; /* Below font size controls (120px + 140px height + 8px gap) */
    right: 20px;
    z-index: 998;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    border: 2px solid rgba(0, 82, 204, 0.2);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1c1c1c);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.reading-time-sticky.visible {
    display: inline-flex;
    animation: slideInRight 0.3s ease;
}

.reading-time-sticky i {
    color: #0052cc;
    font-size: 14px;
}

.reading-time-sticky .reading-time-remaining {
    color: #00c453;
    font-weight: 700;
}

.reading-time-sticky .reading-time-progress {
    display: inline-block;
    min-width: 35px;
    color: #0052cc;
    font-size: 12px;
}

.reading-time-sticky.completed {
    border-color: rgba(0, 196, 83, 0.4);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(0, 196, 83, 0.05));
}

.reading-time-sticky.completed i {
    color: #00c453;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Enhanced reading progress bar */
.reading-progress__fill {
    position: relative;
}

.reading-progress__percentage {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reading-progress:hover .reading-progress__percentage {
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .reading-time-sticky {
        top: auto;
        bottom: 80px; /* Above FAB menu */
        right: 15px;
        left: auto;
        font-size: 12px;
        padding: 8px 12px;
    }

    .reading-time-sticky i {
        font-size: 12px;
    }
}

@media (max-width: 576px) {
    .reading-time-dynamic {
        font-size: 13px;
        padding: 6px 12px;
    }

    .reading-time-sticky {
        bottom: 90px;
        right: 10px;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* ==========================================
   5. ARTICLE METADATA IMPROVEMENTS
   ========================================== */

.article-meta-data {
    margin-bottom: 24px;
}

.article-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 16px;
    font-size: 14px;
    color: var(--text-secondary, #6c757d);
}

.article-meta-item i {
    color: #0052cc;
    font-size: 14px;
}

.article-meta-separator {
    margin: 0 8px;
    color: var(--border-color, #e5e5e5);
}

/* ==========================================
   6. ENHANCED INTERACTION BUTTONS
   ========================================== */

.article-actions {
    margin-bottom: 20px;
}

.article-actions form,
.article-actions button {
    display: inline-block;
}

.article-actions .btn {
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color, #e5e5e5);
}

.article-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.article-actions .btn.active {
    background: linear-gradient(135deg, #0052cc, #00c453);
    color: white;
    border-color: transparent;
}

.article-actions .btn i {
    margin-right: 4px;
}

/* ==========================================
   7. UTILITY CLASSES
   ========================================== */

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Accessibility: Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ==========================================
   8. RELATED ARTICLES - COMPLETE REDESIGN
   ========================================== */

.article-related .block-item {
    margin-bottom: 24px;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    border: 1px solid #e8e8e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.article-related .block-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 82, 204, 0.15);
    border-color: rgba(0, 82, 204, 0.2);
}

/* Thumbnail Container - Cleaner Design */
.article-related .block-item-img {
    position: relative;
    width: 100%;
    padding-bottom: 60%; /* 5:3 ratio - more compact */
    overflow: hidden;
    background: #f5f5f5;
}

.article-related .block-item-img > a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    display: block;
    transition: transform 0.5s ease;
}

.article-related .block-item:hover .block-item-img > a {
    transform: scale(1.06);
}

/* Subtle gradient overlay */
.article-related .block-item-img::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.15) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Lazy loading */
.article-related .block-item-img a.b-lazy {
    background-color: #f0f0f0;
}

.article-related .block-item-img a.b-loaded {
    background-color: transparent;
}

/* Modern Category Badge - Bottom Position with Better Contrast */
.article-related .block-item-category {
    position: absolute !important;
    bottom: 12px !important;
    left: 12px !important;
    right: auto !important;
    top: auto !important;
    padding: 5px 12px !important;
    border-radius: 4px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    z-index: 10 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    line-height: 1.4 !important;
    display: inline-block !important;
    transition: all 0.3s ease !important;
    max-width: calc(100% - 24px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.article-related .block-item:hover .block-item-category {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.article-related .block-item-category a {
    color: white !important;
    text-decoration: none !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
    display: block !important;
    line-height: 1.4 !important;
    font-weight: 700 !important;
}

/* Card Content Area with Proper Spacing */
.article-related .block-item-title {
    padding: 14px 16px 0;
    margin-bottom: 0;
    min-height: 50px; /* Ensures consistent height */
}

.article-related .block-item-title a {
    color: #1c1c1c;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    transition: color 0.2s ease;
}

.article-related .block-item-title a:hover {
    color: #0052cc;
}

/* Meta Information - Better Alignment */
.article-related .block-item-meta {
    padding: 10px 16px 14px;
    margin-top: auto;
    font-size: 11px;
    color: #888;
    line-height: 1.5;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid #f0f0f0;
}

.article-related .block-item-meta small {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.article-related .block-item-meta i {
    font-size: 10px;
    color: #0052cc;
    flex-shrink: 0;
}

/* Remove the hyphen between date and author */
.article-related .block-item-meta small + small {
    margin-left: 0;
}

/* Bottom accent line on hover */
.article-related .block-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0052cc, #00c453);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.article-related .block-item:hover::after {
    transform: scaleX(1);
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .article-related .block-item {
        margin-bottom: 20px;
    }

    .article-related .block-item-title {
        min-height: 45px;
    }

    .article-related .block-item-title a {
        font-size: 14px;
    }
}

@media (max-width: 767px) {
    .article-related .block-item-img {
        padding-bottom: 56.25%; /* 16:9 on mobile */
    }

    .article-related .block-item-title {
        padding: 12px 14px 0;
        min-height: 60px;
    }

    .article-related .block-item-title a {
        font-size: 14px;
        -webkit-line-clamp: 3;
    }

    .article-related .block-item-meta {
        padding: 8px 14px 12px;
        font-size: 10px;
    }

    .article-related .block-item-category {
        font-size: 9px !important;
        padding: 4px 10px !important;
    }
}

@media (max-width: 575px) {
    .article-related .row {
        margin: 0 -8px;
    }

    .article-related [class*="col-"] {
        padding: 0 8px;
    }

    .article-related .block-item {
        margin-bottom: 16px;
    }
}

/* ==========================================
   9. PRINT STYLES
   ========================================== */

@media print {
    .font-size-controls,
    .author-follow-btn,
    .author-social,
    .article-actions {
        display: none !important;
    }

    .author-card {
        border: 1px solid #ccc;
        background: white;
        box-shadow: none;
    }

    .sticky-element {
        position: static;
    }

    .sticky-element .widget.ad,
    .sticky-element .widget:has([class*="ad"]),
    .sticky-element .widget:has([id*="ad"]) {
        position: static;
    }
}
