/* ── AA Writer V2 — Post Content Styles ──────────────────────
   Loaded on public post pages only (not admin).
   Improves: tables (responsive), blockquotes, lists.
──────────────────────────────────────────────────────────── */

/* ── Responsive Table Wrapper ────────────────────────────── */
.aaw2-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.75em 0;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    position: relative;
    max-width: 100%;
    /* Ensure smooth scrolling on all devices */
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #2271b1 #f0f0f0;
}

/* Custom scrollbar for webkit browsers */
.aaw2-table-wrap::-webkit-scrollbar {
    height: 8px;
}

.aaw2-table-wrap::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.aaw2-table-wrap::-webkit-scrollbar-thumb {
    background: #2271b1;
    border-radius: 4px;
}

.aaw2-table-wrap::-webkit-scrollbar-thumb:hover {
    background: #135e96;
}

/* ── Table Base Styles ───────────────────────────────────── */
.aaw2-table-wrap table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    line-height: 1.5;
    color: #1d2327 !important;
    background: #fff;
    margin: 0;
    table-layout: auto; /* Allow columns to size based on content */
}

.aaw2-table-wrap table thead {
    background: #1d2327 !important;
    color: #fff !important;
}

.aaw2-table-wrap table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
    white-space: nowrap; /* Prevent header wrapping on desktop */
    word-wrap: break-word;
    color: #fff !important;
    background: #1d2327 !important;
    border-bottom: 2px solid #e5e7eb;
    min-width: 120px;
}

.aaw2-table-wrap table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
    color: #1d2327 !important;
    background: transparent;
    white-space: normal;
    word-wrap: break-word;
    min-width: 120px;
}

.aaw2-table-wrap table tbody tr:last-child td {
    border-bottom: none;
}

.aaw2-table-wrap table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.aaw2-table-wrap table tbody tr:hover {
    background: #f0f4ff;
    transition: background 0.15s ease;
}

/* Links in tables */
.aaw2-table-wrap table a {
    color: #2271b1 !important;
    text-decoration: none;
}

.aaw2-table-wrap table a:hover {
    text-decoration: underline;
}

/* Strong/bold text in tables */
.aaw2-table-wrap table strong,
.aaw2-table-wrap table b {
    font-weight: 600;
    color: #1d2327 !important;
}

/* Scroll hint for mobile users */
.aaw2-table-wrap::after {
    content: '← Scroll →';
    display: none;
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: rgba(34, 113, 177, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
    animation: fadeInOut 3s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* ── Tablet (≤ 768px) ────────────────────────────────────── */
@media (max-width: 768px) {
    .aaw2-table-wrap {
        margin: 16px -15px; /* Extend to screen edges */
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: inset -10px 0 10px -10px rgba(0,0,0,0.15);
    }
    
    .aaw2-table-wrap::after {
        display: block;
    }
    
    .aaw2-table-wrap table {
        font-size: 14px;
        min-width: 600px; /* Force horizontal scroll for wide tables */
        /* Ensure table doesn't collapse on mobile */
        width: max-content;
    }
    
    .aaw2-table-wrap table th {
        white-space: normal; /* Allow wrapping on mobile */
        padding: 12px 14px;
        font-size: 13px;
        min-width: 100px;
        /* Ensure headers are readable */
        line-height: 1.4;
    }
    
    .aaw2-table-wrap table td {
        padding: 12px 14px;
        font-size: 13px;
        min-width: 100px;
        /* Better text wrapping on mobile */
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Sticky first column for context */
    .aaw2-table-wrap table th:first-child,
    .aaw2-table-wrap table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #fff;
        box-shadow: 2px 0 4px rgba(0,0,0,0.05);
        /* Ensure sticky column is always visible */
        min-width: 120px;
    }
    
    .aaw2-table-wrap table th:first-child {
        background: #1d2327 !important;
        z-index: 3;
    }
    
    .aaw2-table-wrap table tbody tr:nth-child(even) td:first-child {
        background: #f9fafb;
    }
    
    .aaw2-table-wrap table tbody tr:hover td:first-child {
        background: #f0f4ff;
    }
}

/* ── Mobile (≤ 480px) ────────────────────────────────────── */
@media (max-width: 480px) {
    .aaw2-table-wrap {
        margin: 16px -10px; /* Adjust for smaller screens */
    }
    
    .aaw2-table-wrap table {
        font-size: 13px;
        min-width: 500px; /* Ensure scroll on small screens */
        width: max-content; /* Prevent table collapse */
    }
    
    .aaw2-table-wrap table th,
    .aaw2-table-wrap table td {
        padding: 10px 12px;
        font-size: 12px;
        min-width: 90px;
        /* Enhanced text handling on small screens */
        line-height: 1.5;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ensure first column is wider on mobile for better context */
    .aaw2-table-wrap table th:first-child,
    .aaw2-table-wrap table td:first-child {
        min-width: 110px;
        max-width: 150px;
    }
    
    .aaw2-table-wrap::after {
        right: 10px;
        font-size: 10px;
        padding: 5px 10px;
    }
}

/* ── Extra Small Mobile (≤ 360px) ────────────────────────── */
@media (max-width: 360px) {
    .aaw2-table-wrap table {
        font-size: 12px;
        min-width: 450px;
    }
    
    .aaw2-table-wrap table th,
    .aaw2-table-wrap table td {
        padding: 8px 10px;
        font-size: 11px;
        min-width: 80px;
    }
    
    .aaw2-table-wrap table th:first-child,
    .aaw2-table-wrap table td:first-child {
        min-width: 100px;
        max-width: 130px;
    }
}

/* ── Blockquote — styled callout ─────────────────────────── */
.entry-content blockquote,
.post-content blockquote {
    margin: 1.75em 0;
    padding: 1em 1.25em 1em 1.5em;
    border-left: 4px solid #2271b1;
    background: #f0f6fc;
    border-radius: 0 6px 6px 0;
    font-style: normal;
    font-size: 1.02em;
    color: #1d2327;
    line-height: 1.7;
}

.entry-content blockquote p,
.post-content blockquote p {
    margin: 0 0 0.5em;
}

.entry-content blockquote p:last-child,
.post-content blockquote p:last-child {
    margin-bottom: 0;
}

.entry-content blockquote cite,
.post-content blockquote cite {
    display: block;
    margin-top: 0.6em;
    font-size: 0.85em;
    color: #646970;
    font-style: italic;
}

/* Callout variant (tip/note) — add class="aaw2-callout" */
.entry-content blockquote.aaw2-callout,
.post-content blockquote.aaw2-callout {
    border-left-color: #46b450;
    background: #edfaef;
}

/* ── Lists ───────────────────────────────────────────────── */
.entry-content ul,
.post-content ul {
    padding-left: 1.5em;
    margin: 0.75em 0 1.25em;
    list-style: none;
}

.entry-content ul li,
.post-content ul li {
    position: relative;
    padding-left: 1.2em;
    margin-bottom: 0.45em;
    line-height: 1.65;
}

.entry-content ul li::before,
.post-content ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #2271b1;
    font-size: 0.8em;
    top: 0.15em;
}

.entry-content ol,
.post-content ol {
    padding-left: 1.75em;
    margin: 0.75em 0 1.25em;
}

.entry-content ol li,
.post-content ol li {
    margin-bottom: 0.45em;
    line-height: 1.65;
    padding-left: 0.25em;
}

/* Nested lists */
.entry-content li ul,
.entry-content li ol,
.post-content li ul,
.post-content li ol {
    margin: 0.35em 0 0.35em;
}

/* ── Pull Quotes ─────────────────────────────────────────── */
.entry-content blockquote strong:first-child,
.post-content blockquote strong:first-child {
    display: block;
    margin-bottom: 0.5em;
}

.entry-content blockquote:has(strong:first-child),
.post-content blockquote:has(strong:first-child) {
    font-size: 1.3em;
    font-weight: 600;
    border-left: 4px solid #0073aa;
    padding: 20px 30px;
    margin: 30px 0;
    background: #f7f7f7;
    font-style: italic;
    line-height: 1.5;
}

/* ── Video Embeds ────────────────────────────────────────── */
.video-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    margin: 30px 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* ── At a Glance Boxes ───────────────────────────────────── */
.at-a-glance {
    background: #f8f9fa;
    border: 2px solid #0073aa;
    border-radius: 8px;
    padding: 20px 30px;
    margin: 30px 0;
}

.at-a-glance h3 {
    margin-top: 0;
    color: #0073aa;
    font-size: 1.3em;
    margin-bottom: 15px;
}

.at-a-glance ul {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.at-a-glance li {
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    line-height: 1.6;
}

.at-a-glance li:last-child {
    border-bottom: none;
}

.at-a-glance strong {
    color: #333;
    min-width: 100px;
    display: inline-block;
}

/* ── Comparison Table Enhancements ───────────────────────── */
.aaw2-table-wrap table td:last-child {
    font-weight: 600;
}

.aaw2-table-wrap table td:contains("✓") {
    color: #0073aa;
}

/* Mobile responsiveness for new elements */
@media (max-width: 768px) {
    .at-a-glance {
        padding: 15px 20px;
        margin: 20px 0;
    }
    
    .at-a-glance h3 {
        font-size: 1.2em;
    }
    
    .video-embed {
        margin: 20px 0;
    }
    
    .entry-content blockquote:has(strong:first-child),
    .post-content blockquote:has(strong:first-child) {
        font-size: 1.15em;
        padding: 15px 20px;
        margin: 20px 0;
    }
}

@media (max-width: 480px) {
    .at-a-glance {
        padding: 12px 15px;
    }
    
    .at-a-glance h3 {
        font-size: 1.1em;
    }
    
    .at-a-glance strong {
        min-width: 80px;
        font-size: 0.95em;
    }
}
