/* ─────────────────────────────────────────────────────────
   Botli-tec Portal — Stylesheet
   Colors: Navy #1a2e4a, Dark navy #0f1e30, Gray #6b7280,
           Light bg #f4f6f9, White #ffffff
   Direction: RTL (Hebrew)
───────────────────────────────────────────────────────── */

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

[hidden] { display: none !important; }

:root {
  --navy:        #1a2e4a;
  --navy-dark:   #0f1e30;
  --navy-light:  #2c4a6e;
  --accent:      #2563eb;
  --gray:        #6b7280;
  --gray-light:  #e5e7eb;
  --bg:          #f4f6f9;
  --white:       #ffffff;
  --red:         #dc2626;
  --font:        'Segoe UI', 'Arial', sans-serif;
  --radius:      10px;
  --shadow:      0 4px 20px rgba(0,0,0,0.10);
  --sidebar-w:   260px;
  --topbar-h:    60px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--navy-dark);
  direction: rtl;
}

/* ── Spinner ─────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
.spinner.large {
  width: 36px; height: 36px;
  border-color: var(--gray-light);
  border-top-color: var(--navy);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════
   LOGIN PAGE
════════════════════════════════════════════════════════ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
}

.logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.logo {
  height: 56px;
  width: auto;
  mix-blend-mode: multiply;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.login-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray);
  text-align: center;
  margin-bottom: 28px;
}

.field-group {
  margin-bottom: 18px;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.field-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-light);
  border-radius: 6px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--navy-dark);
  transition: border-color 0.2s;
  direction: ltr;
  text-align: right;
}

.field-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-left: 40px;
}

.eye-btn {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
  padding: 4px;
  display: flex;
  align-items: center;
  line-height: 1;
}

.eye-btn:hover { color: var(--navy); }
.eye-btn:focus { outline: 2px solid var(--accent); border-radius: 4px; }
.eye-btn svg   { width: 18px; height: 18px; display: block; }

.error-msg {
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.btn-primary:hover    { background: var(--navy-light); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.footer-note {
  font-size: 12px;
  color: var(--gray);
}

.footer-note a {
  color: var(--gray);
  text-decoration: none;
}

/* ════════════════════════════════════════════════════════
   DASHBOARD SPA LAYOUT
════════════════════════════════════════════════════════ */

.dashboard-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────── */
.top-bar {
  background: var(--navy);
  color: var(--white);
  padding: 0 16px;
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 200;
  position: relative;
}

.top-bar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-small {
  height: 30px;
  width: auto;
  mix-blend-mode: screen;
}

.brand-name-small {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.top-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ── Hamburger button ───────────────────────────────── */
.btn-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-radius: 6px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-hamburger:hover  { background: rgba(255,255,255,0.12); }
.btn-hamburger:focus  { outline: 2px solid rgba(255,255,255,0.5); }

.btn-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: opacity 0.2s;
}

/* ── Layout wrapper ─────────────────────────────────── */
.dashboard-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar overlay (mobile) ───────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}

.sidebar-overlay.visible {
  display: block;
}

/* ── Sidebar ────────────────────────────────────────── */
#sidebar {
  position: fixed;
  left: 0;
  top: var(--topbar-h);
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-light);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

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

/* ── Apps menu ──────────────────────────────────────── */
#apps-menu {
  padding: 10px 0;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  margin: 2px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.menu-item:hover {
  background: var(--bg);
}

.menu-item.active {
  background: var(--navy);
}

.menu-item.active .app-name {
  color: var(--white);
}

.menu-item.active .menu-icon-wrap {
  background: rgba(255,255,255,0.15);
}

.menu-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.app-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.app-icon-placeholder {
  width: 20px;
  height: 20px;
  color: var(--gray);
}

.app-icon-placeholder svg {
  width: 100%;
  height: 100%;
}

.menu-item .app-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar states (empty / loading) ───────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 16px;
  color: var(--gray);
}

.empty-state {
  padding: 24px 16px;
  color: var(--gray);
  text-align: center;
}

.empty-state p {
  font-size: 13px;
  line-height: 1.6;
}

.loading-state p,
.empty-state p {
  font-size: 13px;
}

/* ── Main content ───────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  transition: margin-left 0.25s ease;
}

/* On desktop, sidebar pushes the content area */
@media (min-width: 768px) {
  body.sidebar-open #main-content {
    margin-left: var(--sidebar-w);
  }

  /* No overlay on desktop */
  .sidebar-overlay {
    display: none !important;
  }
}

/* ── Welcome view ───────────────────────────────────── */
#welcome-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.welcome-banner {
  width: 88%;
  max-width: 900px;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  object-fit: contain;
}

/* ── App iframe ─────────────────────────────────────── */
.app-frame {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 0;
  display: block;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 767px) {
  .login-card { padding: 28px 20px; }

  /* Sidebar always overlays on mobile, never pushes */
  #main-content {
    margin-left: 0 !important;
  }

  .brand-name-small {
    display: none;
  }
}

@media (max-width: 380px) {
  #user-greeting { display: none; }
}
