/* متغیرهای رنگی اصلی */
:root {
    --bg-color: #0d041a;
    --text-color: #e0e0e0;
    --card-bg: #1a0b33;
    --card-border: rgba(255, 255, 255, 0.1);
    
    /* این متغیرها توسط جاوااسکریپت تغییر خواهند کرد */
    --primary-color: hwb(266 33% 0%);
    --glow-color: #be8eff;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    margin: 0;
    direction: rtl;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* --- هدر و منو --- */
header {
    background: var(--card-bg);
    padding: 20px 5%;
    text-align: center;
    border-bottom: 1px solid var(--card-border);
}
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}
.nav-logo {
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
    color: var(--primary-color);
}
nav ul { list-style: none; padding: 0; margin: 0; display: flex; }
nav ul li a {
    text-decoration: none;
    color: var(--text-color);
    padding: 10px 20px;
    transition: color 0.3s, text-shadow 0.3s;
    cursor: pointer;
}
nav ul li a:hover {
    color: var(--glow-color);
    text-shadow: 0 0 8px var(--glow-color);
}
.header-content h1 { font-size: 3rem; margin-bottom: 10px; }
.header-content p { font-size: 1.1rem; max-width: 700px; margin: 10px auto; line-height: 1.7; }
.security-note {
    background-color: rgba(159, 85, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    transition: border-color 0.3s, background-color 0.3s;
}

/* --- استایل Color Picker --- */
.color-picker-wrapper { display: flex; align-items: center; gap: 10px; }
.color-picker-label { font-size: 1rem; cursor: pointer; }
input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 35px;
    height: 35px;
    background-color: transparent;
    border: none;
    cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 5px var(--glow-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}
input[type="color"]::-moz-color-swatch {
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 10px var(--glow-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* --- افکت نئونی --- */
.glow-text {
    color: var(--glow-color);
    text-shadow: 0 0 5px var(--glow-color), 0 0 10px var(--glow-color), 0 0 20px var(--primary-color), 0 0 30px var(--primary-color);
    transition: color 0.3s, text-shadow 0.3s;
}

/* --- کارت‌های ابزار --- */
.tools-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; padding: 40px 5%; }
.tool-card {
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--card-border);
}
.tool-card:hover {
    transform: translateY(-5px); /* افکت هاور در موبایل کمتر باشد */
    box-shadow: 0 0 20px var(--primary-color);
    border-color: var(--primary-color);
}
.card-image img { width: 100%; height: 200px; object-fit: cover; display: block; }
.card-content { padding: 25px; flex-grow: 1; display: flex; flex-direction: column; }
.card-title { font-size: 1.5rem; margin: 0 0 10px 0;display: flex;justify-content: center; }
.card-description { opacity: 0.8; line-height: 1.6; flex-grow: 1; margin-bottom: 20px; display: flex;justify-content: center; }
.card-button {
    display: inline-block;
    text-decoration: none;
    color: #fff;
    background: var(--primary-color);
    padding: 12px 25px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    transition: background-color 0.3s, box-shadow 0.3s;
}
.card-button:hover { box-shadow: 0 0 15px var(--primary-color); }

/* --- فوتر و پاپ‌آپ‌ها (اصلاح شده برای وسط‌چین دقیق) --- */
footer { 
    text-align: center; 
    padding: 20px; 
    margin-top: 40px; 
    background: var(--card-bg); 
    border-top: 1px solid var(--card-border); 
}

.modal {
    display: none; /* مودال به صورت پیش‌فرض مخفی است */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    padding: 15px;
    animation: fadeIn 0.5s;
}

/* این کلاس جدید توسط جاوااسکریپت اضافه می‌شود تا مودال را نمایش دهد */
.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border: 1px solid var(--primary-color);
    width: 100%; 
    max-width: 500px;
    border-radius: 15px;
    box-shadow: 0 0 25px var(--primary-color);
    position: relative;
    text-align: center;
    animation: slideIn 0.5s;
    transition: border-color 0.3s, box-shadow 0.3s;
    /* margin: 0; حذف شد چون flex کار وسط‌چینی را انجام می‌دهد */
}
.close-btn { color: #aaa; position: absolute; left: 20px; top: 10px; font-size: 28px; font-weight: bold; cursor: pointer; }
.close-btn:hover { color: white; }
.modal-link { color: var(--glow-color); text-decoration: none; font-size: 1.2rem; font-weight: bold; transition: text-shadow 0.3s, color 0.3s; }
.modal-link:hover { text-shadow: 0 0 10px var(--glow-color); }

/* Keyframe animations */
@keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} }
@keyframes slideIn { from {transform: translateY(-50px); opacity: 0;} to {transform: translateY(0); opacity: 1;} }


/******************************************/
/* بخش کدهای ریسپانسیو           */
/******************************************/

/* برای تبلت و موبایل‌های بزرگ (عرض کمتر از 768 پیکسل) */
@media (max-width: 768px) {
    /* تغییر چیدمان منو */
    nav {
        flex-direction: column;
        gap: 25px; /* ایجاد فاصله بین بخش لوگو و لینک‌ها */
    }

    /* کوچک‌کردن فونت‌ها */
    .header-content h1 {
        font-size: 2.2rem;
    }

    .modal{
        max-width: 500px;
    }
    .header-content p {
        font-size: 1rem;
    }

    /* بهینه‌سازی کانتینر کارت‌ها */
    .tools-container {
        padding: 40px 4%;
        gap: 25px;
    }
}

/* برای موبایل‌های کوچک (عرض کمتر از 480 پیکسل) */
@media (max-width: 480px) {
    header {
        padding: 20px 3%;
    }

    /* چیدمان بخش بالایی منو */
    .nav-left {
        flex-direction: column;
        gap: 15px;
    }

    /* چیدمان لینک‌های منو */
    nav ul {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    nav ul li a {
        display: block; /* تمام عرض را بگیرد */
        padding: 12px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
    }

    .header-content h1 {
        font-size: 1.8rem;
    }

    .card-content {
        padding: 20px;
    }
    
    .modal-content {
        padding: 25px 15px;
    }
}

.card-image {
    position: relative;
}
.card-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%; /* ارتفاع محو شدگی را از اینجا کنترل کنید */
    background: linear-gradient(to top, var(--card-bg) 20%, transparent);
}