/* ============================================
   TinNhanh24h - Stylesheet chính (v3)
   ============================================ */

:root {
    --color-primary: #c1272d;
    --color-primary-dark: #96181d;
    --color-primary-light: #e05a5f;
    --color-bg: #f2f3f5;
    --color-surface: #ffffff;
    --color-text: #17181a;
    --color-text-muted: #6b7078;
    --color-border: #e8e9eb;
    --color-tag-bg: #faeaea;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(20,20,20,0.06);
    --shadow: 0 2px 8px rgba(20,20,20,0.06), 0 1px 2px rgba(20,20,20,0.04);
    --shadow-lg: 0 8px 24px rgba(20,20,20,0.10);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --header-h: 60px;
}

html.dark {
    --color-bg: #121316;
    --color-surface: #1b1d21;
    --color-text: #eef0f2;
    --color-text-muted: #9198a3;
    --color-border: #2a2d32;
    --color-tag-bg: #33201f;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow: 0 2px 10px rgba(0,0,0,0.35);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.45);
}

/* ===== Reset & base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Chặn tràn ngang toàn trang trên mọi thiết bị (nguyên nhân chính gây "tràn lề") */
html, body { max-width: 100%; overflow-x: hidden; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
h1, h2, h3, h4 { font-weight: 700; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   HEADER
   ============================================ */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(6px);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;               /* cho phép xuống dòng thay vì tràn lề */
    align-items: center;
    gap: 12px 16px;
}

.logo {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    order: 1;
}

.header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    order: 2;
}

.search-box {
    display: flex;
    flex: 1 1 260px;      /* co giãn linh hoạt, tối thiểu 260px trước khi xuống dòng */
    min-width: 0;
    max-width: 460px;
    order: 3;
}

.search-box input {
    flex: 1;
    min-width: 0;          /* QUAN TRỌNG: cho phép input co nhỏ lại, không đẩy tràn layout */
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: 20px 0 0 20px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    outline: none;
    transition: border-color .15s ease;
}
.search-box input:focus { border-color: var(--color-primary); }

.search-box button {
    border: none;
    background: var(--color-primary);
    color: #fff;
    padding: 0 16px;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s ease;
}
.search-box button:hover { background: var(--color-primary-dark); }

.icon-btn {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    font-size: 16px;
    color: var(--color-text);
    transition: background .15s ease, transform .15s ease;
}
.icon-btn:hover { background: var(--color-tag-bg); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.header-ad-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 20px 0;
    overflow: hidden;
}

/* ===== Category nav ===== */
.category-nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }

.category-nav a {
    text-decoration: none;
    padding: 7px 15px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
    background: var(--color-bg);
    flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}

.category-nav a.active,
.category-nav a:hover {
    background: var(--color-primary);
    color: #fff;
}

/* ===== Đảm bảo header luôn gọn trên mobile ===== */
@media (max-width: 640px) {
    .header-inner { padding: 10px 14px; gap: 10px 12px; }
    .logo { font-size: 18px; }
    .search-box { order: 4; flex: 1 1 100%; max-width: 100%; }
    .icon-btn { width: 36px; height: 36px; font-size: 15px; }
    .category-nav { padding: 8px 14px; }
}

/* ============================================
   LAYOUT
   ============================================ */
.site-main {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .site-main { grid-template-columns: 1fr; margin: 16px auto; padding: 0 14px; }
    .sidebar { order: 2; }
}

/* ============================================
   ARTICLE CARD
   ============================================ */
.article-grid { display: flex; flex-direction: column; gap: 14px; }

.article-card {
    display: flex;
    gap: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: box-shadow .2s ease, transform .2s ease;
}
.article-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.article-card .thumb {
    width: 200px;
    height: 122px;
    flex-shrink: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-border);
    text-decoration: none;
}
.article-card .thumb img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .3s ease;
}
.article-card:hover .thumb img { transform: scale(1.05); }

.article-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.source-tag {
    background: var(--color-tag-bg);
    color: var(--color-primary);
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 11.5px;
}

.article-title {
    margin: 0 0 6px;
    font-size: 17px;
    line-height: 1.4;
    font-weight: 700;
}
.article-title a { text-decoration: none; }
.article-title a:hover { color: var(--color-primary); }

.article-summary {
    margin: 0;
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2;
}

.bookmark-btn,
.card-actions .share-btn {
    background: rgba(20,20,20,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, transform .15s ease;
}
.bookmark-btn:hover,
.card-actions .share-btn:hover { transform: scale(1.08); }
.bookmark-btn.active { background: var(--color-primary); }

@media (max-width: 560px) {
    .article-card { flex-direction: column; padding: 12px; }
    .article-card .thumb { width: 100%; height: 190px; }
    .article-title { font-size: 16px; }
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.sidebar-box h3 {
    margin: 0 0 14px;
    font-size: 15px;
    border-left: 4px solid var(--color-primary);
    padding-left: 10px;
}
.trending-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
    transition: color .15s ease;
}
.trending-item:hover { color: var(--color-primary); }
.trending-item:last-child { border-bottom: none; padding-bottom: 0; }
.trending-item:first-child { padding-top: 0; }
.trending-rank {
    font-weight: 800;
    font-size: 18px;
    color: var(--color-primary);
    width: 22px;
    flex-shrink: 0;
}
.trending-item h4 {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
    font-weight: 600;
}

.newsletter-box p { font-size: 13px; color: var(--color-text-muted); margin-top: 0; }
.newsletter-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
}
.newsletter-box button {
    width: 100%;
    padding: 11px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: background .15s ease;
}
.newsletter-box button:hover { background: var(--color-primary-dark); }

/* ============================================
   ADS
   ============================================ */
.ad-slot {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 10px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    overflow: hidden;
    max-width: 100%;
}
.ad-label {
    display: block;
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.06em;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 28px 0;
    flex-wrap: wrap;
}
.pagination a {
    padding: 8px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}
.pagination a:hover { background: var(--color-tag-bg); color: var(--color-primary); }
.pagination a.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination a.page-nav { font-weight: 700; }
.pagination .page-ellipsis {
    padding: 8px 2px;
    color: var(--color-text-muted);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--color-border);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    margin-top: 40px;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 36px 20px 20px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 28px;
}
.footer-col h3 { font-size: 14px; margin-bottom: 12px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 8px; font-size: 13px; }
.footer-col a { text-decoration: none; color: var(--color-text-muted); }
.footer-col a:hover { color: var(--color-primary); }
.footer-note { font-size: 12.5px; color: var(--color-text-muted); line-height: 1.6; }
.footer-bottom {
    text-align: center;
    font-size: 12.5px;
    color: var(--color-text-muted);
    padding: 16px 14px 28px;
    border-top: 1px solid var(--color-border);
    margin-top: 8px;
}
@media (max-width: 700px) {
    .footer-inner { grid-template-columns: 1fr; padding: 28px 18px 16px; gap: 22px; }
}

/* ============================================
   SHARE BAR (nút chia sẻ mạng xã hội)
   ============================================ */
.share-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0;
}
.share-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-right: 2px;
}
.share-bar .share-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s ease, background .15s ease, color .15s ease;
}
.share-bar .share-btn:hover { transform: translateY(-2px); }
.share-bar .share-fb:hover { background: #1877f2; color: #fff; border-color: #1877f2; }
.share-bar .share-x:hover { background: #000; color: #fff; border-color: #000; }
.share-bar .share-telegram:hover { background: #229ed9; color: #fff; border-color: #229ed9; }
.share-bar .share-zalo { width: auto; padding: 0 14px; border-radius: 18px; font-weight: 700; font-size: 13px; }
.share-bar .share-zalo:hover { background: #0068ff; color: #fff; border-color: #0068ff; }
.share-bar .share-copy { width: auto; padding: 0 14px; border-radius: 18px; font-size: 13px; }
.share-text { white-space: nowrap; }

/* Nút chia sẻ nhanh trên card danh sách (dùng chung style icon tròn với bookmark) */
.card-actions .share-quick { font-size: 15px; }

/* ============================================
   ARTICLE DETAIL PAGE (article.php)
   ============================================ */
.article-detail-wrap { min-width: 0; }

.article-detail {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.breadcrumb a { text-decoration: none; color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }

.article-detail-title {
    font-size: 26px;
    line-height: 1.35;
    margin: 10px 0 14px;
}
@media (max-width: 640px) {
    .article-detail { padding: 16px; }
    .article-detail-title { font-size: 21px; }
}

.article-detail-image {
    border-radius: var(--radius);
    overflow: hidden;
    margin: 16px 0;
    background: var(--color-border);
}
.article-detail-image img { width: 100%; max-height: 460px; object-fit: cover; }

.article-detail-summary {
    font-size: 16.5px;
    line-height: 1.75;
    color: var(--color-text);
    margin: 18px 0;
}

.cta-button {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    padding: 14px 26px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 15px;
    margin: 10px 0 16px;
    transition: background .15s ease, transform .15s ease;
    box-shadow: 0 4px 14px rgba(193,39,45,0.3);
}
.cta-button:hover { background: var(--color-primary-dark); transform: translateY(-1px); }

.source-note {
    font-size: 12.5px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
    margin-top: 6px;
}

.share-bar-bottom { border-top: 1px solid var(--color-border); padding-top: 16px; margin-top: 6px; }

.section-title {
    font-size: 17px;
    margin: 0 0 14px;
    padding-left: 10px;
    border-left: 4px solid var(--color-primary);
}

.related-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
@media (max-width: 560px) {
    .related-grid { grid-template-columns: 1fr; }
}

.related-card {
    display: flex;
    gap: 12px;
    text-decoration: none;
    color: var(--color-text);
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 10px;
    transition: background .15s ease;
}
.related-card:hover { background: var(--color-tag-bg); }
.related-card .thumb {
    width: 96px;
    height: 68px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-border);
}
.related-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-card h3 {
    font-size: 13.5px;
    line-height: 1.4;
    margin: 4px 0 0;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   NÚT LÊN ĐẦU TRANG
   ============================================ */
.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
    z-index: 90;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover { background: var(--color-primary-dark); }

@media (max-width: 640px) {
    .back-to-top { right: 14px; bottom: 14px; width: 42px; height: 42px; font-size: 18px; }
}
