/**
 * PRNewsPlus - Main Stylesheet (OPTIMIZED VERSION)
 * Optimized for Mobile Performance
 * Version: 2.2.1
 *
 * IMPROVEMENTS:
 * - Reduced !important from 72 to 0
 * - Added CSS custom properties
 * - Better specificity management
 * - Improved cascade
 */

/* ========================================
   CSS Custom Properties (Variables)
   ======================================== */
:root {
    /* Category Badge Colors */
    --badge-green-bg: #dcfce7;
    --badge-green-text: #15803d;
    --badge-green-border: #86efac;

    --badge-blue-bg: #dbeafe;
    --badge-blue-text: #1d4ed8;
    --badge-blue-border: #93c5fd;

    --badge-orange-bg: #ffedd5;
    --badge-orange-text: #c2410c;
    --badge-orange-border: #fdba74;

    --badge-red-bg: #fee2e2;
    --badge-red-text: #b91c1c;
    --badge-red-border: #fca5a5;

    --badge-purple-bg: #f3e8ff;
    --badge-purple-text: #7c3aed;
    --badge-purple-border: #c4b5fd;

    --badge-pink-bg: #fce7f3;
    --badge-pink-text: #be185d;
    --badge-pink-border: #f9a8d4;

    --badge-yellow-bg: #fef9c3;
    --badge-yellow-text: #a16207;
    --badge-yellow-border: #fde047;

    --badge-indigo-bg: #e0e7ff;
    --badge-indigo-text: #4338ca;
    --badge-indigo-border: #a5b4fc;

    --badge-teal-bg: #ccfbf1;
    --badge-teal-text: #0f766e;
    --badge-teal-border: #5eead4;

    --badge-cyan-bg: #cffafe;
    --badge-cyan-text: #0e7490;
    --badge-cyan-border: #67e8f9;

    --badge-default-bg: #f3f4f6;
    --badge-default-text: #374151;
    --badge-default-border: #d1d5db;

    --badge-amber-bg: #fef3c7;
    --badge-amber-text: #b45309;
    --badge-amber-border: #fcd34d;

    /* Gradients */
    --gradient-sponsored: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-table-header: linear-gradient(135deg, #0F2C59, #365486);
    --gradient-quote-orange: #FF6C22;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ========================================
   Category Badges (OPTIMIZED - No !important)
   ======================================== */
.sponsored-badge {
    background: var(--gradient-sponsored);
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: transform var(--transition-fast),
                filter var(--transition-fast);
    white-space: nowrap;
}

/* Mobile: slightly smaller font */
@media (max-width: 640px) {
    .category-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }
}

.category-badge:hover {
    transform: translateY(-1px);
    filter: brightness(0.95);
}

/* Category Badge Colors - Using Cascade Instead of !important */
.category-badge--green {
    background-color: var(--badge-green-bg);
    color: var(--badge-green-text);
    border-color: var(--badge-green-border);
}

.category-badge--blue {
    background-color: var(--badge-blue-bg);
    color: var(--badge-blue-text);
    border-color: var(--badge-blue-border);
}

.category-badge--orange {
    background-color: var(--badge-orange-bg);
    color: var(--badge-orange-text);
    border-color: var(--badge-orange-border);
}

.category-badge--red {
    background-color: var(--badge-red-bg);
    color: var(--badge-red-text);
    border-color: var(--badge-red-border);
}

.category-badge--purple {
    background-color: var(--badge-purple-bg);
    color: var(--badge-purple-text);
    border-color: var(--badge-purple-border);
}

.category-badge--pink {
    background-color: var(--badge-pink-bg);
    color: var(--badge-pink-text);
    border-color: var(--badge-pink-border);
}

.category-badge--yellow {
    background-color: var(--badge-yellow-bg);
    color: var(--badge-yellow-text);
    border-color: var(--badge-yellow-border);
}

.category-badge--indigo {
    background-color: var(--badge-indigo-bg);
    color: var(--badge-indigo-text);
    border-color: var(--badge-indigo-border);
}

.category-badge--teal {
    background-color: var(--badge-teal-bg);
    color: var(--badge-teal-text);
    border-color: var(--badge-teal-border);
}

.category-badge--cyan {
    background-color: var(--badge-cyan-bg);
    color: var(--badge-cyan-text);
    border-color: var(--badge-cyan-border);
}

.category-badge--default {
    background-color: var(--badge-default-bg);
    color: var(--badge-default-text);
    border-color: var(--badge-default-border);
}

.category-badge--amber {
    background-color: var(--badge-amber-bg);
    color: var(--badge-amber-text);
    border-color: var(--badge-amber-border);
}

/* White badge for dark backgrounds - Higher specificity */
.category-badge--white {
    background-color: white;
    color: var(--badge-default-text);
}

/* ========================================
   Hover Effects
   ======================================== */
.group:hover .group-hover\:visible {
    visibility: visible;
}
.group:hover .group-hover\:opacity-100 {
    opacity: 1;
}
.group:hover .group-hover\:translate-y-0 {
    transform: translateY(0);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    transition: all var(--transition-normal);
}

/* ========================================
   Swiper Customization
   ======================================== */
.swiper-button-next,
.swiper-button-prev {
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 24px;
    border-radius: 50%;
}
.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 16px;
}

/* ========================================
   News List Cards
   ======================================== */
.news-list-card {
    transition: background-color var(--transition-fast);
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
}
.news-list-card:last-child {
    border-bottom: none;
}
.news-list-card:hover {
    background: #fafafa;
}
.news-list-card:hover .news-list-thumb img {
    transform: scale(1.03);
}
.news-list-card:hover .news-list-title {
    color: #0F2C59;
}

/* News List Card Thumbnail */
.news-list-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f8fafc;
}
.news-list-thumb img {
    transition: transform var(--transition-slow);
}

/* Smaller Sidebar Card Thumbnail */
.news-list-thumb-sm {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 0.375rem;
    overflow: hidden;
    background: #f8fafc;
}
.news-list-thumb-sm img {
    transition: transform var(--transition-slow);
}
.news-list-card:hover .news-list-thumb-sm img {
    transform: scale(1.03);
}

/* News List Title */
.news-list-title {
    font-weight: 500;
    color: #1e293b;
    line-height: 1.4;
    transition: color var(--transition-fast);
}

/* News List Meta */
.news-list-meta {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* Responsive Thumbnails */
@media (max-width: 768px) {
    .news-list-thumb {
        width: 100px;
        height: 67px;
    }
}
@media (max-width: 640px) {
    .news-list-thumb {
        width: 88px;
        height: 59px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .news-list-card {
        border-bottom-color: #334155;
    }
    .news-list-card:hover {
        background: #1e293b;
    }
    .news-list-card .news-list-title {
        color: #e2e8f0;
    }
    .news-list-card:hover .news-list-title {
        color: #60a5fa;
    }
    .news-list-card .news-list-meta {
        color: #64748b;
    }
    .news-list-thumb,
    .news-list-thumb-sm {
        background: #334155;
    }
}

.dark .news-list-card {
    border-bottom-color: #334155;
}
.dark .news-list-card:hover {
    background: #1e293b;
}
.dark .news-list-card .news-list-title {
    color: #e2e8f0;
}
.dark .news-list-card:hover .news-list-title {
    color: #60a5fa;
}
.dark .news-list-card .news-list-meta {
    color: #64748b;
}
.dark .news-list-thumb,
.dark .news-list-thumb-sm {
    background: #334155;
}

/* ========================================
   Article Content (Prose Styles)
   ======================================== */
.prose {
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    color: #374151;
    line-height: 1.9;
    max-width: 100%;
}

#article-content.prose {
    max-width: 100%;
}

/* Headings */
.prose h2 {
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    font-weight: 600;
    font-size: 1.5rem;
    color: #0F2C59;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--badge-orange-text);
    display: inline-block;
}
.prose h2.flex {
    display: flex;
}
.prose h3 {
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    font-weight: 600;
    font-size: 1.25rem;
    color: #0F2C59;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}
.prose h4 {
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    font-weight: 600;
    font-size: 1.125rem;
    color: #365486;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Paragraphs */
.prose p {
    margin-bottom: 1.25rem;
    text-align: justify;
}
.prose p:first-of-type {
    font-size: 1.125rem;
    color: #1f2937;
}

.prose > p:first-of-type::first-letter {
    float: left;
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--badge-orange-text);
    line-height: 1;
    margin-right: 0.5rem;
    margin-top: 0.1rem;
}

/* Lists */
.prose ul {
    list-style: none;
    padding-left: 0;
    margin: 1.5rem 0;
}
.prose ul li {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 0.75rem;
}
.prose ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6rem;
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--badge-orange-text), #FFA500);
    border-radius: 50%;
}
.prose ol {
    counter-reset: item;
    list-style: none;
    padding-left: 0;
    margin: 1.5rem 0;
}
.prose ol li {
    position: relative;
    padding-left: 2.5rem;
    margin-bottom: 0.75rem;
    counter-increment: item;
}
.prose ol li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 0;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--gradient-table-header);
    color: white;
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Blockquotes */
.prose blockquote {
    border-left: 4px solid var(--badge-orange-text);
    background: linear-gradient(to right, #FFF7ED, transparent);
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    margin: 2rem 0;
    font-style: italic;
    font-size: 1.1rem;
    color: #374151;
    border-radius: 0 0.75rem 0.75rem 0;
    position: relative;
}
.prose blockquote::before {
    content: '"';
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", serif;
    font-size: 4rem;
    color: var(--badge-orange-text);
    opacity: 0.3;
    position: absolute;
    top: -0.5rem;
    left: 0.5rem;
    line-height: 1;
}
.prose blockquote p {
    margin-bottom: 0;
}

/* Links */
.prose a {
    color: var(--badge-orange-text);
    text-decoration: none;
    border-bottom: 1px dashed var(--badge-orange-text);
    transition: all var(--transition-fast);
}
.prose a:hover {
    color: #0F2C59;
    border-bottom-color: #0F2C59;
    border-bottom-style: solid;
}

/* Strong/Bold */
.prose strong {
    font-weight: 600;
    color: #1f2937;
}

/* Images */
.prose img {
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin: 2rem auto;
    display: block;
    max-width: 100%;
    height: auto;
}
.prose figure {
    margin: 2rem 0;
}
.prose figcaption {
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.75rem;
    font-style: italic;
}

/* Code */
.prose code {
    background: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.875em;
    color: #e11d48;
}
.prose pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 1.5rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}
.prose pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Tables */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}
.prose thead {
    background: var(--gradient-table-header);
    color: white;
}
.prose th {
    font-family: "Google Sans", "Sarabun", "IBM Plex Sans Thai", sans-serif;
    font-weight: 600;
    padding: 1rem;
    text-align: left;
}
.prose td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.prose tbody tr:hover {
    background: #f9fafb;
}

/* HR */
.prose hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #e5e7eb, transparent);
    margin: 3rem 0;
}

/* Info Boxes */
.prose .info-box,
.prose .note {
    background: linear-gradient(to right, #EBF5FF, #F0F9FF);
    border-left: 4px solid #3B82F6;
    padding: 1.25rem 1.5rem;
    border-radius: 0 0.5rem 0.5rem 0;
    margin: 1.5rem 0;
}
.prose .warning-box {
    background: linear-gradient(to right, #FEF3C7, #FFFBEB);
    border-left: 4px solid #F59E0B;
}
.prose .success-box {
    background: linear-gradient(to right, #D1FAE5, #ECFDF5);
    border-left: 4px solid #10B981;
}

/* Video */
.prose iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 0.75rem;
    margin: 2rem 0;
}

/* Print */
@media print {
    .prose {
        font-size: 12pt;
        line-height: 1.6;
    }
    .prose h2, .prose h3 {
        page-break-after: avoid;
    }
    .prose img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}

/* ========================================
   Policy Pages
   ======================================== */
.policy-content {
    font-size: 1rem;
    line-height: 1.8;
}

.policy-content .prose ul.list-disc {
    list-style: disc;
    padding-left: 1.5rem;
}
.policy-content .prose ul.list-disc li {
    padding-left: 0.25rem;
}
.policy-content .prose ul.list-disc li::before {
    display: none;
}

.policy-section-header {
    display: flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 0.75rem;
}
.policy-section-number {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    flex-shrink: 0;
}
.policy-section-title {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
}

.policy-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}
.policy-table-wrapper table {
    min-width: 500px;
}

.policy-alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
}

.policy-section {
    margin-bottom: 2.5rem;
    scroll-margin-top: 5rem;
}
.policy-section:last-child {
    margin-bottom: 0;
}

/* Policy Mobile Responsive */
@media (max-width: 768px) {
    .policy-content {
        font-size: 0.9375rem;
        line-height: 1.75;
    }
    .policy-section .pl-11 {
        padding-left: 0;
        margin-top: 1rem;
    }
    .policy-section h2 {
        font-size: 1.125rem;
    }
    .policy-section h3 {
        font-size: 1rem;
    }
    .policy-section h4 {
        font-size: 0.9375rem;
    }
    .policy-content .bg-white.p-8 {
        padding: 1.25rem;
    }
    .policy-table-wrapper th,
    .policy-table-wrapper td {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    .policy-alert {
        padding: 0.875rem 1rem;
    }
    .policy-content .grid.md\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .policy-toc .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .policy-content {
        font-size: 0.875rem;
    }
    .policy-section h2 {
        font-size: 1rem;
    }
    .policy-section-number {
        width: 1.75rem;
        height: 1.75rem;
        min-width: 1.75rem;
        font-size: 0.75rem;
    }
    .policy-content .bg-white.p-8 {
        padding: 1rem;
    }
    .policy-hero h1 {
        font-size: 1.5rem;
    }
}

.policy-content p {
    text-align: left;
    margin-bottom: 1rem;
}

.policy-content a {
    color: #0F2C59;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.policy-content a:hover {
    color: var(--badge-orange-text);
}

.policy-info-box {
    border-left-width: 4px;
    padding: 1rem 1.25rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

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

/* Line clamp utilities */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Policy line heights */
.policy-content .bg-red-50,
.policy-content .bg-amber-50,
.policy-content .bg-blue-50,
.policy-content .bg-green-50,
.policy-content .bg-gray-50,
.policy-content .bg-gray-100 {
    line-height: 1.5;
}
.policy-content .bg-red-50 p,
.policy-content .bg-red-50 li,
.policy-content .bg-amber-50 p,
.policy-content .bg-amber-50 li,
.policy-content .bg-blue-50 p,
.policy-content .bg-blue-50 li,
.policy-content .bg-green-50 p,
.policy-content .bg-green-50 li,
.policy-content .bg-gray-50 p,
.policy-content .bg-gray-50 li,
.policy-content .bg-gray-100 p,
.policy-content .bg-gray-100 li {
    line-height: 1.5;
}
