* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --dark-bg: #0f172a;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 10px 25px -5px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

body.dark {
    --light-bg: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--light-bg);
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.5;
    transition: background 0.3s, color 0.2s;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* Progress Bar */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    z-index: 2000;
}
.progress-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    width: 0%;
    transition: width 0.1s;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    z-index: 1000;
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 2rem;
}
body.dark .header { background: rgba(15,23,42,0.9); }
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: auto;
}
.logo { font-size: 1.8rem; font-weight: 800; background: linear-gradient(135deg, var(--primary), #7c3aed); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-menu {
    display: flex;
    gap: 2rem;
    align-items: center;
}
.nav-menu a { text-decoration: none; color: var(--text-main); font-weight: 500; transition: 0.2s; }
.nav-menu a:hover, .nav-menu a.active { color: var(--primary); }
.dark-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: 0.3s;
}
.hamburger { display: none; font-size: 1.8rem; cursor: pointer; }

/* Hero */
.hero {
    text-align: center;
    padding: 3rem 1.5rem 4rem;
    background: radial-gradient(circle at 10% 30%, rgba(37,99,235,0.08), transparent);
}
.hero h1 {
    font-size: clamp(1.5rem, 5vw, 2.8rem);
    background: linear-gradient(to right, var(--primary), #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.typed-text {
    font-size: clamp(0.9rem, 4vw, 1.3rem);
    color: var(--text-muted);
    margin: 1rem 0;
    min-height: 3rem;
}
.search-wrapper {
    max-width: 600px;
    margin: 1.5rem auto;
    position: relative;
    padding: 0 1rem;
}
.search-bar {
    width: 100%;
    padding: 0.9rem 1.2rem;
    border-radius: 60px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    font-size: clamp(0.9rem, 4vw, 1rem);
    outline: none;
    transition: 0.2s;
}
.autocomplete-dropdown {
    position: absolute;
    background: var(--card-bg);
    width: calc(100% - 2rem);
    left: 1rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.filter-chips {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0 1rem;
}
.chip {
    padding: 0.5rem 1.2rem;
    border-radius: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    font-size: clamp(0.75rem, 3vw, 0.9rem);
    white-space: nowrap;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Main Content */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    gap: 2rem;
}
.articles-section { flex: 3; }
.sidebar { flex: 1; display: none; }
@media (min-width: 1024px) { .sidebar { display: block; } }
.toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.view-toggle { display: flex; gap: 0.5rem; }
.toggle-btn {
    padding: 0.4rem 1rem;
    border-radius: 30px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: clamp(0.8rem, 3vw, 0.9rem);
}
.category-tabs {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    margin-bottom: 2rem;
    scrollbar-width: thin;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}
.category-tab {
    padding: 0.5rem 1.2rem;
    background: var(--card-bg);
    border-radius: 40px;
    white-space: nowrap;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid var(--border);
    font-size: clamp(0.8rem, 3vw, 0.9rem);
}
.category-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.articles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 768px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1200px) {
    .articles-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
.articles-grid.list-view {
    grid-template-columns: 1fr;
}

/* Card Styles - FULLY RESPONSIVE */
.card {
    background: var(--card-bg);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* Responsive images - FIXED for mobile */
.card-img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: linear-gradient(135deg, var(--border) 0%, var(--card-bg) 100%);
    display: block;
}

.card-content {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Badge styles - responsive */
.badge-level {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: clamp(0.65rem, 3vw, 0.75rem);
    font-weight: 600;
    margin-right: 0.5rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
}

.level-1 { background: #dcfce7; color: #166534; }
.level-2 { background: #fed7aa; color: #9a3412; }
.level-3 { background: #fee2e2; color: #b91c1c; }

/* Card title - responsive */
.card-title {
    font-size: clamp(1rem, 4vw, 1.2rem);
    font-weight: 700;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0.25rem 0;
}

/* Meta info - responsive */
.meta {
    display: flex;
    gap: 0.75rem;
    font-size: clamp(0.65rem, 3vw, 0.75rem);
    color: var(--text-muted);
    flex-wrap: wrap;
    align-items: center;
}

.preview {
    font-size: clamp(0.8rem, 3.5vw, 0.9rem);
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card actions - fully responsive */
.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}


.share-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.share-group button,
.share-fb,
.share-twitter,
.copy-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: clamp(0.9rem, 4vw, 1rem);
    padding: 0.25rem;
    transition: 0.2s;
}

/* List view responsive */
.list-view .card {
    flex-direction: row;
    gap: 1rem;
}

.list-view .card-img {
    width: 120px;
    height: 120px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .list-view .card {
        flex-direction: column;
    }
    .list-view .card-img {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

/* Sidebar responsive */
.sidebar .card {
    padding: 1rem;
    margin-bottom: 1rem;
}

.sidebar h3 {
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    margin-bottom: 0.75rem;
}

/* Modal responsive */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}
.modal-content {
    background: var(--card-bg);
    max-width: 700px;
    width: 95%;
    max-height: 90%;
    border-radius: 1rem;
    padding: 1.5rem;
    overflow-y: auto;
    position: relative;
}

/* Responsive footer */
footer {
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    font-size: clamp(0.75rem, 3vw, 0.9rem);
}
/* استایل پایه برای چیپ ها */
.chip {
    background-color: var(--card-bg, #f0f0f0);
    color: var(--text-color, #333);
    transition: all 0.3s ease;
}

/* استایل برای دارک مود */
body.dark .chip {
    background-color: #2d2d2d;
    color: #ffffff !important;
}

body.dark .chip.active {
    background-color: #007bff;
    color: #ffffff !important;
}

body.dark .chip:hover {
    background-color: #3d3d3d;
    color: #ffffff !important;
}

body.dark a.chip {
    color: #ffffff !important;
}

body.dark a.chip:visited {
    color: #ffffff !important;
}


/* Responsive Design - Mobile First */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background: var(--card-bg);
        padding: 1rem;
        gap: 1rem;
        border-bottom: 1px solid var(--border);
        backdrop-filter: blur(12px);
        z-index: 999;
    }
    .nav-menu.active { display: flex; }
    .hamburger { display: block; }
    .header { padding: 0.8rem 1rem; }
    .container {
        padding: 0 1rem;
        flex-direction: column;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .view-toggle {
        justify-content: center;
    }
    .card-content {
        padding: 0.875rem;
    }
    .meta {
        gap: 0.5rem;
    }
    .card-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .readmore {
        text-align: center;
        padding: 0.5rem;
        background: var(--primary);
        color: white;
        border-radius: 8px;
    }
    .share-group {
        justify-content: center;
        padding: 0.5rem 0;
        border-top: 1px solid var(--border);
    }
    .bookmark {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        background: rgba(0,0,0,0.5);
        color: white;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(4px);
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }
    .card-actions {
        flex-direction: row;
    }
}

.tooltip-word {
    border-bottom: 1px dashed var(--primary);
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.popover {
    position: absolute;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    padding: 0.5rem 1rem;
    max-width: 250px;
    z-index: 1100;
    box-shadow: var(--shadow-md);
    display: none;
    font-size: 0.9rem;
}

#loadMoreBtn {
    width: auto;
    min-width: 200px;
}

@media (max-width: 768px) {
    #loadMoreBtn {
        width: 100%;
        padding: 0.75rem;
    }
}
/* Popular posts styling */
.sidebar .card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar .card ul li {
    margin-bottom: 0.75rem;
}

.sidebar .card ul li a {
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition);
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.sidebar .card ul li a:hover {
    color: var(--primary);
    padding-left: 0.5rem;
}

.sidebar .card ul li:last-child a {
    border-bottom: none;
}

/* Dark mode support */
body.dark .sidebar .card ul li a {
    color: var(--text-main);
}

body.dark .sidebar .card ul li a:hover {
    color: var(--primary);
}
