/*
 * shell.css — Yalla Wrap It ERP
 * Layout: fixed left sidebar + topbar + scrollable page-content
 * Brand: Navy #0D1B3E / Orange #F5A623 / Light #F8F9FC
 */

/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --navy:        #0D1B3E;
  --navy-2:      #1A2952;
  --navy-3:      #243561;
  --orange:      #F5A623;
  --orange-dark: #E09510;
  --blue:        #2D3580;
  --light:       #F8F9FC;
  --border:      #E2E8F0;
  --text:        #1A202C;
  --muted:       #718096;
  --green:       #38A169;
  --green-light: #C6F6D5;
  --red:         #E53E3E;
  --red-light:   #FED7D7;
  --amber:       #D97706;
  --amber-light: #FEEBC8;
  --purple:      #805AD5;
  --teal:        #319795;

  --sidebar-width:          230px;
  --sidebar-collapsed-width: 60px;
  --topbar-height:           56px;
  --transition:              0.2s ease;
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}
img { max-width: 100%; display: block; }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }

/* ═══════════════════════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

/* ── Sidebar Brand ────────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  min-height: 58px;
}

.sidebar-logo {
  background: var(--orange);
  color: var(--navy);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  border-radius: 8px;
  padding: 6px 9px;
  flex-shrink: 0;
  min-width: 36px;
  text-align: center;
  line-height: 1;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}

.sidebar-brand-name {
  font-size: 13px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.sidebar-collapse-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.sidebar-collapse-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* ── Sidebar Nav ──────────────────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.28);
  padding: 6px 6px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  position: relative;
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.sidebar-nav-item.active {
  background: var(--orange);
  color: var(--navy);
  font-weight: 700;
}

.sidebar-nav-item.active:hover {
  background: var(--orange-dark);
}

.sidebar-nav-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  line-height: 1;
}

.sidebar-nav-label-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition);
}

/* Badge on nav items */
.sidebar-nav-badge {
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

/* ── Sidebar Footer / User ────────────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 58px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--navy);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.sidebar-logout-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  text-decoration: none;
}
.sidebar-logout-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

/* ── Sidebar COLLAPSED state ──────────────────────────────────────────────── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-nav-label-text,
.sidebar.collapsed .sidebar-nav-label,
.sidebar.collapsed .sidebar-nav-badge,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .sidebar-brand-sub {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}
.sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 9px 0;
}
.sidebar.collapsed .sidebar-nav-icon {
  width: auto;
}
.sidebar.collapsed .sidebar-user {
  justify-content: center;
}
.sidebar.collapsed .sidebar-brand {
  justify-content: center;
}
.sidebar.collapsed .sidebar-collapse-btn {
  display: none;
}

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
}
.sidebar-overlay.visible { display: block; }

/* ═══════════════════════════════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  transition: left var(--transition);
}

.topbar.collapsed-sidebar {
  left: var(--sidebar-collapsed-width);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-hamburger {
  display: none; /* shown on mobile */
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}
.topbar-hamburger:hover { background: rgba(255,255,255,0.2); }

.topbar-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: white;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN WRAPPER + PAGE CONTENT
═══════════════════════════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-wrapper.collapsed-sidebar {
  margin-left: var(--sidebar-collapsed-width);
}

.page-content {
  margin-top: var(--topbar-height);
  flex: 1;
  overflow-y: auto;
  height: calc(100vh - var(--topbar-height));
  padding: 22px 24px 60px;
}

/* Full-bleed variant (calendar, kanban) */
.page-content.no-pad {
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════════════════════ */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--navy);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.25s ease forwards;
  transition: opacity 0.3s ease;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--amber); color: var(--navy); }
.toast.info    { background: var(--blue); }
.toast.fade-out { opacity: 0; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important; /* always full-width when open */
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .topbar {
    left: 0 !important;
  }
  .topbar-hamburger {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 16px 14px 60px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LOGIN PAGE (standalone — no sidebar)
═══════════════════════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, var(--navy-3) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
}
.login-logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo {
  background: var(--orange);
  color: var(--navy);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  padding: 8px 14px;
  border-radius: 10px;
}
.login-app-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.login-app-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}
.login-error {
  background: var(--red-light);
  border: 1px solid #FEB2B2;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #C53030;
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SPA: ROUTE TRANSITIONS, PROGRESS BAR, SKELETONS
═══════════════════════════════════════════════════════════════════════════════ */

/* ── Brand link (logo clickable) ── */
.sidebar-logo-link { text-decoration: none; }

/* ── Route progress bar (top of content area) ── */
#routeProgress {
  position: relative;
  height: 2px;
  background: transparent;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}
#routeProgress::before {
  content: '';
  position: absolute;
  top: 0;
  left: -30%;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--orange), transparent);
  opacity: 0;
  transition: opacity 0.15s;
}
#routeProgress.loading::before {
  opacity: 1;
  animation: progressSlide 0.9s ease-in-out infinite;
}
#routeProgress.done::before {
  opacity: 0;
}
@keyframes progressSlide {
  0%   { left: -30%; }
  100% { left: 100%; }
}

/* ── Page content fade transition ── */
.page-content {
  transition: opacity 0.18s ease, transform 0.18s ease;
  position: relative;
}
.page-content.fading {
  opacity: 0;
  transform: translateY(4px);
}

/* ── Skeleton loaders ── */
.route-skeleton {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.skel-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  height: 120px;
  position: relative;
  overflow: hidden;
}
.skel-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(226, 232, 240, 0.4) 50%,
    transparent 100%
  );
  animation: shimmer 1.4s infinite;
}
.skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.skel-grid .skel-card { height: 100px; }

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Active nav (already styled above; ensure works with data-route) ── */
.sidebar-nav-item.active {
  background: var(--orange);
  color: var(--navy);
  font-weight: 700;
}
