/* Self-hosted Inter font - eliminates Google Fonts render-blocking & CLS */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/inter-400.woff2') format('woff2');
    
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/inter-500.woff2') format('woff2');
    
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/inter-600.woff2') format('woff2');
    
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/inter-700.woff2') format('woff2');
    
}

:root {
    --bg-body: #f8fafc;
    /* Nền xám cực nhạt để làm nổi bật Card trắng */
    --bg-card: #ffffff;
    --bg-section: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --primary-color: #d32029;
    /* Màu đỏ/coral đồng bộ với logo TIỆN ÍCH nhưng tối hơn để đạt Accesibility */
    --primary-hover: #b91823;
    --hover-bg: #f1f5f9;
    --hot-color: #b91c1c;
    --new-color: #047857;

    /* Hệ thống Shadow (Bóng đổ) hiện đại tinh tế */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.02);
    --shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    font-display: swap; 
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

input, button, select, textarea {
    font-family: inherit;
}

/* Header wrapper để kéo dài viền full trang */
#tienich-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    margin-bottom: 2rem;
}

/* Header Content */
.header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.logo-text span {
    font-weight: 400;
    color: var(--text-muted);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* Search Box */
.search-container {
    max-width: 600px;
    margin: 0 auto 2rem;
}

.search-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.6rem 1.25rem;
    background-color: var(--bg-card);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(232, 67, 74, 0.15);
    transform: translateY(-1px);
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.5rem;
    font-size: 1rem;
    color: var(--text-main);
    background: transparent;
    font-family: inherit;
}

.search-box input::placeholder {
    color: var(--text-light);
}

.search-btn {
    background: var(--hover-bg);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-btn svg {
    stroke: var(--primary-color);
}

.search-btn:hover {
    background: var(--primary-color);
}

.search-btn:hover svg {
    stroke: white;
}

/* Filters */
.filter-container {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.filter-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

@media (min-width: 640px) {
    .filter-container {
        flex-wrap: wrap;
        justify-content: center;
        overflow-x: visible;
    }
}

.filter-btn {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-btn:hover {
    background: rgba(226, 232, 240, 0.5);
    /* Xám rất nhạt */
    color: var(--text-main);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(232, 67, 74, 0.3);
}

/* Main Content */
.main-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

/* Tools Grid */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 900px) {
    .main-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .left-content {
        flex: 1;
        min-width: 0;
    }

    .sidebar {
        width: 300px;
        flex-shrink: 0;
        position: sticky;
        top: 20px;
    }
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 4rem;
}

@media (min-width: 640px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        /* Giữ 2 cột vì bị thu hẹp bởi sidebar */
        gap: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
        /* 3 cột trên màn to */
        gap: 1.5rem;
    }
}

/* Sidebar Box */
.sidebar-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid var(--bg-section);
    padding-bottom: 0.8rem;
}

.hot-tool-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 0;
    border-bottom: 1px dashed var(--border-color);
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s;
}

.hot-tool-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.hot-tool-item:hover {
    color: var(--primary-color);
    transform: translateX(5px);
}

.hot-icon {
    width: 42px;
    height: 42px;
    background: var(--hover-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.hot-info {
    flex: 1;
}

.hot-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    line-height: 1.3;
}

.hot-views {
    font-size: 0.75rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Card */
.tool-card {
    position: relative;
    display: block;
    text-decoration: none;
    background-color: var(--bg-card);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    padding: 1.25rem;
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    overflow: visible;
    z-index: 1;
}

@media (min-width: 640px) {
    .tool-card {
        padding: 1.75rem 1.5rem;
    }
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), #f97316);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-hover);
}

.tool-card:hover::before {
    opacity: 1;
    /* Sáng màu viền top lúc hover */
}

.tool-icon {
    font-size: 2.4rem;
    margin-bottom: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--hover-bg);
    border-radius: 14px;
    transition: transform 0.3s ease;
}

.tool-card:hover .tool-icon {
    transform: scale(1.1) rotate(-5deg);
    /* Hiệu ứng nảy nghiêng nhẹ */
}

.tool-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-main);
    line-height: 1.3;
}

.tool-desc {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.tool-cat {
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* Badges */
.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
    z-index: 1;
}

.badge-hot {
    background-color: var(--hot-color);
}

.badge-new {
    background-color: var(--new-color);
}

/* ===== SKELETON LOADING ===== */
@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
}

.skeleton-bone {
    background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 8px;
}

/* ===== BREADCRUMB ===== */
.breadcrumb-wrapper {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-light);
}

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

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

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

.breadcrumb-current {
    color: var(--primary-color);
    font-weight: 500;
}

/* ===== VIEW COUNT ===== */
.tool-views {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== FAQ SECTION ===== */
.faq-section {
    max-width: 800px;
    margin: 3rem auto 0;
    padding: 0 1rem;
}

.faq-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    background: var(--bg-card);
    border: none;
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-family: inherit;
    transition: background 0.2s;
}

.faq-question:hover {
    background: var(--bg-section);
}

.faq-question .faq-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    color: var(--text-light);
}

.faq-item.open .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.2s ease;
    background: var(--bg-card);
}

.faq-item.open .faq-answer {
    max-height: 300px;
    padding: 0 1.25rem 1rem;
}

.faq-answer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

/* ===== FOOTER ===== */
.site-footer {
    background-color: #ffffff;
    color: var(--text-muted);
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.footer-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 1.5rem 2rem;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 3rem;
}

@media (max-width: 768px) {
    .footer-inner {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2.5rem 1.25rem 1.5rem;
    }
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.footer-logo svg {
    flex-shrink: 0;
}

.footer-desc {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-muted);
}

.footer-tool-count {
    margin-top: 0.6rem;
    font-size: 0.82rem;
    color: var(--text-light);
}

.footer-tool-count strong {
    color: var(--primary-color);
    font-weight: 700;
}

.footer-col-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.25rem;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

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

.footer-bottom {
    border-top: 1px solid var(--border-color);
    text-align: center;
    padding: 1.25rem 1rem;
    font-size: 0.8rem;
    color: var(--text-light);
}
