/* Custom CSS using the specified color palette */

:root {
    --primary-color: #0A1C2E;
    --secondary-color: #2D6A9F;
    --accent-color: #E63946;
    --bg-light: #FFFFFF;
    --bg-gray: #F5F5F5;
    --text-dark: #1A1A1A;
    --text-muted: #6C757D;
    --border-color: #DDDDDD;
}

/* Override Bootstrap primary colors */
.bg-primary { background-color: var(--primary-color) !important; }
.text-primary { color: var(--primary-color) !important; }
.btn-primary { 
    background-color: var(--primary-color); 
    border-color: var(--primary-color); 
}
.btn-primary:hover { 
    background-color: #083247; 
    border-color: #083247; 
}

.bg-secondary { background-color: var(--secondary-color) !important; }
.text-secondary { color: var(--secondary-color) !important; }
.btn-secondary { 
    background-color: var(--secondary-color); 
    border-color: var(--secondary-color); 
}

.bg-accent { background-color: var(--accent-color) !important; }
.text-accent { color: var(--accent-color) !important; }
.btn-accent { 
    background-color: var(--accent-color); 
    border-color: var(--accent-color); 
    color: white;
}
.btn-accent:hover { 
    background-color: #d62533; 
    border-color: #d62533; 
    color: white;
}

/* Typography */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
}

.section-title {
    position: relative;
    padding-bottom: 0.5rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background-color: var(--accent-color);
}

/* Navigation */
.navbar-brand {
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--bg-gray) 0%, #e8f4f8 100%);
}

.hero-main-image {
    transition: transform 0.3s ease;
}

.hero-main-article:hover .hero-main-image {
    transform: scale(1.05);
}

.hero-overlay {
    background: linear-gradient(
        0deg,
        rgba(10, 28, 46, 0.8) 0%,
        rgba(10, 28, 46, 0.4) 40%,
        transparent 100%
    );
}

.hero-title a:hover {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Article Cards */
.article-card {
    transition: all 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.article-image-container {
    height: 200px;
    position: relative;
}

.article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.article-card:hover .article-image {
    transform: scale(1.05);
}

.category-badge {
    z-index: 2;
}

.card-meta {
    border-color: var(--border-color) !important;
}

/* Content Sections */
.content-section {
    scroll-margin-top: 100px; /* Account for sticky navbar */
}

/* Newsletter Section */
.newsletter-section {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
}

.newsletter-content .form-control {
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
}

.newsletter-content .form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(230, 57, 70, 0.25);
    border-color: var(--accent-color);
}

/* Footer */
footer {
    background-color: var(--primary-color) !important;
}

footer .social-links a {
    transition: color 0.3s ease;
}

footer .social-links a:hover {
    color: var(--accent-color) !important;
}

/* Search Results */
.search-header {
    background-color: var(--bg-gray);
    border-bottom: 1px solid var(--border-color);
}

.search-filters .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Article Detail */
.article-header {
    background: linear-gradient(135deg, var(--bg-gray) 0%, #e8f4f8 100%);
}

.article-meta {
    color: var(--text-muted);
}

.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.article-content h1,
.article-content h2,
.article-content h3 {
    color: var(--primary-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-title {
        font-size: 1.5rem !important;
    }
    
    .hero-teaser {
        font-size: 0.9rem;
    }
    
    .newsletter-content .btn {
        width: 100%;
    }
    
    .article-image-container {
        height: 150px;
    }
}

@media (max-width: 576px) {
    .hero-overlay {
        position: static !important;
        background: rgba(10, 28, 46, 0.9) !important;
    }
    
    .hero-main-image {
        height: 200px !important;
    }
    
    .section-title {
        font-size: 1.25rem;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
.form-control:focus,
.btn:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 9999;
    border-radius: 4px;
}

.skip-link:focus {
    top: 6px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Advertisement Styles */
.ad-container {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.ad-container::before {
    content: "Advertisement";
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #6c757d;
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ad-placeholder {
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border: 2px dashed #dee2e6;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-weight: 500;
    min-height: 200px;
}

/* Sidebar Ads */
.sidebar-ad {
    position: sticky;
    top: 80px;
    z-index: 100;
}

.sidebar-ad .ad-container {
    width: 160px;
    margin: 0 auto;
}

.sidebar-ad-left {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
}

.sidebar-ad-right {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
}

/* Article Middle Ad */
.article-middle-ad {
    margin: 40px 0;
    padding: 20px 0;
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
}

.article-middle-ad .ad-container {
    max-width: 728px;
    margin: 0 auto;
}

/* Bottom Sticky Ad */
.bottom-sticky-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    border-top: 2px solid #e9ecef;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    padding: 10px 0;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.bottom-sticky-ad.show {
    transform: translateY(0);
}

.bottom-sticky-ad .ad-container {
    margin: 0;
    background-color: transparent;
    border: none;
    padding: 0;
}

.bottom-sticky-ad .ad-container::before {
    display: none;
}

.bottom-sticky-ad .ad-placeholder {
    min-height: 90px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.bottom-sticky-ad .close-ad {
    position: absolute;
    top: 5px;
    right: 15px;
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    z-index: 1051;
}

.bottom-sticky-ad .close-ad:hover {
    color: #495057;
}

/* Responsive Design for Ads */
@media (max-width: 1400px) {
    .sidebar-ad-left,
    .sidebar-ad-right {
        display: none;
    }
}

@media (max-width: 768px) {
    .article-middle-ad .ad-container {
        max-width: 320px;
    }
    
    .bottom-sticky-ad .ad-placeholder {
        min-height: 60px;
    }
    
    .sidebar-ad {
        position: static;
        margin: 20px 0;
    }
    
    .sidebar-ad .ad-container {
        width: 100%;
        max-width: 320px;
    }
}

@media (max-width: 576px) {
    .bottom-sticky-ad {
        padding: 5px 0;
    }
    
    .bottom-sticky-ad .ad-placeholder {
        min-height: 50px;
        font-size: 12px;
    }
}

/* Print styles */
@media print {
    .navbar,
    .footer,
    .newsletter-section,
    .btn,
    .social-links,
    .ad-container,
    .sidebar-ad,
    .article-middle-ad,
    .bottom-sticky-ad {
        display: none !important;
    }
    
    .article-content {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* Article Detail Page Specifi... color: #e2e2e2; } }
/* Article Detail Page Specific Styles */

/* Article Header */
.article-header {
    padding: 2rem 0;
    background: linear-gradient(135deg, var(--bg-gray) 0%, #e8f4f8 100%);
}

.article-title {
    font-size: 2.5rem;
    line-height: 1.2;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted);
}

/* Article Content Styling */
.article-content .rich-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-dark);
}

.article-content .rich-text h2 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.article-content .rich-text h3 {
    font-size: 1.5rem;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.article-content .rich-text h4 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.article-content .rich-text p {
    margin-bottom: 1.5rem;
}

.article-content .rich-text ul,
.article-content .rich-text ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.article-content .rich-text li {
    margin-bottom: 0.5rem;
}

.article-content .rich-text blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    background-color: var(--bg-gray);
    font-style: italic;
}

.article-content .rich-text pre {
    background-color: #f8f9fa;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
}

.article-content .rich-text code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875em;
}

.article-content .rich-text img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: 0.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.article-content .rich-text figcaption {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

.article-content .rich-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

.article-content .rich-text th,
.article-content .rich-text td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

.article-content .rich-text th {
    background-color: var(--bg-gray);
}

/* Streamlit iframe styling */
.streamlit-iframe {
    width: 100%;
    min-height: 600px;
    border: none;
    border-radius: 0.25rem;
}

/* Contents offcanvas */
#article-toc ul {
    margin-top: 1rem;
}

#article-toc a {
    display: block;
    padding: 0.5rem 0;
    color: var(--text-dark);
}

#article-toc a:hover {
    color: var(--secondary-color);
}

/* Author Bio Card */
.author-bio .card {
    background-color: #f8f9fa;
}

/* Tags */
.article-tags .badge {
    font-weight: normal;
    transition: all 0.2s ease;
}

.article-tags .badge:hover {
    background-color: var(--secondary-color) !important;
    color: white !important;
}

/* Sticky contents bar */
.contents-bar.sticky-top {
    top: 56px; /* Adjust based on navbar height */
    z-index: 999;
    transition: box-shadow 0.3s ease;
}

/* Social share buttons */
.social-share button {
    transition: all 0.2s ease;
}

.social-share button:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* Related Articles */
.related-articles .article-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.related-articles .article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1) !important;
}

/* Responsive styling */
@media (max-width: 991px) {
    .article-title {
        font-size: 2rem;
    }
    
    .article-content .rich-text h2 {
        font-size: 1.6rem;
    }
    
    .article-content .rich-text h3 {
        font-size: 1.3rem;
    }
}

@media (max-width: 767px) {
    .article-title {
        font-size: 1.75rem;
    }
    
    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .related-articles .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .related-articles .col {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

@media (max-width: 576px) {
    .article-header {
        padding: 1.5rem 0;
    }
    
    .article-title {
        font-size: 1.5rem;
    }
    
    .article-content .rich-text {
        font-size: 1rem;
    }
    
    .streamlit-iframe {
        min-height: 400px;
    }
    
    .social-share {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }
    
    .social-share button {
        flex-shrink: 0;
    }
}

/* Print styles */
@media print {
    .contents-bar,
    .social-share,
    .newsletter-section,
    .related-articles,
    .author-bio .author-social {
        display: none;
    }
    
    .article-title {
        font-size: 24pt;
    }
    
    .article-content .rich-text {
        font-size: 12pt;
        line-height: 1.5;
    }
}

/* Consent Checkboxes Styling */
.consent-section {
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.consent-section h5 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.consent-checkbox {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.consent-checkbox:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 2px 8px rgba(45, 106, 159, 0.1);
}

.consent-checkbox .form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-right: 0.75rem;
    border: 2px solid var(--secondary-color);
}

.consent-checkbox .form-check-input:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.consent-checkbox .form-check-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.25rem rgba(230, 57, 70, 0.25);
}

.consent-checkbox .form-check-label {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-dark);
    cursor: pointer;
    margin-bottom: 0;
}

.consent-checkbox .form-check-label strong {
    color: var(--primary-color);
}

/* Required field indicator */
.consent-checkbox::before {
    content: "*";
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.2rem;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.consent-checkbox {
    position: relative;
}

/* Error state for consent checkboxes */
.consent-checkbox.error {
    border-color: var(--accent-color);
    background-color: #fff5f5;
}

.consent-checkbox.error .form-check-label {
    color: var(--accent-color);
}

/* Success state when checked */
.consent-checkbox.checked {
    border-color: #28a745;
    background-color: #f8fff9;
}

.consent-checkbox.checked::before {
    content: "✓";
    color: #28a745;
}

/* Responsive design for consent checkboxes */
@media (max-width: 768px) {
    .consent-section {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .consent-checkbox {
        padding: 0.75rem;
    }
    
    .consent-checkbox .form-check-label {
        font-size: 0.9rem;
    }
}

/* Dark mode support (for future use) */
@media (prefers-color-scheme: dark) {
    body.dark-mode .article-content .rich-text {
        color: #e2e2e2;
    }
    
    body.dark-mode .article-header {
        background: linear-gradient(135deg, #1a1a1a 0%, #0A1C2E 100%);
    }
    
    body.dark-mode .article-title,
    body.dark-mode .breadcrumb-item a,
    body.dark-mode .article-meta a {
        color: #e2e2e2;
    }
    
    body.dark-mode .consent-section {
        background-color: #2d3748;
        border-color: #4a5568;
    }
    
    body.dark-mode .consent-checkbox {
        background-color: #1a202c;
        border-color: #4a5568;
    }
    
    body.dark-mode .consent-checkbox .form-check-label {
        color: #e2e8f0;
    }
}
