@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap');

:root {
  --tabbar-h: 40px;
}

body {
  font-family: 'Cairo', sans-serif;
}

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bs-primary);
  box-shadow: 0 0 6px var(--bs-primary);
  display: inline-block;
}

/* ── Theme customizer ── */
.theme-customizer {
  position: fixed;
  top: calc(var(--topbar-h, 56px) + 10px);
  inset-inline-end: 14px;
  width: 280px;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  z-index: 1000;
  padding: 14px;
  display: none;
}
.theme-customizer.open { display: block; }
.theme-customizer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.theme-customizer-title {
  font-size: .88rem;
  font-weight: 700;
}
.theme-customizer-close {
  width: 28px; height: 28px;
  border: 1px solid var(--bs-border-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.theme-customizer-grid {
  display: grid;
  gap: 10px;
}
.theme-field {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: .78rem;
  font-weight: 600;
}
.theme-field input[type="color"] {
  width: 44px; height: 32px;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
}
.theme-customizer-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.theme-customizer-actions .btn {
  flex: 1;
}

/* ── Content section must be flex column for iframe to fill height ── */
.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.content-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
}
section.content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ── Tab bar (custom iframe-tab UI, AdminLTE has no equivalent) ── */
.app-main { min-height: 0; }
.app-content.frameless {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tab-bar {
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: stretch;
  height: var(--tabbar-h);
  overflow: hidden;
  flex-shrink: 0;
}

.tab-list {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  flex: 1;
  gap: 1px;
  padding: 0 4px;
  scrollbar-width: thin;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px 0 12px;
  min-width: 100px; max-width: 180px;
  border-inline-end: 1px solid var(--bs-border-color);
  cursor: pointer;
  font-size: .8rem;
  transition: background .15s, color .15s;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-item:hover { background: rgba(var(--bs-secondary-rgb), .08); }
.tab-item.active {
  border-bottom: 2px solid var(--bs-primary);
  font-weight: 700;
  background: #17a2b8;
  color: var(--bs-primary);
}

.tab-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
}

.tab-close {
  background: none; border: none; cursor: pointer;
  font-size: 11px; padding: 2px 4px;
  border-radius: 4px; line-height: 1; flex-shrink: 0;
  color: var(--bs-secondary-color);
}
.tab-close:hover { color: var(--bs-danger); background: rgba(var(--bs-danger-rgb), .12); }

/* ── Welcome screen ── */
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--bs-secondary-color); gap: 14px;
  text-align: center; padding: 40px;
}
.chat-empty .icon { font-size: 52px; opacity: .16; }
.chat-empty p { font-size: .92rem; line-height: 1.8; }

/* ── Frames wrap ── */
.frames-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.content-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: none;
  display: none;
}

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: 24px;
  inset-inline-end: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  padding: 12px 18px; border-radius: 10px;
  font-size: .85rem; font-weight: 600;
  animation: toastIn .3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  font-family: 'Cairo', sans-serif;
}
.toast-success { background: rgba(var(--bs-success-rgb), .2); border: 1px solid rgba(var(--bs-success-rgb), .4); }
.toast-error   { background: rgba(var(--bs-danger-rgb), .2);  border: 1px solid rgba(var(--bs-danger-rgb), .4); }
.toast-info    { background: rgba(var(--bs-info-rgb), .15);   border: 1px solid rgba(var(--bs-info-rgb), .3); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bs-border-color); border-radius: 4px; }

/* ── Admin pages inside iframes ── */
body.admin-page {
  overflow: auto !important;
  height: auto !important;
  padding: 28px 20px;
  font-family: 'Cairo', sans-serif;
}

/* ── Login page ── */
body.login-page {
  font-family: 'Cairo', sans-serif;
}
.login-logo {
  font-weight: 700;
}

/* ── Sidebar nav base ── */
.nav {
  display: contents;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

/* ── Sidebar menu item arrow (for items with submenus) ── */
.nav-sidebar .nav-item.has-treeview > .nav-link > p > .right {
  position: absolute;
  top: 50%;
  margin-top: -8px;
  font-size: .8rem;
  transition: transform .3s ease;
}
.nav-sidebar .nav-item.menu-open > .nav-link > p > .right {
  transform: rotate(-90deg);
}

/* ── RTL layout overrides for AdminLTE v3 (CDN build has no built-in RTL) ── */
[dir="rtl"] .main-sidebar {
  left: auto !important;
  right: 0 !important;
}
[dir="rtl"] .content-wrapper,
[dir="rtl"] .main-footer,
[dir="rtl"] .main-header {
  margin-left: 0 !important;
  margin-right: 250px !important;
}
[dir="rtl"] .sidebar-collapse .content-wrapper,
[dir="rtl"] .sidebar-collapse .main-footer,
[dir="rtl"] .sidebar-collapse .main-header {
  margin-right: 0 !important;
  margin-left: 0 !important;
}
[dir="rtl"] .sidebar-mini.sidebar-collapse .content-wrapper,
[dir="rtl"] .sidebar-mini.sidebar-collapse .main-footer,
[dir="rtl"] .sidebar-mini.sidebar-collapse .main-header {
  margin-right: 4.6rem !important;
  margin-left: 0 !important;
}
[dir="rtl"] .sidebar-collapse .main-sidebar {
  margin-right: -250px !important;
}
[dir="rtl"] .sidebar-mini.sidebar-collapse .main-sidebar {
  margin-right: 0 !important;
}
[dir="rtl"] .sidebar-open .main-sidebar {
  margin-right: 0 !important;
  margin-left: auto !important;
}

[dir="rtl"] .brand-link .brand-image {
  float: right !important;
  margin-left: .5rem !important;
  margin-right: -.5rem !important;
}
[dir="rtl"] .brand-link .brand-text {
  margin-left: 0 !important;
}

[dir="rtl"] .nav-sidebar .nav-link {
  direction: rtl;
  text-align: right;
  padding-right: .5rem !important;
  padding-left: .5rem !important;
}
[dir="rtl"] .nav-sidebar .nav-link p {
  direction: rtl;
  text-align: right !important;
}
[dir="rtl"] .nav-sidebar > .nav-item .nav-icon {
  margin-left: .2rem !important;
  margin-right: .05rem !important;
}
[dir="rtl"] .nav-sidebar .nav-item .nav-treeview {
  padding-left: 0 !important;
  padding-right: .5rem !important;
}
[dir="rtl"] .nav-sidebar .nav-item .nav-link .right {
  float: left !important;
}
[dir="rtl"] .nav-sidebar .nav-link > .right,
[dir="rtl"] .nav-sidebar .nav-link > p > .right {
  right: auto !important;
  left: .5rem !important;
}
[dir="rtl"] .nav-sidebar .nav-link > .right:nth-child(2),
[dir="rtl"] .nav-sidebar .nav-link > p > .right:nth-child(2) {
  left: 1.8rem !important;
  right: auto !important;
}
[dir="rtl"] .nav-sidebar .nav-item .nav-link > .fas.fa-angle-left {
  transform: rotate(180deg);
}
[dir="rtl"] .nav-sidebar .nav-item.menu-open > .nav-link > .fas.fa-angle-left {
  transform: rotate(90deg);
}

[dir="rtl"] .float-left { float: right !important; }
[dir="rtl"] .float-right { float: left !important; }
[dir="rtl"] .text-left { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left !important; }

[dir="rtl"] .ml-0 { margin-left: 0 !important; margin-right: 0 !important; }
[dir="rtl"] .ml-1 { margin-left: 0 !important; margin-right: .25rem !important; }
[dir="rtl"] .ml-2 { margin-left: 0 !important; margin-right: .5rem !important; }
[dir="rtl"] .ml-3 { margin-left: 0 !important; margin-right: 1rem !important; }
[dir="rtl"] .ml-4 { margin-left: 0 !important; margin-right: 1.5rem !important; }
[dir="rtl"] .ml-5 { margin-left: 0 !important; margin-right: 3rem !important; }
[dir="rtl"] .ml-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .mr-0 { margin-right: 0 !important; margin-left: 0 !important; }
[dir="rtl"] .mr-1 { margin-right: 0 !important; margin-left: .25rem !important; }
[dir="rtl"] .mr-2 { margin-right: 0 !important; margin-left: .5rem !important; }
[dir="rtl"] .mr-3 { margin-right: 0 !important; margin-left: 1rem !important; }
[dir="rtl"] .mr-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }
[dir="rtl"] .mr-5 { margin-right: 0 !important; margin-left: 3rem !important; }
[dir="rtl"] .mr-auto { margin-right: 0 !important; margin-left: auto !important; }

[dir="rtl"] .pl-0 { padding-left: 0 !important; padding-right: 0 !important; }
[dir="rtl"] .pl-1 { padding-left: 0 !important; padding-right: .25rem !important; }
[dir="rtl"] .pl-2 { padding-left: 0 !important; padding-right: .5rem !important; }
[dir="rtl"] .pl-3 { padding-left: 0 !important; padding-right: 1rem !important; }
[dir="rtl"] .pl-4 { padding-left: 0 !important; padding-right: 1.5rem !important; }
[dir="rtl"] .pl-5 { padding-left: 0 !important; padding-right: 3rem !important; }
[dir="rtl"] .pr-0 { padding-right: 0 !important; padding-left: 0 !important; }
[dir="rtl"] .pr-1 { padding-right: 0 !important; padding-left: .25rem !important; }
[dir="rtl"] .pr-2 { padding-right: 0 !important; padding-left: .5rem !important; }
[dir="rtl"] .pr-3 { padding-right: 0 !important; padding-left: 1rem !important; }
[dir="rtl"] .pr-4 { padding-right: 0 !important; padding-left: 1.5rem !important; }
[dir="rtl"] .pr-5 { padding-right: 0 !important; padding-left: 3rem !important; }

[dir="rtl"] .border-left { border-left: none !important; border-right: 1px solid #dee2e6 !important; }
[dir="rtl"] .border-right { border-right: none !important; border-left: 1px solid #dee2e6 !important; }
[dir="rtl"] .rounded-left { border-radius: 0 .25rem .25rem 0 !important; }
[dir="rtl"] .rounded-right { border-radius: .25rem 0 0 .25rem !important; }

[dir="rtl"] .dropdown-menu-right { right: auto !important; left: 0 !important; }
[dir="rtl"] .dropdown-menu-left { left: auto !important; right: 0 !important; }
[dir="rtl"] .navbar-nav { padding-right: 0 !important; }
[dir="rtl"] .navbar-nav.ml-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .modal-header .close { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .alert-dismissible .close { right: auto !important; left: 0 !important; }

[dir="rtl"] #toast-container {
  inset-inline-end: auto !important;
  left: 24px !important;
}
