/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
}

/* ===== Scrollbar Styles ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

.dark ::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.dark ::-webkit-scrollbar-thumb {
    background: #2d2d3f;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #3d3d5f;
}

/* ===== Line Clamp ===== */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Hide Scrollbar ===== */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-right {
    animation: slideInRight 0.5s ease-out forwards;
}

.animate-slide-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

/* ===== Stagger Animation ===== */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }

/* ===== Post Card Hover Effect ===== */
.post-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card:hover {
    transform: translateY(-4px);
}

/* ===== Gradient Text ===== */
.gradient-text {
    background: linear-gradient(135deg, #0ea5e9, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Glass Effect ===== */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark .glass {
    background: rgba(18, 18, 26, 0.5);
    border: 1px solid rgba(30, 30, 46, 0.5);
}

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1a1a2e 25%, #2a2a3e 50%, #1a1a2e 75%);
    background-size: 1000px 100%;
}

/* ===== Button Ripple Effect ===== */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ===== Tag Styles ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

/* ===== Breadcrumb ===== */
.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-separator {
    color: #9ca3af;
}

/* ===== Table of Contents ===== */
.toc-link {
    position: relative;
    padding-right: 16px;
}

.toc-link::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.toc-link.active {
    color: #0ea5e9;
}

.toc-link.active::before {
    opacity: 1;
    background: #0ea5e9;
}

/* ===== Reading Progress Bar ===== */
.progress-bar {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 40;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9, #7c3aed);
    transition: width 0.1s linear;
}

/* ===== Image Placeholder ===== */
.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
}

.dark .image-placeholder {
    background: linear-gradient(135deg, #1a1a2e, #12121a);
}

/* ===== Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* ===== Avatar ===== */
.avatar {
    position: relative;
}

.avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 25%;
    height: 25%;
    border-radius: 50%;
    border: 2px solid white;
    background: #22c55e;
}

.dark .avatar::after {
    border-color: #12121a;
}

/* ===== Tooltip ===== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 4px 12px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.tooltip:hover::after {
    opacity: 1;
}

.dark .tooltip::after {
    background: #374151;
}

/* ===== Input Styles ===== */
.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    color: #1f2937;
    transition: all 0.2s;
    outline: none;
}

.input-field:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.dark .input-field {
    background: #1a1a2e;
    border-color: #1e1e2e;
    color: #e5e7eb;
}

.dark .input-field:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

/* ===== Sidebar ===== */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    color: #6b7280;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background: #f9fafb;
    color: #0ea5e9;
}

.dark .sidebar-link:hover {
    background: #1a1a2e;
    color: #38bdf8;
}

.sidebar-link.active {
    background: #f0f9ff;
    color: #0ea5e9;
    font-weight: 600;
}

.dark .sidebar-link.active {
    background: rgba(14, 165, 233, 0.1);
    color: #38bdf8;
}

/* ===== Pagination ===== */
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #6b7280;
    transition: all 0.2s;
    font-weight: 500;
}

.page-btn:hover {
    border-color: #0ea5e9;
    color: #0ea5e9;
}

.page-btn.active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
}

.dark .page-btn {
    background: #1a1a2e;
    border-color: #1e1e2e;
    color: #ffffff;
}

.dark .page-btn:hover {
    border-color: #38bdf8;
    color: #38bdf8;
}

.dark .page-btn.active {
    background: #0ea5e9;
    border-color: #0ea5e9;
}

/* ===== Responsive Typography ===== */
.prose-custom {
    line-height: 1.8;
}

.prose-custom h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.prose-custom h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose-custom p {
    margin-bottom: 1.25rem;
    color: #4b5563;
}

.dark .prose-custom p {
    color: #9ca3af;
}

.prose-custom code {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #f3f4f6;
    color: #dc2626;
}

.dark .prose-custom code {
    background: #1a1a2e;
    color: #fb7185;
}

.prose-custom pre {
    padding: 1.25rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 1.5rem 0;
    background: #1f2937;
    color: #e5e7eb;
}

.prose-custom blockquote {
    padding: 1rem 1.25rem;
    border-right: 4px solid #0ea5e9;
    background: #f0f9ff;
    border-radius: 0 8px 8px 0;
    margin: 1.5rem 0;
}

.dark .prose-custom blockquote {
    background: rgba(14, 165, 233, 0.05);
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 768px) {
    .prose-custom h2 {
        font-size: 1.25rem;
    }
    
    .prose-custom h3 {
        font-size: 1.125rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    nav, footer, .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* ===== CKEditor Content Styles - Compatible with Tailwind Dark Mode ===== */
.post-content {
    /* استایل پایه */
    line-height: 1.8;
}

.post-content :is(h1, h2, h3, h4, h5, h6) {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.post-content h1 { font-size: 2em; }
.post-content h2 { font-size: 1.5em; }
.post-content h3 { font-size: 1.25em; }

/* پاراگراف‌ها */
.post-content p {
    margin-bottom: 1em;
}

/* تصاویر */
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1.5rem auto;
    display: block;
}

/* لینک‌ها */
.post-content a {
    color: #0ea5e9;
    text-decoration: none;
}

.post-content a:hover {
    text-decoration: underline;
}

/* لیست‌ها */
.post-content ul, 
.post-content ol {
    margin: 1em 0;
    padding-right: 2em;
}

.post-content li {
    margin: 0.5em 0;
}

/* ===== Code Styles ===== */
/* کدهای داخل خط */
.post-content :not(pre) > code {
    background: #f1f5f9;
    color: #d946ef;
    padding: 0.2rem 0.4rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

/* بلاک کدها */
.post-content pre {
    background: #1e293b;
    border-radius: 0.75rem;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.post-content pre code {
    background: transparent;
    color: #e2e8f0;
    padding: 0;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

/* نقل قول‌ها */
.post-content blockquote {
    border-right: 4px solid #0ea5e9;
    background: #f0f9ff;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 0.75rem 0.75rem 0;
    font-style: italic;
}

/* جداول */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.post-content th,
.post-content td {
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    text-align: right;
}

.post-content th {
    background: #f8fafc;
    font-weight: 600;
}

/* ===== Dark Mode Styles (مهم: این بخش با Tailwind کلاس "dark" هماهنگ شده) ===== */
.dark .post-content {
    color: #e2e8f0;
}

.dark .post-content :not(pre) > code {
    background: #1e293b;
    color: #f472b6;
}

.dark .post-content pre {
    background: #0f172a;
}

.dark .post-content pre code {
    color: #cbd5e1;
}

.dark .post-content blockquote {
    background: rgba(14, 165, 233, 0.1);
    border-right-color: #38bdf8;
}

.dark .post-content th,
.dark .post-content td {
    border-color: #334155;
}

.dark .post-content th {
    background: #1e293b;
}

.dark .post-content a {
    color: #38bdf8;
}