:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary-color: #2563eb;
    --secondary-color: #eff6ff;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition);
}

a:hover {
    color: #1d4ed8;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
}

.brand {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-color);
    letter-spacing: -0.025em;
}

.brand:hover {
    color: var(--primary-color);
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 30px;
}

.main-nav a {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.main-nav a:hover {
    color: var(--text-color);
}

/* Main Content */
.site-content {
    min-height: calc(100vh - 80px - 100px);
    padding: 50px 0;
}

/* Section Title */
.section-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 40px;
    color: var(--text-color);
}

/* Blog Grid */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 30px;
    margin-bottom: 50px;
}

@media (min-width: 768px) {
    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .blog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Blog Card */
.blog-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.blog-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.card-img-wrapper {
    position: relative;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio */
    background: #e2e8f0;
    overflow: hidden;
}

.card-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card-img-wrapper.placeholder::before {
    content: "No Image";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #94a3b8;
    font-weight: 500;
}

.blog-card:hover .card-img-wrapper img {
    transform: scale(1.05);
}

.card-content {
    padding: 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.card-title a {
    color: var(--text-color);
}

.card-title a:hover {
    color: var(--primary-color);
}

.card-excerpt {
    color: var(--text-muted);
    margin-bottom: 24px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.95rem;
}

.card-footer {
    margin-top: auto;
    font-size: 0.9rem;
    font-weight: 600;
}

.card-footer a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    list-style: none;
    margin-top: 50px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-weight: 500;
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--secondary-color);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.pagination .current {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Footer */
.site-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
}

.footer-bottom {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Page Layout w/ Sidebar */
.page-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

@media (min-width: 992px) {
    .page-layout {
        grid-template-columns: 1fr 320px;
    }
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.sidebar-widget {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 8px;
}

.recommended-posts {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rec-post-item {
    display: flex;
    gap: 15px;
    align-items: center;
    color: var(--text-color);
}

.rec-post-item:hover h4 {
    color: var(--primary-color);
}

.rec-img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: #e2e8f0;
}

.rec-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rec-info {
    display: flex;
    flex-direction: column;
}

.rec-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rec-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Single Post */
.single-post-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.breadcrumb {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.breadcrumb .separator {
    margin: 0 8px;
    color: #cbd5e1;
}

.post-header {
    text-align: center;
    margin-bottom: 40px;
}

.post-meta {
    display: flex;
    justify-content: center;
    gap: 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.post-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.25;
    margin-bottom: 20px;
}

.post-gallery {
    margin-bottom: 40px;
}

.post-main-img {
    border-radius: var(--radius-lg);
    width: 100%;
    margin-bottom: 15px;
    box-shadow: var(--shadow-md);
}

.gallery-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.gallery-thumbs img {
    height: 80px;
    width: 120px;
    object-fit: cover;
    border-radius: var(--radius-md);
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition);
}

.gallery-thumbs img:hover,
.gallery-thumbs img.active {
    opacity: 1;
}

.post-content {
    font-size: 1.125rem;
    color: #334155;
    line-height: 1.8;
    padding: 12px;
    background: #ffffff;
    border-radius: 15px;
    border: 1px solid #cdcaca;
}

.post-content h2,
.post-content h3 {
    color: var(--text-color);
    margin-top: 40px;
    margin-bottom: 20px;
    font-weight: 700;
}

.post-content p {
    margin-bottom: 20px;
}

/* Social Share */
.social-share {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    margin: 40px 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.social-share strong {
    font-size: 1rem;
}

.share-btns {
    display: flex;
    gap: 15px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--text-color);
    font-weight: 600;
    transition: var(--transition);
}

.share-btn.twitter:hover {
    background: #1da1f2;
    color: #fff;
}

.share-btn.facebook:hover {
    background: #1877f2;
    color: #fff;
}

.share-btn.linkedin:hover {
    background: #0a66c2;
    color: #fff;
}

/* Comments */
.comments-section {
    margin-top: 60px;
}

.comments-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 30px;
}

.comment-list {
    margin-bottom: 50px;
}

.comment-item {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.comment-author {
    font-weight: 600;
    color: var(--text-color);
}

.comment-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.comment-body {
    color: #475569;
}

.comment-form-container {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.comment-form h3 {
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-submit {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-submit:hover {
    background: #1d4ed8;
}

/* Alert Messages */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Form Layout Classes */
.comment-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Header Search & Suggestions */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
}

#top-search-input {
    width: 200px;
    padding: 10px 40px 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: #f1f5f9;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-color);
    transition: width 0.3s ease, background 0.3s ease;
}

#top-search-input:focus {
    width: 280px;
    background: #fff;
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-form button {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    padding: 0;
}

.search-form button:hover {
    color: var(--primary-color);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    right: 0;
    width: 280px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    margin-top: 10px;
    z-index: 1000;
    overflow: hidden;
    display: none;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-color);
    transition: background 0.2s ease;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestion-item:hover {
    background: #f8fafc;
    color: var(--primary-color);
}

.suggestion-img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.suggestion-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Search Results UI */
.search-page-wrapper {
    max-width: 1200px;
}

.search-header {
    text-align: center;
    margin-bottom: 40px;
}

.highlight-text {
    color: var(--primary-color);
    background: #eff6ff;
    padding: 0 4px;
    border-radius: 4px;
}

.search-count {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.search-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 40px;
    justify-content: flex-end;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.empty-icon {
    color: #94a3b8;
    margin-bottom: 20px;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-muted);
}

/* Infinite Scroll Loader */
.loader-container {
    text-align: center;
    padding: 30px 0;
    visibility: hidden;
}

.loader-container.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    visibility: visible;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(37, 99, 235, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInCustom {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile & RTL Adjustments */
@media (max-width: 991px) {
    .sidebar {
        border-top: 1px solid var(--border-color);
        padding-top: 40px;
    }
}

@media (max-width: 767px) {
    .header-inner {
        flex-direction: column;
        justify-content: center;
        height: auto;
        padding: 15px 0;
        gap: 15px;
    }

    .main-nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }

    .page-layout {
        gap: 30px;
    }

    .post-title {
        font-size: 1.75rem;
    }

    .section-title {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }

    .post-meta {
        flex-direction: column;
        gap: 10px;
    }

    .social-share {
        flex-direction: column;
        text-align: center;
    }

    .comment-inputs-grid {
        grid-template-columns: 1fr;
    }
}