@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@300;400;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --bg-light: #f8fafc;
    --text-main: #334155;
    --text-muted: #64748b;
    --white: #ffffff;
    --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

body.loading {
    overflow: hidden;
}

body {
    transition: opacity 0.5s ease;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 15px rgba(37, 99, 235, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Almarai', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.7;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

/* Header Re-Design */
header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0.8rem 0;
    width: 100%;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    width: 100%;
}

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--dark);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.logo span { color: var(--primary); }

.nav-links { 
    display: flex; 
    gap: 1.2rem; 
    align-items: center; 
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.3s;
    white-space: nowrap; /* منع انقسام الكلمات لسطرين */
}

.nav-links a:hover { color: var(--primary); }
.nav-links a.active { 
    border: 2px solid var(--primary); 
    color: var(--primary) !important; 
    padding: 0.4rem 1.1rem; 
    border-radius: 50px;
}

/* Responsive Grid */
.container {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    width: 100%;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2.5rem;
    width: 100%;
}

/* Premium Cards */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-premium);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.03);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.card-img-wrapper {
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.5s;
}

.card:hover .card-img { transform: scale(1.08); }

.card-content {
    padding: 1.8rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-category {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.8rem;
    background: #eff6ff;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    display: inline-block;
}

.card-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.4;
    color: var(--dark);
}

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

.btn {
    background: var(--primary);
    color: var(--white);
    padding: 0.8rem 1.8rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    text-align: center;
    transition: 0.3s;
    border: none;
    cursor: pointer;
    display: block;
    width: 100%;
}

.btn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.btn-portfolio:hover { background: var(--dark) !important; color: white !important; }

/* Article View Enhancements */
.article-header {
    text-align: center;
    max-width: 900px;
    margin: 0 auto 3rem;
    width: 100%;
}

.post-content h2, .post-content h3 {
    margin: 2rem 0 1rem;
    color: var(--dark);
}

.post-content p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Search Bar Styles */
.search-container {
    position: relative;
    margin-right: 1.5rem;
}

.search-input {
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.9rem;
    width: 200px;
    transition: 0.3s;
}

.search-input:focus {
    width: 280px;
    border-color: var(--primary);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--dark);
    z-index: 3000;
}

/* Mobile Responsive Fixes */
@media (max-width: 768px) {
    .menu-toggle { display: block; }
    
    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        background: var(--white);
        flex-direction: column;
        padding: 5rem 2rem;
        box-shadow: -10px 0 30px rgba(0,0,0,0.1);
        transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 2000;
    }

    .nav-links.active { right: 0; }
    
    .nav-links a { font-size: 1.2rem; width: 100%; text-align: center; }
    
    .search-container { margin: 1rem 0; width: 100%; }
    .search-input { width: 100% !important; }

    nav { justify-content: space-between; }
    .container { padding: 0 1rem; }
}

@media (max-width: 480px) {
    .logo { font-size: 1.3rem; }
    .card-title { font-size: 1.15rem; }
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 2rem;
    left: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.8rem;
    background: var(--white);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 5000;
    font-weight: 700;
    animation: slideInLeft 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: 0.4s;
    border-right: 5px solid var(--primary);
}

.toast.hide {
    opacity: 0;
    transform: translateX(-100%);
    pointer-events: none;
}

.toast-success { color: #22c55e; border-right-color: #22c55e; }
.toast-error { color: #ef4444; border-right-color: #ef4444; }

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
