@font-face {
    font-family: sans-light;
    src: url("/font/IRANSansWeb_Light.ttf");
}

/* ================= ROOT ================= */
:root{
    --background-color : #ffffff;
    --background-color-opacity : #ffffff,0.2;
    --text-color : #eeaf10 ;
    --text-color2 : #000000 ;
    --border-color : #f6d365 ;
    --border-color2 : #E8F7DE ;
    --hover-color : #8FBC8F;
    --hover-color2 :greenyellow;
    --background-color3:#ffffff;
    --background-color4:#E4FBD5;
    --background-color5:#f0ffee;
    --background-color6:#8FBC8F;
    --box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    --box-shadow-inset: inset 1px 1px 5px rgba(0, 0, 0, 0.3);
    --box-shadow-inset2: inset 0px -3px 5px rgba(0, 0, 0, 0.3);
    --text-shadow: -2px -2px 4px rgba(0, 0, 0, 0.2);
    
}

/* ================= RESET ================= */
* {
    box-sizing: border-box;
    font-family: sans-light;
    margin: 0;
    padding: 0;
}

body {
    direction: ltr;
}

/* ================= HEADER ================= */
#header2 {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 999;
    box-shadow: var(--box-shadow);
    background: var(--background-color);
}

.container-bar {
    width: 1fr;
    background-color: var(--background-color);
    display: grid;
    justify-content: center;
    align-items: center;
    grid-template-columns: repeat(2 , 1fr);
    grid-template-rows: auto auto;
    grid-template-areas: 
    " a b  "
    " c c ";
    row-gap: 3px;
    
    box-shadow: var(--box-shadow);
}

/* ================= LOGO ================= */
.logo-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
     grid-area: b;
    margin-right: 10px;
    
}

.logo-bar img {
    width: 50px;
    margin-top: 3px;
}

.logo-bar p{
    font-size: large;
    
}

.logo-link-home {
    display: flex;
    
    align-items: center;
    justify-content: space-around;
    width: 100%;
    color: #000;
    text-decoration: none;
}


/* ================= SEARCH ================= */
.search-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-area: a;
    padding: 0 20px;
    position: relative;
}

/* فرم = مرجع dropdown */
.search-bar form {
    display: flex;
    position: relative;
    width: 100%;
    max-width: 400px;
    margin-right: 5px;
    border-radius: 30px;
}

/* input */
.search-bar input {
    width: 100%;
    height: 42px;
    padding: 0 45px 0 20px;
    border: 2px solid var(--border-color2);
    border-radius: 30px;
    background: var(--background-color4);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.25s ease;
    direction: rtl;
    text-align: right;
}

.search-bar input::placeholder {
    color: var(--text-color);
    opacity: 0.7;
}

.search-bar input:hover {
    box-shadow: var(--box-shadow);
    border-color: var(--hover-color);
}

.search-bar input:focus {
    box-shadow: 0 0 0 3px rgba(143, 188, 143, 0.25);
    background: var(--background-color5);
}

/* دکمه جستجو */
.search-button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    background: transparent;
    color: var(--text-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    font-size: 1rem;
}

.search-button:hover {
    background: rgba(0,0,0,0.05);
}

/* 🔍 نتایج جستجو */
.search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    max-height: 360px;
    overflow-y: auto;
    display: none;
    z-index: 2000;
}

/* آیتم‌ها */
.search-result-item {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
    background: #f6f7f8;
}

.search-result-item:focus {
    outline: none;
    background: #eef2ff;
}

/* عنوان */
.search-result-title {
    margin: 0 0 4px;
    color: #333;
    font-size: 13.5px;
    font-weight: 600;
}

/* خلاصه */
.search-result-excerpt {
    margin: 0 0 6px;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* متا */
.search-result-meta {
    font-size: 11px;
    color: #999;
}

/* وضعیت‌ها */
.no-results,
.loading,
.error {
    text-align: center;
    padding: 16px;
    color: #999;
}

/* لودینگ */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #eee;
    border-top: 2px solid var(--hover-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* موبایل */
@media (max-width: 600px) {
    .search-bar form {
        max-width: 100%;
    }

    .search-results {
        max-height: 300px;
    }
}




/* حذف دکمه قدیمی */
.bar-button{
    display: none;
    width: 36px;
    height: 36px;
    background: var(--hover-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    font-size: 1.1rem;
}
/* ================= NAV ================= */
.links-bar {
    background: var(--background-color6);
    transition: opacity .3s ease, max-height .3s ease;
    display: grid;
    align-items: center;
    grid-area: c; 
    order: 3;
    box-shadow: var(--box-shadow);
}



.links-bar ul {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    column-gap: 5px;
    margin: 8px;
    

}

.links-bar li {
    
    display: flex;
    justify-content: center;
    align-items: center;
}

.links-bar a {
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    width: 100px;
    padding:10px 10px;
    align-items: center;
    font-size: small;
    font-weight:500;
    text-align: center;
    background: var(--background-color4);
    border-radius: 5px;
    text-decoration: none;
    color: var(--text-color2);
}

.links-bar a:hover {
    color: var(--text-color);
    box-shadow: var(--box-shadow);
}

/* ================= AUTH ================= */
.auth-buttons {
    
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: center;
    margin-right: 30px;
    width: 350px;
   
    
    
}

.auth-buttons a {
    display: flex;
    flex-direction: row;
    justify-content:space-between;
    align-items: center;
    background: var(--background-color6);
    padding: 10px;
    
    margin-right: 5px;
    border-radius: 5px;
    text-decoration: none;
    color: #171414;
    font-size: 12px;
}
#icon{
    margin-left: 5px;
}
.register-btn{
    display: flex;
    flex-direction: row;
    font-size: small;
    
}

.auth-buttons a:hover {
    background: #27ae60;
    color: #E8F7DE;
    box-shadow: var(--box-shadow);
}

/* ================= UTIL ================= */
.hide-nav {
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, height 0.3s ease;
}






/* ================= RESPONSIVE DESIGN ================= */



/* موبایل و دستگاه‌های کوچک (تا 768px) */
@media (max-width: 768px) {
    .container-bar {
        
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas: 
            "a"
            "b"
            "c";
        row-gap: 8px;
        padding: 10px;
    }
    
    /* جابجایی موقعیت عناصر برای موبایل */
    .search-bar {
        grid-area: b;
        order: 1;
        margin: 0;
        padding: 0 15px;
        
    }
    
    .logo-bar {
        grid-area: a;
        order: 2;
        margin-right: 0;
        justify-content: center;
        gap: 15px;
    }
    
    .links-bar-visibility{
        display: none;
    }

    .links-bar {
        grid-area: c;
        order: 3;
    }

    .bar-button{
        display: inline-block;
    }
    
    .hide-nav {
        opacity: 100%;
        height: 100%;
        overflow: hidden;
        transition: opacity 0.3s ease, height 0.3s ease;
    }
    

    /* بهبود ظاهر جستجو */
    .search-bar input {
        height: 48px;
        font-size: 16px; /* جلوگیری از زوم خودکار در iOS */
        padding: 0 55px 0 20px;
    }
    
    .search-bar input:hover,
    .search-bar input:focus {
        
        border-color: var(--hover-color);
    }
    
    .search-button {
        width: 20px;
        height: 2.5em;
        border-radius: 20px;
        margin-left: 5px;
    }
    
    /* منوی ناوبری عمودی برای موبایل */

    .links-bar{
        border-radius: 10px;
    }

    .links-bar ul {
        display: grid;
        grid-template-columns: repeat(2 , 1fr);
        grid-template-areas:
        "Articles training"
        "About idea"
        "home home";
        gap: 8px;
        margin: 10px;
    }
    .Articles-nav{
        grid-area: Articles;
    }
    .training-nav{
        grid-area: training;
    }
    .About-the-site-nav{
        grid-area: About;
    }
    .idea-maker-nav{
        grid-area: idea;
    }
    .home-nav{
        grid-area: home;
    }
    
    .links-bar li {
        width: 100%;
    }
    
    .links-bar a {
        width: 100%;
        
        
        font-size: 14px;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    /* دکمه‌های احراز هویت */
    .auth-buttons {
        width: 300px;
        margin-right: 5px;
        
    }
    
    .auth-buttons a {
        
        height: 40px;
        padding-top: 10px;
        text-align: center;
        
        
    }

   
    
    /* استایل‌های تایپوگرافی */
    .logo-bar p {
        font-size: 18px;
        text-align: center;
    }
    
    .logo-bar img {
        width: 45px;
    }
}







/* دستگاه‌های با DPI بالا */
@media screen and (-webkit-min-device-pixel-ratio: 2), 
       screen and (min-resolution: 192dpi) {
    .logo-bar img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    .bar-button{
        display: inline-block;
    }
    
    .hide-nav {
        opacity: 100%;
        height: 100%;
        overflow: hidden;
        transition: opacity 0.3s ease, height 0.3s ease;
    }
}

/* پشتیبانی از حالت تیره در موبایل */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1a1a;
        --background-color3: #2d2d2d;
        --background-color4: #3a3a3a;
        --background-color5: #2a2a2a;
        --text-color2: #ffffff;
        --border-color2: #444444;
        --box-shadow: 2px 2px 5px rgba(255, 255, 255, 0.1);
    }
    
    .search-bar input {
        background-color: var(--background-color4);
        color: white;
    }
    
    .search-bar input::placeholder {
        color: #cccccc;
    }
}

/* جلوگیری از بزرگ شدن فونت در iOS */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-text-size-adjust: 100%;
    }
    
    .search-bar input {
        font-size: 16px; /* جلوگیری از زوم در iOS */
    }
}

/* بهبود UX لمسی در موبایل */
@media (hover: none) and (pointer: coarse) {
    .links-bar a,
    .search-bar button {
        min-height: 44px; /* حداقل ارتفاع برای لمسی */
        min-width: 44px; /* حداقل عرض برای لمسی */
    }

    
    
    .links-bar a {
        padding: 15px 10px;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    /* استایل‌های تبلت */
    .bar-button{
        display: none;
    }

    .search-bar input {
        height: 46px;
        padding: 0 55px 0 20px;
    }

    .search-bar input:focus {
        max-width: 100%;
    }


    .hide-nav {
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, height 0.3s ease;
    }

    .auth-buttons{
        margin-right: 10px;
    }

    .auth-buttons a{
        text-align: center;
        
    }

}

@media (max-width: 1222px) and (min-width: 1025px){
    .auth-buttons a{
        text-align: center;
        
    }
}

@media (min-width : 1029px){
    .bar-button{
        display: none;
    }
}