/* MyMoney — Main Stylesheet */

/* ===== Thai Font ===== */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --gradient-start: #6366f1;
    --gradient-mid: #8b5cf6;
    --gradient-end: #ec4899;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #f8fafc;
    color: var(--text-primary);
    line-height: 1.7;
}

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

/* ===== Selection ===== */
::selection {
    background: var(--primary-light);
    color: white;
}

/* ===== Header ===== */
.site-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
}

.site-header.scrolled {
    box-shadow: var(--shadow-md);
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.nav-link {
    position: relative;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-xs);
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Mobile menu */
.mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }
    .nav-desktop {
        display: none;
    }
    .nav-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding: 1rem;
        border-top: 1px solid var(--border-light);
    }
    .nav-mobile .nav-link {
        padding: 0.75rem 1rem;
        border-radius: var(--radius-sm);
    }
}

/* ===== Hero Section ===== */
.hero {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-mid) 50%, var(--gradient-end) 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, #f8fafc, transparent);
    pointer-events: none;
}

.hero-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
    animation: float 8s ease-in-out infinite;
}

.hero-blob-1 {
    width: 300px;
    height: 300px;
    background: #a78bfa;
    top: -50px;
    right: -50px;
    animation-delay: 0s;
}

.hero-blob-2 {
    width: 200px;
    height: 200px;
    background: #f472b6;
    bottom: -30px;
    left: 10%;
    animation-delay: -3s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.05); }
}

/* ===== Article Cards ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

.card-image {
    height: 200px;
    background: linear-gradient(135deg, #e0e7ff, #fce7f3, #ede9fe);
    position: relative;
    overflow: hidden;
}

.card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.03));
}

.card-image .card-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.3;
}

.card-body {
    padding: 1.25rem 1.5rem 1.5rem;
}

.card-category {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.1));
    color: var(--primary);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0.75rem 0 0.5rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.card:hover .card-title {
    color: var(--primary);
}

.card-excerpt {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Featured card (first card, larger) */
.card-featured {
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .card-featured {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .card-featured .card-image {
        height: 100%;
        min-height: 280px;
    }
    .card-featured .card-body {
        padding: 2rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .card-featured .card-title {
        font-size: 1.5rem;
        -webkit-line-clamp: 3;
    }
    .card-featured .card-excerpt {
        -webkit-line-clamp: 4;
    }
}

/* ===== Category Badges ===== */
.badge-tech { background: rgba(59,130,246,0.1); color: #3b82f6; }
.badge-finance { background: rgba(16,185,129,0.1); color: #10b981; }
.badge-health { background: rgba(239,68,68,0.1); color: #ef4444; }
.badge-lifestyle { background: rgba(245,158,11,0.1); color: #f59e0b; }
.badge-entertainment { background: rgba(168,85,247,0.1); color: #a855f7; }
.badge-education { background: rgba(14,165,233,0.1); color: #0ea5e9; }

/* Category icons */
.cat-icon-tech::before { content: '\1F4BB'; }
.cat-icon-finance::before { content: '\1F4B0'; }
.cat-icon-health::before { content: '\1F3E5'; }
.cat-icon-lifestyle::before { content: '\2728'; }

/* ===== Trending Bar ===== */
.trending-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    overflow: hidden;
}

.trending-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.75rem 0;
}

.trending-scroll::-webkit-scrollbar {
    display: none;
}

.trending-tag {
    flex-shrink: 0;
    padding: 0.375rem 1rem;
    border-radius: 100px;
    background: var(--border-light);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.trending-tag:hover {
    background: var(--primary);
    color: white;
}

/* ===== Article Detail ===== */
.article-header {
    padding: 3rem 0 2rem;
}

.article-title {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .article-title {
        font-size: 1.75rem;
    }
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.article-tag {
    padding: 0.3rem 0.85rem;
    border-radius: 100px;
    background: var(--border-light);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.article-tag:hover {
    background: var(--primary);
    color: white;
}

/* Article body prose */
.article-body {
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--text-primary);
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2em;
    margin-bottom: 0.75em;
    color: var(--text-primary);
}

.article-body h2 {
    font-size: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-light);
}

.article-body h3 {
    font-size: 1.25rem;
}

.article-body p {
    margin-bottom: 1.25em;
}

.article-body img {
    border-radius: var(--radius-sm);
    margin: 1.5em 0;
    max-width: 100%;
}

.article-body blockquote {
    border-left: 4px solid var(--primary);
    background: rgba(99, 102, 241, 0.05);
    padding: 1rem 1.5rem;
    margin: 1.5em 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.article-body ul, .article-body ol {
    margin-bottom: 1.25em;
    padding-left: 1.5em;
}

.article-body li {
    margin-bottom: 0.5em;
}

.article-body code {
    background: var(--border-light);
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-size: 0.9em;
}

.article-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1.5em 0;
}

.article-body pre code {
    background: none;
    padding: 0;
}

.article-body a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.article-body a:hover {
    color: var(--primary-dark);
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.article-body th {
    background: var(--border-light);
    font-weight: 600;
    text-align: left;
}

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

/* ===== Breadcrumb ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-sep {
    color: var(--border);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ===== Section Title ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.section-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-title-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(to right, var(--border), transparent);
}

/* ===== Footer ===== */
.site-footer {
    background: #0f172a;
    color: #94a3b8;
    margin-top: 4rem;
}

.footer-top {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 3rem;
    padding: 3rem 0;
}

@media (max-width: 768px) {
    .footer-top {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    .footer-top {
        grid-template-columns: 1fr;
    }
}

.footer-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.75rem;
}

.footer-desc {
    font-size: 0.875rem;
    line-height: 1.6;
}

.footer-heading {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #e2e8f0;
    margin-bottom: 1rem;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: #94a3b8;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-light);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 1.125rem;
    color: var(--text-muted);
}

/* ===== 404 Page ===== */
.error-page {
    text-align: center;
    padding: 6rem 2rem;
}

.error-code {
    font-size: 8rem;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-message {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
}

.error-desc {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid));
    color: white;
    font-weight: 600;
    border-radius: 100px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

/* ===== Ad Container ===== */
.ad-container {
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    margin: 2rem 0;
    min-height: 90px;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }
.animate-in:nth-child(7) { animation-delay: 0.35s; }
.animate-in:nth-child(8) { animation-delay: 0.4s; }
.animate-in:nth-child(9) { animation-delay: 0.45s; }

/* ===== Share Buttons ===== */
.share-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    margin: 2rem 0;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.share-btn:hover {
    transform: scale(1.1);
}

.share-fb { background: #1877f2; color: white; }
.share-tw { background: #1da1f2; color: white; }
.share-line { background: #00c300; color: white; }
.share-copy { background: var(--border-light); color: var(--text-secondary); }
.share-copy:hover { background: var(--primary); color: white; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Reading Progress Bar ===== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
    z-index: 200;
    transition: width 0.1s;
}
