/* ===================================================
   header.css — MyFit (Clean & Optimized)
   =================================================== */

/* ================= HEADER ================= */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid rgba(23, 33, 29, 0.08);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ================= HEADER CONTAINER ================= */

.header-container {
    width: min(1200px, calc(100% - 40px));
    min-height: 68px; /* کاهش ارتفاع برای ظاهر فشرده‌تر */
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

/* ================= LOGO ================= */

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 20px;
    font-weight: 800;
    flex-shrink: 0;
}

.logo img {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.logo span {
    color: var(--text);
}

/* ================= NAVIGATION ================= */

.main-nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-right: auto;
    margin-left: auto;
    background: #141414;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.main-nav a {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 60px;
    min-height: 44px;
    padding: 4px;
    color: #9a9a9a;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    border-radius: 14px;
    transition: color 0.25s ease, transform 0.25s ease;
}

.main-nav a i {
    font-size: 16px;
    transition: color 0.25s ease, transform 0.25s ease;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--accent);
}

.main-nav a:hover i {
    transform: translateY(-1px);
}

.nav-ring {
    position: absolute;
    top: 5px;
    width: 40px;
    height: 40px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px 1px color-mix(in srgb, var(--accent) 45%, transparent);
    pointer-events: none;
    z-index: 1;
    transition: left 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.main-nav.following .nav-ring {
    transition: none;
}

/* ================= THEMES ================= */

[data-theme="light"] .main-nav {
    background: #EAF3DF;
    border: 1px solid rgba(123, 174, 63, 0.18);
    box-shadow: 0 6px 20px rgba(23, 33, 29, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .main-nav a {
    color: #707873;
}

[data-theme="light"] .main-nav a:hover,
[data-theme="light"] .main-nav a.active {
    color: #557C2E;
}

[data-theme="light"] .nav-ring {
    border-color: #7BAE3F;
    box-shadow: 0 0 10px 1px rgba(123, 174, 63, 0.28);
}

[data-theme="dark"] .site-header { border-bottom-color: rgba(242, 245, 241, 0.08); }
[data-theme="dark"] .main-nav { background: #141414; }
[data-theme="dark"] .main-nav a { color: #9a9a9a; }
[data-theme="dark"] .main-nav a:hover,
[data-theme="dark"] .main-nav a.active { color: #9BCB55; }
[data-theme="dark"] .nav-ring { border-color: #9BCB55; box-shadow: 0 0 12px 2px rgba(155, 203, 85, 0.35); }

/* ================= ACTIONS ================= */

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.theme-toggle {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(23, 33, 29, 0.08);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    color: var(--accent);
    transform: rotate(12deg);
}

.login-btn,
.signup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 15px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
}

.login-btn {
    border: 1px solid var(--accent);
    color: var(--accent);
    background: transparent;
}

.login-btn:hover {
    background: var(--accent);
    color: var(--primary);
}

.signup-btn {
    background: var(--accent);
    color: var(--primary);
}

.signup-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ================= USER MENU ================= */

.user-menu { position: relative; }

.user-profile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 4px 8px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.user-profile:hover { background: var(--bg); }

.user-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    border: 2px solid transparent;
    transition: border-color 0.25s ease, transform 0.25s ease;
}

.user-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-profile:hover .user-avatar {
    border-color: var(--accent);
    transform: scale(1.04);
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
}

.user-profile > i {
    color: var(--muted);
    font-size: 10px;
}

.logout-form { margin: 0; }

.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(23, 33, 29, 0.1);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
    border-color: var(--accent-light);
}

[data-theme="dark"] .theme-toggle,
[data-theme="dark"] .logout-btn {
    border-color: rgba(242, 245, 241, 0.1);
}

/* ================= RESPONSIVE ================= */

@media (max-width: 992px) {
    .header-container { width: min(100% - 30px, 900px); gap: 14px; }
    .main-nav a { width: 54px; }
}

@media (max-width: 768px) {
    .header-container { width: calc(100% - 24px); min-height: 60px; }
    .logo { font-size: 18px; }
    .logo img { width: 32px; height: 32px; }
    .main-nav { display: none; }
    .header-actions { margin-right: auto; }
}

@media (max-width: 480px) {
    .header-container { width: calc(100% - 16px); }
    .logo span { display: none; }
    .user-name { max-width: 60px; }
}

@media (max-width: 768px) {
    /* دکمه همبرگر */
    .hamburger-btn {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        width: 25px;
        height: 18px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1002;
    }

    .hamburger-btn span {
        width: 100%;
        height: 2px;
        background-color: #ffffff; /* رنگ خطوط همبرگر */
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    /* منوی کشویی در موبایل */
    .site-header .main-nav {
        position: fixed;
        top: 0;
        right: -100%; /* مخفی در خارج از صفحه */
        width: 280px; /* عرض استاندارد کشو */
        height: 100vh;
        background-color: #1e1e1e; /* رنگ پس‌زمینه تیره و خوانا */
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 80px 20px 30px;
        gap: 20px;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
        transition: right 0.3s ease-in-out;
        z-index: 1001;
        border-radius: 0; /* حذف لبه‌های گرد اضافه */
    }

    /* وقتی منو باز می‌شود */
    .site-header .main-nav.active {
        right: 0;
    }

    /* اصلاح رنگ لینک‌ها و متن‌های داخل منو */
    .site-header .main-nav a {
        color: #ffffff !important; /* روشن و خوانا کردن متن‌ها */
        font-size: 1rem;
        width: 100%;
        padding: 10px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .site-header .main-nav a i {
        color: #4caf50; /* رنگ آیکون‌ها */
        font-size: 1.2rem;
    }

    /* تبدیل دکمه همبرگر به X */
    .hamburger-btn.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .hamburger-btn.active span:nth-child(2) {
        opacity: 0;
    }
    .hamburger-btn.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}

/* ================= MOBILE MENU FIX ================= */

/* مخفی در دسکتاپ */
.hamburger-btn {
    display: none !important;
}

/* حالت موبایل */
@media (max-width: 768px) {
    /* دکمه همبرگری */
    button.hamburger-btn {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        width: 28px;
        height: 20px;
        background: transparent !important;
        border: none !important;
        cursor: pointer;
        padding: 0;
        z-index: 9999 !important; /* لایه بالاتر برای غیب نشدن */
        position: relative;
    }

    button.hamburger-btn span {
        display: block;
        width: 100%;
        height: 3px;
        background-color: var(--text, #ffffff) !important; /* رنگ خطوط */
        border-radius: 3px;
        transition: all 0.3s ease-in-out;
    }

    /* کشوی منو */
    .site-header #mainNav {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important; /* مخفی در حالت عادی */
        width: 260px !important;
        height: 100vh !important;
        background-color: #1a1a1a !important; /* رنگ تیره و یکدست */
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: 80px 20px 30px !important;
        gap: 16px !important;
        box-shadow: -5px 0 20px rgba(0,0,0,0.5) !important;
        transition: right 0.3s ease-in-out !important;
        z-index: 9998 !important;
    }

    /* باز شدن منو */
    .site-header #mainNav.active {
        right: 0 !important;
    }

    /* استایل لینک‌های داخل منو */
    .site-header #mainNav a {
        width: 100%;
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        color: #ffffff !important;
        font-size: 15px !important;
        padding: 10px 8px !important;
        border-bottom: 1px solid rgba(255,255,255,0.08) !important;
        text-decoration: none !important;
    }

    .site-header #mainNav a i {
        font-size: 18px !important;
        color: #4caf50 !important;
    }

    /* تبدیل همبرگر به X */
    button.hamburger-btn.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    button.hamburger-btn.active span:nth-child(2) {
        opacity: 0;
    }
    button.hamburger-btn.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
}
