/* =========================================
   NAK AI — THEME.CSS
========================================= */

:root {

  /* COLORS */
  --bg-dark: #0b1120;
  --bg-light: #f5f7fb;

  --surface-dark: #111827;
  --surface-light: #ffffff;

  --surface-2-dark: #1e293b;
  --surface-2-light: #eef2ff;

  --text-dark: #f8fafc;
  --text-light: #0f172a;

  --muted-dark: #94a3b8;
  --muted-light: #64748b;

  --border-dark: rgba(255, 255, 255, .07);
  --border-light: rgba(15, 23, 42, .08);

  --primary: #3b82f6;
  --primary-hover: #2563eb;

  --danger: #ef4444;

  --radius: 18px;

  --navbar-height: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* =========================================
   RESET
========================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {

  font-family:
    IRANSans,
    Vazirmatn,
    sans-serif;

  transition:
    background .2s ease,
    color .2s ease;
}

/* =========================================
   THEMES
========================================= */

body.dark-theme {

  background: var(--bg-dark);
  color: var(--text-dark);
}

body.light-theme {

  background: var(--bg-light);
  color: var(--text-light);
}

/* Bootstrap utility sync with custom themes */
body.dark-theme,
html[data-bs-theme="dark"] body {
  --bs-body-color: var(--text-dark);
  --bs-body-bg: var(--bg-dark);
  --bs-secondary-color: var(--muted-dark);
  --bs-tertiary-color: rgba(148, 163, 184, 0.7);
  --bs-emphasis-color: #fff;
  --bs-heading-color: var(--text-dark);
  --bs-link-color: #60a5fa;
  --bs-link-hover-color: #93c5fd;
  --bs-border-color: var(--border-dark);
}

body.light-theme,
html[data-bs-theme="light"] body {
  --bs-body-color: var(--text-light);
  --bs-body-bg: var(--bg-light);
  --bs-secondary-color: var(--muted-light);
  --bs-emphasis-color: var(--text-light);
  --bs-heading-color: var(--text-light);
}

body.dark-theme .text-muted {
  color: var(--muted-dark) !important;
}

body.dark-theme .text-body,
body.dark-theme .text-dark {
  color: var(--text-dark) !important;
}

body.dark-theme .form-control,
body.dark-theme .form-select,
body.dark-theme textarea {
  color: var(--text-dark);
  background-color: rgba(255, 255, 255, 0.06);
  border-color: var(--border-dark);
}

body.dark-theme .form-control::placeholder,
body.dark-theme textarea::placeholder {
  color: rgba(248, 250, 252, 0.45);
}

body.dark-theme .alert {
  color: var(--text-dark);
}

body.dark-theme small,
body.dark-theme .small {
  color: var(--muted-dark);
}

/* =========================================
   APP
========================================= */

.app-wrapper {

  min-height: 100vh;
  min-height: 100dvh;

  display: flex;
  flex-direction: column;

  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.main-content {
  flex: 1;
}

/* =========================================
   NAVBAR
========================================= */

#mainNavbar {

  position: sticky;
  top: 0;

  z-index: 999;

  border-bottom: 1px solid var(--border-dark);

  backdrop-filter: blur(14px);

  background: rgba(11, 17, 32, .82);
}

.light-theme #mainNavbar {

  background: rgba(255, 255, 255, .9);

  border-bottom: 1px solid var(--border-light);
}

.nav-container {

  min-height: var(--navbar-height);

  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  position: relative;
}

/* =========================================
   BRAND
========================================= */

.navbar-brand {

  display: flex;
  align-items: center;

  gap: 12px;

  text-decoration: none;

  color: inherit;

  font-size: 1.35rem;
  font-weight: 800;

  margin: 0;

  white-space: nowrap;
}

.navbar-brand img {

  width: 42px;
  height: 42px;

  border-radius: 14px;
}

/* =========================================
   COLLAPSE
========================================= */

.navbar-collapse {

  flex: 1;

  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;
}

/* =========================================
   CENTER NAV
========================================= */

.nav-center {

  display: flex;
  flex-direction: row;

  align-items: center;

  gap: 8px;

  margin: 0;
  padding: 0;

  list-style: none;

  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-link-custom {

  height: 46px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  padding: 0 18px;

  border-radius: 14px;

  text-decoration: none;

  color: inherit;

  white-space: nowrap;

  font-weight: 600;

  transition: .2s ease;
}

.nav-link-custom:hover {

  background: rgba(59, 130, 246, .12);

  color: var(--primary);
}

.nav-link-custom.active {

  background: var(--primary);

  color: white;
}

/* =========================================
   ACTIONS
========================================= */

.navbar-actions {

  display: flex;
  align-items: center;

  gap: 12px;

  flex-shrink: 0;
}

.auth-buttons {

  display: flex;
  align-items: center;

  gap: 10px;
}

/* =========================================
   BUTTONS
========================================= */

.btn-login,
.btn-signup {

  height: 46px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0 18px;

  border-radius: 14px;

  text-decoration: none;

  font-weight: 700;

  white-space: nowrap;

  transition: .2s ease;
}

.btn-login {

  color: inherit;

  border: 1px solid rgba(255, 255, 255, .1);

  background: transparent;
}

.light-theme .btn-login {

  border: 1px solid rgba(15, 23, 42, .1);
}

.btn-login:hover {

  background: rgba(255, 255, 255, .05);

  color: inherit;
}

.light-theme .btn-login:hover {

  background: rgba(15, 23, 42, .04);
}

.btn-signup {

  background: var(--primary);

  color: white;
}

.btn-signup:hover {

  background: var(--primary-hover);

  color: white;
}

/* =========================================
   THEME BUTTON
========================================= */

.theme-btn {

  width: 42px;
  height: 42px;

  border: none;

  border-radius: 12px;

  background: rgba(255, 255, 255, .05);

  color: inherit;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 1.3rem;

  cursor: pointer;

  transition: .2s ease;
}

.theme-btn:hover {

  background: rgba(255, 255, 255, .1);
}

.light-theme .theme-btn {

  background: rgba(15, 23, 42, .04);
}

.light-theme .theme-btn:hover {

  background: rgba(15, 23, 42, .08);
}

/* =========================================
   PROFILE
========================================= */

.profile-btn {

  height: 44px;

  border: 1px solid rgba(255, 255, 255, .08);

  border-radius: 14px;

  background: rgba(255, 255, 255, .03);

  color: inherit;

  padding: 0 12px;

  display: flex;
  align-items: center;

  gap: 10px;

  transition: .2s ease;
}

.profile-btn:hover {
  background: rgba(255, 255, 255, .08);
}

.light-theme .profile-btn {
  background: rgba(15, 23, 42, .04);
  border: 1px solid rgba(15, 23, 42, .08);
}

.profile-avatar {

  width: 30px;
  height: 30px;

  border-radius: 10px;

  background: var(--primary);

  color: white;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 1.1rem;
}

.profile-btn::after {
  display: none;
}

/* =========================================
   DROPDOWN
========================================= */

.dropdown-menu {

  display: none;
  position: absolute;

  border: none;

  border-radius: 18px;

  overflow: hidden;

  padding: 8px;

  min-width: 200px;

  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);

  z-index: 1000;

  margin-top: 10px !important;
}

.dropdown-menu.show {
  display: block;
}

.dark-theme .dropdown-menu {

  background: #1e293b;

  border: 1px solid rgba(255, 255, 255, .1);
}

.light-theme .dropdown-menu {

  background: #ffffff;

  border: 1px solid rgba(15, 23, 42, .08);
}

.dropdown-item {

  border-radius: 12px;

  padding: 10px 14px;

  display: flex;
  align-items: center;

  gap: 12px;

  transition: .2s;

  color: inherit;

  text-decoration: none;

  font-size: .95rem;

  font-weight: 500;
}

.dropdown-item i {
  font-size: 1.1rem;
}

.dropdown-item:hover {

  background: rgba(59, 130, 246, .1);

  color: var(--primary);
}

/* =========================================
   FOOTER
========================================= */

.site-footer {

  position: relative;

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;

  gap: 16px;

  padding: 16px max(24px, var(--safe-left)) 16px max(24px, var(--safe-right));

  min-height: 104px;

  border-top: 1px solid var(--border-dark);

  color: var(--muted-dark);

  margin-top: auto;
}

.light-theme .site-footer {

  border-top: 1px solid var(--border-light);

  color: var(--muted-light);
}

/* COPYRIGHT */

.footer-copy {

  font-size: .92rem;
  font-weight: 600;

  opacity: .9;

  justify-self: center;

  text-align: center;
}

.footer-brand-link {

  color: #f97316;

  text-decoration: none;

  font-weight: inherit;

  transition: opacity .2s ease;
}

.footer-brand-link:hover,
.footer-brand-link:focus {

  color: #f97316;

  text-decoration: none;

  opacity: .85;
}

/* SOCIALS */

.footer-socials {

  position: static;

  transform: none;

  justify-self: left;

  display: flex;
  align-items: center;

  gap: 12px;
}

.footer-social-link {

  width: 42px;
  height: 42px;

  border-radius: 14px;

  display: flex;
  align-items: center;
  justify-content: center;

  text-decoration: none;

  color: inherit;

  background: rgba(255,255,255,.04);

  border: 1px solid rgba(255,255,255,.08);

  transition: .2s ease;
}

.footer-social-link i {

  font-size: 1.15rem;
}

/* Hover */

.footer-social-link:hover {

  transform: translateY(-2px);

  background: rgba(59,130,246,.12);

  border-color: rgba(59,130,246,.3);

  color: var(--primary);
}

/* Light Theme */

.light-theme .footer-social-link {

  background: rgba(15,23,42,.03);

  border: 1px solid rgba(15,23,42,.08);
}

.light-theme .footer-social-link:hover {

  background: rgba(59,130,246,.08);
}

/* ENAMAD */

.footer-enamad {

  position: static;

  transform: none;

  justify-self: right;
}

.footer-enamad a {

  display: block;

  line-height: 0;
}

.footer-enamad img {

  display: block;

  height: 88px;
  width: auto;
  max-width: 112px;

  object-fit: contain;

  opacity: .95;

  transition: opacity .2s ease, transform .2s ease;
}

.footer-enamad a:hover img {

  opacity: 1;

  transform: translateY(-1px);
}

/* MOBILE */

@media (max-width: 768px) {

  .site-footer {

    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;

    gap: 10px;

    min-height: auto;

    padding-top: 14px;
    padding-bottom: 14px;
  }

  .footer-copy,
  .footer-socials,
  .footer-enamad {

    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: static;
    transform: none;
  }

  .footer-socials {

    order: 2;
  }

  .footer-copy {

    order: 1;
    text-align: center;
  }

  .footer-enamad {

    order: 3;
  }

  .footer-enamad img {

    height: 72px;
    max-width: 96px;
  }
}


.footer-social-link img {

  width: 22px;
  height: 22px;

  object-fit: contain;

  opacity: .9;

  transition: .2s ease;
}

.footer-social-link:hover img {

  opacity: 1;

  transform: scale(1.08);
}


/* =========================================
   TOGGLER
========================================= */

.navbar-toggler {

  border: none !important;

  box-shadow: none !important;

  padding: 0;
}

.navbar-toggler-icon-custom {

  width: 24px;
  height: 18px;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.navbar-toggler-icon-custom span {

  height: 2.5px;

  border-radius: 10px;

  background: var(--text-dark);
}

.light-theme .navbar-toggler-icon-custom span {
  background: #0f172a;
}

/* =========================================
   MOBILE
========================================= */

@media(max-width:991px) {

  .nav-container {

    min-height: 76px;

    flex-wrap: wrap;
  }

  .navbar-collapse {

    width: 100%;

    margin-top: 12px;

    padding: 16px;

    border-radius: 20px;

    background: rgba(17, 24, 39, 0.95);

    border: 1px solid rgba(255, 255, 255, 0.1);

    flex-direction: column;

    align-items: stretch;

    gap: 12px;

    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);

    backdrop-filter: blur(10px);
  }

  .light-theme .navbar-collapse {

    background: rgba(255, 255, 255, 0.95);

    border: 1px solid rgba(15, 23, 42, 0.1);

    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
  }

  .nav-center {

    position: static;
    transform: none;

    width: 100%;

    flex-direction: column;

    gap: 10px;

    margin: 10px 0;
  }

  .nav-link-custom {

    width: 100%;

    justify-content: center;
  }

  .navbar-actions {

    width: 100%;

    justify-content: center;

    flex-direction: row;
    gap: 15px;

    padding: 5px 0;
  }

  .auth-buttons {

    width: 100%;

    display: flex;

    gap: 10px;
  }

  .btn-login,
  .btn-signup {

    flex: 1;
  }

  .profile-btn {

    width: 100%;

    justify-content: center;
  }
}

/* =========================================
   SMALL MOBILE
========================================= */

@media(max-width:576px) {

  .navbar-brand {

    font-size: 1.15rem;
  }

  .navbar-brand img {

    width: 38px;
    height: 38px;
  }

  .nav-link-custom {

    height: 50px;
  }

  .btn-login,
  .btn-signup {

    height: 50px;
  }

  .theme-btn {

    width: 50px;
    height: 50px;
  }
}

/* =========================================
   MOBILE BOTTOM NAV
========================================= */

.mobile-bottom-nav {
  display: none !important; /* Strictly hidden on desktop */
  position: fixed;
  bottom: calc(10px + var(--safe-bottom));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));

  height: 56px;

  display: flex;
  align-items: center;
  justify-content: space-around;

  background: rgba(17, 24, 39, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;

  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);

  z-index: 2000;

  padding: 0 12px;
}

.light-theme .mobile-bottom-nav {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.mobile-nav-link {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;

  text-decoration: none;
  color: var(--muted-dark);
  font-size: 0.72rem;
  font-weight: 700;

  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-theme .mobile-nav-link {
  color: var(--muted-light);
}

.mobile-nav-link.active {
  color: var(--primary);
}

.mobile-nav-link i {
  font-size: 1.4rem;
  transition: transform 0.2s;
}

.mobile-nav-link:active i {
  transform: scale(0.9);
}

.mobile-nav-link span {
  opacity: 0.8;
}

.mobile-nav-link.active span {
  opacity: 1;
}

.mobile-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

#mobileThemeEmoji {
  font-size: 1.4rem;
}

.mobile-bottom-nav .dropup .dropdown-menu {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 150px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    padding: 8px;
}

.light-theme .mobile-bottom-nav .dropup .dropdown-menu {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.mobile-bottom-nav .dropup .dropdown-item {
    padding: 10px 15px;
    font-size: 0.9rem;
    border-radius: 10px;
}

.mobile-bottom-nav .dropdown-toggle::after {
    display: none;
}

/* Adjust Main Content for Bottom Nav */
@media (max-width: 991px) {
  .mobile-bottom-nav {
    display: flex !important; /* Force show on mobile */
  }

  .app-wrapper {
    padding-top: calc(var(--navbar-height) + var(--safe-top));
    padding-bottom: var(--mobile-bottom-bar, calc(72px + var(--safe-bottom)));
  }

  body.page-chat .app-wrapper {
    padding-top: 0 !important;
  }

  body.page-chat #mainNavbar {
    display: block !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    flex-shrink: 0;
    height: calc(var(--navbar-height) + var(--safe-top));
    min-height: calc(var(--navbar-height) + var(--safe-top));
    max-height: calc(var(--navbar-height) + var(--safe-top));
    padding-top: var(--safe-top);
    padding-bottom: 0;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-dark);
    background: rgba(11, 17, 32, .94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 1001;
  }

  body.light-theme.page-chat #mainNavbar {
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--border-light);
  }

  .main-content {
    min-width: 0;
  }

  #mainNavbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--navbar-height) + var(--safe-top));
    min-height: calc(var(--navbar-height) + var(--safe-top));
    max-height: calc(var(--navbar-height) + var(--safe-top));
    padding-top: var(--safe-top);
    padding-bottom: 0;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-dark);
    background: rgba(11, 17, 32, .94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 999;
  }

  .light-theme #mainNavbar {
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--border-light);
  }

  .nav-container {
    justify-content: center !important;
    height: var(--navbar-height);
    min-height: var(--navbar-height) !important;
    max-height: var(--navbar-height);
    padding-top: 2px !important;
    padding-bottom: 2px !important;
  }

  .navbar-collapse {
    display: none !important;
  }

  body:not(.page-home):not(.page-chat) .site-footer {
    min-height: auto;
    padding: 12px max(12px, var(--safe-left)) var(--mobile-bottom-bar, calc(72px + var(--safe-bottom))) max(12px, var(--safe-right));
    border-top: 1px solid var(--border-dark);
    opacity: 1;
    font-size: 0.8rem;
  }
}

.nav-mini-btn {

  height: 44px;

  border: 1px solid rgba(255,255,255,.08);

  border-radius: 14px;

  background: rgba(255,255,255,.03);

  color: inherit;

  padding: 0 12px;

  display: flex;
  align-items: center;
  gap: 8px;

  text-decoration: none;

  font-weight: 600;

  transition: .2s ease;

  cursor: pointer;
}

.nav-mini-btn:hover {
  background: rgba(255,255,255,.08);
}

.light-theme .nav-mini-btn {
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
}



.mobile-bottom-nav button.mobile-nav-link {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0;
  cursor: pointer;
}

/* PWA standalone — full-screen app feel (no Safari chrome after Add to Home Screen) */
@media (display-mode: standalone) {
  html,
  body {
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }

  body.dark-theme {
    background: var(--bg-dark);
  }

  body.light-theme {
    background: var(--bg-light);
  }
}