/* =====================================================================
   CONTENT TYPOGRAPHY & LAYOUT FIXES
   Version: 1.0.0 (2025-12-25)
   
   Purpose: 
   - Ensure titles are left-aligned (furthest left indentation)
   - Center stats grids with proper explanations
   - Fix text selection share popup with official social icons
   - Ensure responsive consistency across all viewports
   
   ARCHITECTURE:
   - All fixes must work desktop -> tablet -> mobile
   - Use CSS variables for consistency
   - No !important unless overriding inline styles
   ===================================================================== */

/* ============ TYPOGRAPHY HIERARCHY ============ */
/* Titles should be the furthest-left indented element */

.article-content h1,
.article-content .article-title,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    text-align: left !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* H2 with left border accent - ensure left alignment */
.article-content h2 {
    position: relative;
    padding-left: var(--space-4) !important;
    border-left: 4px solid var(--color-primary);
    margin-left: 0 !important;
}

/* Remove any centering from headings that should be left */
.article-content :where(h2, h3, h4, h5, h6):not(.text-center):not([style*="text-align: center"]) {
    text-align: left !important;
}

/* ============ STATS GRID CENTERING ============ */
/* Stats cards (3x, 2hrs, etc) should be centered with explanation below */

.synth-stats-grid,
[class*="stats-grid"],
.aiwp-stats-grid,
.aiwp-stats-block__grid {
    display: grid !important;
    /* Guardrail: keep desktop/tablet parity at 2 columns for readability */
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: var(--space-4) !important;
    margin: var(--space-6) auto !important;
    max-width: 800px !important;
    justify-content: center !important;
}

/* Individual stat cards - centered text */
.synth-stat-card,
[class*="stat-card"],
.aiwp-stat-item,
.aiwp-stat-card,
.synth-stats-grid > div,
.stats-grid > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: var(--space-6) var(--space-4) !important;
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-lg) !important;
    min-height: 120px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.synth-stat-card:hover,
[class*="stat-card"]:hover,
.aiwp-stat-item:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(0, 102, 204, 0.12) !important;
}

/* Stat value (3x, 2hrs, etc) - large and prominent */
.synth-stat-value,
[class*="stat-value"],
.aiwp-stat-value,
.synth-stat-card > div:first-child,
[class*="stat-card"] > div:first-child {
    font-size: clamp(2.5rem, 6vw, 3.5rem) !important;
    font-weight: 900 !important;
    color: var(--color-primary) !important;
    line-height: 1 !important;
    margin-bottom: var(--space-2) !important;
    text-align: center !important;
}

/* Stat label (RETENTION RATE, DAILY AVG USE) - uppercase caption */
.synth-stat-label,
[class*="stat-label"],
.aiwp-stat-label,
.synth-stat-card > div:last-child,
[class*="stat-card"] > div:last-child {
    font-size: var(--font-size-xs) !important;
    font-weight: 700 !important;
    color: var(--color-text-muted) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.1em !important;
    text-align: center !important;
    margin-top: var(--space-1) !important;
}

/* ============ CHART EXPLANATIONS ============ */
/* Charts must have centered explanation/paragraph below */

.synth-chart-container,
[class*="chart-container"],
.synth-chart-wrapper,
[class*="chart-wrapper"],
.aiwp-chart-container {
    margin: var(--space-8) auto !important;
    max-width: 900px !important;
    text-align: center !important;
}

/* Chart explanation paragraph */
.synth-chart-container + p,
[class*="chart-container"] + p,
.synth-stats-grid + p,
[class*="stats-grid"] + p {
    text-align: center !important;
    max-width: 700px !important;
    margin: var(--space-4) auto var(--space-6) !important;
    color: var(--color-text-secondary) !important;
    font-size: var(--font-size-sm) !important;
    line-height: 1.6 !important;
}

/* ============ TEXT SELECTION SHARE POPUP - FULL SOCIAL OPTIONS ============ */
/* v5.31.2: Complete social share popup with all platforms */
/* Appears when user selects text in article content */

.aiwp-selection-share {
    position: fixed !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 8px 10px !important;
    border-radius: 12px !important;
    
    /* Surface styling */
    background: #FFFFFF !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.08) !important;
    
    z-index: 1200;
    transition: all 0.2s ease !important;
}

.aiwp-selection-share.is-visible {
    display: inline-flex !important;
}

/* Individual share buttons */
.aiwp-selection-share__btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
}

.aiwp-selection-share__btn svg {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    /* ALWAYS VISIBLE: Explicit white icons on colored backgrounds */
    fill: #FFFFFF !important;
    stroke: #FFFFFF !important;
    color: #FFFFFF !important;
}

/* For stroke-based icons (email, copy), fill should be none */
.aiwp-selection-share__btn--email svg,
.aiwp-selection-share__btn--copy svg {
    fill: none !important;
    stroke: #FFFFFF !important;
}

.aiwp-selection-share__btn:hover {
    transform: translateY(-2px) !important;
}

.aiwp-selection-share__btn:focus-visible {
    outline: 3px solid var(--color-primary, #0066CC) !important;
    outline-offset: 2px !important;
}

/* Twitter/X - Official Black */
.aiwp-selection-share__btn--twitter {
    background: #000000 !important;
    color: #FFFFFF !important;
}
.aiwp-selection-share__btn--twitter:hover {
    background: #1a1a1a !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Facebook - Official Blue */
.aiwp-selection-share__btn--facebook {
    background: #1877F2 !important;
    color: #FFFFFF !important;
}
.aiwp-selection-share__btn--facebook:hover {
    background: #166FE5 !important;
    box-shadow: 0 4px 12px rgba(24, 119, 242, 0.4) !important;
}

/* LinkedIn - Official Blue */
.aiwp-selection-share__btn--linkedin {
    background: #0A66C2 !important;
    color: #FFFFFF !important;
}
.aiwp-selection-share__btn--linkedin:hover {
    background: #004182 !important;
    box-shadow: 0 4px 12px rgba(10, 102, 194, 0.4) !important;
}

/* WhatsApp - Official Green */
.aiwp-selection-share__btn--whatsapp {
    background: #25D366 !important;
    color: #FFFFFF !important;
}
.aiwp-selection-share__btn--whatsapp:hover {
    background: #128C7E !important;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4) !important;
}

/* Email - Purple accent */
.aiwp-selection-share__btn--email {
    background: #8B5CF6 !important;
    color: #FFFFFF !important;
}
.aiwp-selection-share__btn--email:hover {
    background: #7C3AED !important;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4) !important;
}

/* Copy - Primary brand color */
.aiwp-selection-share__btn--copy {
    background: var(--color-primary, #0066CC) !important;
    color: #FFFFFF !important;
}
.aiwp-selection-share__btn--copy:hover {
    background: var(--color-primary-hover, #004D99) !important;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4) !important;
}
.aiwp-selection-share__btn--copy.copied {
    background: var(--color-success, #10B981) !important;
}

/* Legacy single-tweet button - DEPRECATED but kept for backwards compatibility */
.aiwp-selection-tweet {
    position: fixed !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 10px 16px !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em !important;
    line-height: 1 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    
    /* X/Twitter official black */
    background: #000000 !important;
    color: #FFFFFF !important;
    border: none !important;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.15) !important;
    
    z-index: 1200;
    transition: all 0.2s ease !important;
}

.aiwp-selection-tweet::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFFFFF'%3E%3Cpath d='M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.aiwp-selection-tweet.is-visible {
    display: inline-flex !important;
}

.aiwp-selection-tweet:hover {
    background: #1a1a1a !important;
    transform: translateY(-2px) !important;
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.3),
        0 6px 16px rgba(0, 0, 0, 0.2) !important;
}

.aiwp-selection-tweet:focus-visible {
    outline: 3px solid var(--color-primary) !important;
    outline-offset: 3px !important;
}

/* ============ SOCIAL SHARE BUTTONS - OFFICIAL BRAND COLORS ============ */
/* Using official brand colors for each platform */

/* Twitter/X - Official Black */
.social-share__link--twitter,
[class*="social-share__link--twitter"] {
    background: #000000 !important;
    color: #FFFFFF !important;
}

.social-share__link--twitter:hover,
[class*="social-share__link--twitter"]:hover {
    background: #1a1a1a !important;
}

/* Facebook - Official Blue #1877F2 */
.social-share__link--facebook,
[class*="social-share__link--facebook"] {
    background: #1877F2 !important;
    color: #FFFFFF !important;
}

.social-share__link--facebook:hover,
[class*="social-share__link--facebook"]:hover {
    background: #166FE5 !important;
}

/* LinkedIn - Official Blue #0A66C2 */
.social-share__link--linkedin,
[class*="social-share__link--linkedin"] {
    background: #0A66C2 !important;
    color: #FFFFFF !important;
}

.social-share__link--linkedin:hover,
[class*="social-share__link--linkedin"]:hover {
    background: #004182 !important;
}

/* WhatsApp - Official Green #25D366 */
.social-share__link--whatsapp,
[class*="social-share__link--whatsapp"] {
    background: #25D366 !important;
    color: #FFFFFF !important;
}

.social-share__link--whatsapp:hover,
[class*="social-share__link--whatsapp"]:hover {
    background: #128C7E !important;
}

/* Email - Purple accent */
.social-share__link--email,
[class*="social-share__link--email"] {
    background: #8B5CF6 !important;
    color: #FFFFFF !important;
}

.social-share__link--email:hover,
[class*="social-share__link--email"]:hover {
    background: #7C3AED !important;
}

/* Copy Link - Primary brand color */
.social-share__link--copy,
[class*="social-share__link--copy"] {
    background: var(--color-primary, #0066CC) !important;
    color: #FFFFFF !important;
    border: none !important;
}

.social-share__link--copy:hover,
[class*="social-share__link--copy"]:hover {
    background: var(--color-primary-hover, #004D99) !important;
}

.social-share__link--copy.copied,
[class*="social-share__link--copy"].copied {
    background: var(--color-success, #10B981) !important;
}

/* Ensure SVG icons are visible and properly sized */
.social-share__link svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
}

.social-share__link svg[fill="currentColor"] {
    fill: currentColor !important;
}

.social-share__link svg[fill="none"] {
    fill: none !important;
    stroke: currentColor !important;
}

/* ============ SIDEBAR SHARE RAIL ============ */
/* Ensure sidebar share buttons are properly styled */

.aiwp-rail-share {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--space-2) !important;
}

.aiwp-rail-share .social-share__link {
    width: 100% !important;
    justify-content: flex-start !important;
    padding: var(--space-3) var(--space-4) !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
}

/* ============ RESPONSIVE - TABLET (768px - 1023px) ============ */
@media (min-width: 768px) and (max-width: 1023px) {
    .synth-stats-grid,
    [class*="stats-grid"],
    .aiwp-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        max-width: 600px !important;
    }
    
    .synth-stat-card,
    [class*="stat-card"],
    .aiwp-stat-item {
        padding: var(--space-5) var(--space-3) !important;
    }
    
    .synth-stat-value,
    [class*="stat-value"],
    .aiwp-stat-value {
        font-size: 2.5rem !important;
    }
}

/* ============ RESPONSIVE - MOBILE (< 768px) ============ */
@media (max-width: 767px) {
    /* Stats grid - single column on mobile for legibility */
    .synth-stats-grid,
    [class*="stats-grid"],
    .aiwp-stats-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-3) !important;
        max-width: 100% !important;
        padding: 0 var(--space-2) !important;
    }
    
    .synth-stat-card,
    [class*="stat-card"],
    .aiwp-stat-item {
        padding: var(--space-4) var(--space-2) !important;
        min-height: 100px !important;
    }
    
    .synth-stat-value,
    [class*="stat-value"],
    .aiwp-stat-value {
        font-size: 2rem !important;
    }
    
    .synth-stat-label,
    [class*="stat-label"],
    .aiwp-stat-label {
        font-size: 0.65rem !important;
        letter-spacing: 0.08em !important;
    }
    
    /* Tweet button - larger touch target */
    .aiwp-selection-tweet {
        padding: 12px 18px !important;
        font-size: 15px !important;
        border-radius: 14px !important;
    }
    
    .aiwp-selection-tweet::before {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* Full social share popup - mobile optimized */
    .aiwp-selection-share {
        gap: 3px !important;
        padding: 6px 8px !important;
        border-radius: 10px !important;
    }
    
    .aiwp-selection-share__btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 8px !important;
    }
    
    .aiwp-selection-share__btn svg {
        width: 18px !important;
        height: 18px !important;
        /* ALWAYS VISIBLE: Maintain icon visibility on mobile */
        fill: #FFFFFF !important;
        stroke: #FFFFFF !important;
        color: #FFFFFF !important;
    }
    
    /* For stroke-based icons (email, copy), fill should be none */
    .aiwp-selection-share__btn--email svg,
    .aiwp-selection-share__btn--copy svg {
        fill: none !important;
        stroke: #FFFFFF !important;
    }
    
    /* Social share - full width buttons */
    .social-sharing__links {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: var(--space-2) !important;
    }
    
    .social-share__link {
        width: 100% !important;
        justify-content: center !important;
        padding: var(--space-3) var(--space-4) !important;
        min-height: 48px !important; /* Touch-friendly */
    }
}

/* ============ RESPONSIVE - SMALL MOBILE (< 480px) ============ */
@media (max-width: 479px) {
    .synth-stats-grid,
    [class*="stats-grid"],
    .aiwp-stats-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-2) !important;
    }
    
    .synth-stat-value,
    [class*="stat-value"],
    .aiwp-stat-value {
        font-size: 1.75rem !important;
    }
    
    .synth-stat-label,
    [class*="stat-label"],
    .aiwp-stat-label {
        font-size: 0.6rem !important;
    }
}

/* ============ DARK MODE ADJUSTMENTS ============ */
/* Full social share popup - dark mode */
:root[data-theme="dark"] .aiwp-selection-share {
    background: #1a1a1a !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

/* Dark mode - icons remain white on colored backgrounds (default) */
/* Twitter button is inverted in dark mode (white bg, black icon) */
:root[data-theme="dark"] .aiwp-selection-share__btn--twitter {
    background: #FFFFFF !important;
    color: #000000 !important;
}
:root[data-theme="dark"] .aiwp-selection-share__btn--twitter svg {
    fill: #000000 !important;
    stroke: #000000 !important;
    color: #000000 !important;
}
:root[data-theme="dark"] .aiwp-selection-share__btn--twitter:hover {
    background: #E5E5E5 !important;
}

/* Legacy tweet button - dark mode */
:root[data-theme="dark"] .aiwp-selection-tweet {
    background: #FFFFFF !important;
    color: #000000 !important;
}

:root[data-theme="dark"] .aiwp-selection-tweet::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000000'%3E%3Cpath d='M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] .aiwp-selection-tweet:hover {
    background: #E5E5E5 !important;
}

:root[data-theme="dark"] .synth-stat-card,
:root[data-theme="dark"] [class*="stat-card"],
:root[data-theme="dark"] .aiwp-stat-item {
    background: var(--color-surface-dark, #1a1a1a) !important;
    border-color: var(--color-border-dark, #333) !important;
}

/* ============ PRINT STYLES ============ */
@media print {
    .aiwp-selection-tweet,
    .social-sharing,
    .aiwp-rail-share {
        display: none !important;
    }
}
