
body {
    font-family: 'Vazir', Tahoma, sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}
.chat-actions {
    display: flex;
    gap: 6px;
    position: absolute;
    top: 6px;
    z-index: 2;
}
:root {
    --bot-bg-color: rgb(140, 143, 162);
}





  /* دسکتاپ/تبلت: گرید با اسکرول عمودی */
  #models .model-grid {

display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;

    max-height: 65vh;         /* ارتفاع قابل‌اسکرول */
    overflow-y: auto;         /* اسکرول عمودی */
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    padding:10px;
  }

  /* موبایل: ردیف افقی اسکرول‌پذیر با اسنپ */
  @media (max-width: 767px) {
    #models .model-grid {
      display: flex;           /* از گرید به فلکس تغییر کن */
      flex-wrap: nowrap;
      gap: 12px;

      max-height: none;
      overflow-x: auto;        /* اسکرول افقی */
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch; /* اینرسی آیفون */
      scroll-snap-type: x mandatory;     /* اسنپ کارت‌ها */
      padding-inline: 8px;
      padding-block: 6px;
    }
    #models .model-card {
      flex: 0 0 50%;           /* هر کارت ~72% عرض صفحه */
      max-width: 50%;
      scroll-snap-align: start;
    }
  }

  /* اختیاری: کمی زیبایی برای کارت انتخاب‌شده */
.model-card {
  position: relative;
  border: 2px solid transparent;
  border-radius: 12px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, filter .15s ease;
  overflow: hidden;
  cursor: pointer;
}

.model-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}


.model-card.selected {
  border-color: #4da3ff;
  box-shadow:
    0 0 0 4px rgba(77,163,255,.18),     /* رینگ بیرونی */
    0 8px 24px rgba(0,0,0,.35);         /* سایه عمقی */
  transform: translateY(-1px) scale(1.02);
}
/* گرادیان ملایم برای هایلایت */
.model-card.selected::after {
  opacity: 1;
  background:
    radial-gradient(120% 120% at 50% 30%, rgba(77,163,255,.18), rgba(77,163,255,0) 60%),
    linear-gradient(to bottom, rgba(255,255,255,.06), rgba(255,255,255,0));
}
/* خود تصویر کمی درخشان‌تر شود */
.model-card.selected img {
  filter: brightness(1.05) saturate(1.06);
}

  .model-card img { width: 100%; display: block; }
  .model-card .model-name {
    position: absolute; bottom: 6px; left: 6px; right: 6px;
    background: rgba(0,0,0,.5); font-size: 12px; padding: 4px 6px; border-radius: 6px;
  }
/* تیک گوشه بالا-چپ + هاله کوچک زیرش */
.model-card .model-check {
  position: absolute;
  top: 6px; left: 6px;        /* RTL مشکلی ندارد؛ بالای چپ می‌ماند */
  display: none;
  background: #fff;
  color: #111;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 12px;
  box-shadow:
    0 0 0 2px #fff,           /* حلقه سفید دور تیک */
    0 4px 10px rgba(77,163,255,.45);
}
.model-card.selected .model-check { display: inline-block; }







.copy-btn,
.toast-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 0 0 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.copy-btn:hover,
.toast-btn:hover {
    opacity: 1;
}
.bubble-toast {
    position: absolute;
    top: 8px;
    right: 50px;
    background-color: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(-10px);
    z-index: 10;
    pointer-events: none;
}




.message-text {
    margin-top: 10px;
    padding: 0;
}

.bubble-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.chat-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    margin-top: 100px;
}
.sidebar {
    width: 400px;
    border-left: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    background: #f000;
    min-height: 0; /* مهم */
    height: calc(100vh - 160px); /* ارتفاع ثابت بدون اضافه شدن به صفحه */
}
.sidebar .top {
    padding: 10px;
    background: #f000;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid #ddd;
}
.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
}

.user-info img {
    width: 150px;
    height: 150px;
    border-radius: 12px;
    object-fit: cover;
}
.token-box {
    border: 2px solid #007bff;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: bold;
    color: #007bff;
    background: #e6f2ff;
    text-align: center;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    color: white;
    padding: 10px;
    background-color: #f000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding-right: 4px;
}     
.chat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 15px;
    background: #1e1e2f;
    min-height: 0; /* مهم */
    height: calc(100vh - 180px); /* همانند sidebar */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #000;
    border-radius: 8px;
    color: white;
    margin-bottom: 10px;
}

.chat-input {
    display: flex;
    font-size:12px;
    flex-direction: column;
    padding-top: 10px;
    background: #000;
    font-size:12px;
}

.chat-input button {
    width: fit-content;
    align-self: flex-start;
    padding: 10px 20px;
    font-family: 'Vazir', Tahoma, sans-serif;
    background: #007bff;
    color: white;
    height: 40px;
    margin-bottom: 5px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}
.chat-input button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* افکت hover برای چت‌ها در لیست */
#chat-list > div:hover {
    background-color: #c6b6c8;
    color:black;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding-right: 4px;
    transition: all 0.2s ease-in-out;
}
.toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #323232;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px 16px;
    position: fixed;
    z-index: 9999;
    right: 30px;
    bottom: 30px;
    font-family: 'Vazir', Tahoma, sans-serif;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.4s ease-in-out, transform 0.4s ease;
}

.toast.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(-10px);
}

.chat-bubble.user, .chat-bubble.bot {
    margin: 8px 0;
    padding: 18px ;
    border-radius: 16px;
    max-width: 75%;
    direction: rtl;
    white-space: inherit;
    font-size: 15px;
}
.chat-bubble.bot:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}        
.chat-bubble.user:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
.chat-bubble.user {
    margin-left: auto;
    background-color: rgb(97, 118, 139);
    border-radius: 16px 0 16px 16px;
    align-self: flex-end;
    text-align: right;
    position: relative;    
}
.chat-bubble.user::before {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 12px;
  height: 20px;
  background-color: rgb(97, 118, 139);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.chat-bubble.bot::before {
    
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 12px;
  height: 20px;
  background-color: var(--bot-bg-color);
  clip-path: polygon(100% 0, 0 0, 100% 100%);    
 
}
.chat-bubble.bot {
    margin-right: auto;
    background-color: var(--bot-bg-color);
    border-radius: 0 16px 16px 16px;
    align-self: flex-start;

    position: relative;    
}

.copy-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
}


.chat-item-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1a1a1a;
    padding: 3px 5px;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-item-container a {
    color: white;
    text-decoration: none;
    flex-grow: 1;
    font-size: 14px;
}

.chat-item-container:hover {
    background-color: #333;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transform: translateY(-1px);
}

.chat-item-container:hover a {
    color: #00bfff;
}

.chat-item-container .delete-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: red;
    cursor: pointer;
    margin-right: 10px;
}

textarea {
    resize: none;
    padding: 10px;
    font-size: 16px;
    font-family: 'Vazir', Tahoma, sans-serif;
    border-radius: 8px;
    border: 1px solid #ccc;
    margin-bottom: 5px;
}

textarea::placeholder {
    font-family: 'Vazir', Tahoma, sans-serif;
    font-size: 14px;
    color: #999;
}

a.active-chat {
    font-weight: bold;
    color: #007bff;
    background: #e6f2ff;
    padding: 3px 6px;
    border-radius: 6px;
}

button:disabled {
    background: gray;
}

.newchat-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 2px;
    margin:2px 10px 2px 10px;
    font-family: 'Vazir', Tahoma, sans-serif;
    background: #007bff;
    color: white;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}
.active-chat-item {
    background-color: var(--bot-bg-color);
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.4);
}

.active-chat-item a {
    color: #fff;
    font-weight: bold;
}

.btn-icon {
    vertical-align: middle;
    margin-top: 1px;
}









.image-modal {
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);

    /* پیش‌فرض مخفی */
    display: none;

    /* وقتی باز میشه، جاوااسکریپت display:flex می‌کنه */
    justify-content: center;
    align-items: center;
    overflow: hidden;
}


.image-modal img,
.image-modal video {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    padding: 30px;
    display: block;   /* مهم برای اینکه وسط‌چین درست کار کنه */
    margin: auto;     /* مطمئن بشیم وسط قرار می‌گیره */
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.image-modal .close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
}

.image-modal #downloadLink {
    position: absolute;
    top: 15px;
    left: 20px;
    background: #fff;
    color: black;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
}













@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 rgba(0, 123, 255, 0.7); }
    50% { box-shadow: 0 0 12px rgba(0, 123, 255, 0.7); }
    100% { box-shadow: 0 0 0 rgba(0, 123, 255, 0.7); }
}

.newchat-button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    animation: pulse-glow 1.2s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}
.tabs {
  display: flex;
  margin-top: 10px;
}
.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  cursor: pointer;
  background: #333;
  color: white;
}
.tab-btn.active {
  background: #555;
  font-weight: bold;
}
.tab-pane {
  margin-top: 10px;
}
.model-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.model-card {
  text-align: center;
  background: #222;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.model-card img {
  max-width: 100%;
  border-radius: 6px;
}

.delete-btn {
    font-size: 30px;
    padding: 0 6px;
}
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 999;
    background: #333;
    color: white;
    font-size: 24px;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
}
.sidebar {
    transition: transform 0.3s ease;
}


html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* مهم */
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding-top: 100px; /* جایگزین margin-top */
}

#footer {
    flex-shrink: 0; /* جلوگیری از فشرده شدن فوتر */
    background-color: #1e1e2f;
    color: white;
    padding: 20px 0;
}


.chat-actions {
    display: flex;

    margin-top: 2px;
}

@media (max-width: 1000px) {
    .main-nav {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    body.noscroll {
        overflow: hidden;
    }

    /* سایدبار موبایل */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100%;
        width: 400px;
        background: #f000;
        background-color: #f0f8ff;
        z-index: 998;
        box-shadow: -2px 0 8px rgba(0,0,0,0.2);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

.layout-mobile .chat-layout {
    display: flex;
    flex-direction: column; 
    height: calc(100vh - 100px); /* ارتفاع با در نظر گرفتن هدر/منو */
}


.chat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: #1e1e2f;
    min-height: 0;
}


    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 10px;
        background: #000;
        border-radius: 8px;
        color: white;
        margin-bottom: 10px;
    }

}

@media (min-width: 1200px) {
    .container {
        grid-template-columns: repeat(5, minmax(200px, 1fr));
    }
}

@media (max-width: 1199px) and (min-width: 768px) {
    .container {
        grid-template-columns: repeat(4, minmax(200px, 1fr));
    }
}

@media (max-width: 767px) {
    .container {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}