/* ═══════════════════════════════════════════════════════════
   Layout — Login, Sidebar, Main, Mobile
   ═══════════════════════════════════════════════════════════ */

/* ── Login Page ── */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-page) 0%, var(--accent-primary-light) 100%);
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  padding: 48px 40px 40px;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  width: 420px;
  max-width: 100%;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  animation: fadeInUp 0.5s ease;
  border: 1px solid var(--border-color);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 4px;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
}

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

/* ── App Container ── */
.app {
  display: none;
  width: 100%;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 250px;
  background: var(--bg-sidebar);
  color: #fff;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
  box-shadow: var(--shadow-sidebar);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.sidebar-title h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-title small {
  color: var(--text-sidebar-muted);
  font-size: 11px;
  display: block;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebarLocation {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-sidebar-muted);
  max-width: 160px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-sidebar);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar nav {
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar nav::-webkit-scrollbar {
  width: 3px;
}

.sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ── Navigation Items ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--text-sidebar);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.nav-item:hover .nav-icon {
  color: inherit;
}

.nav-item.active {
  background: rgba(79, 110, 247, 0.15);
  color: var(--text-sidebar-active);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  background: var(--accent-primary);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
}

.nav-item.active .nav-icon {
  color: var(--accent-primary);
  opacity: 1;
}

.nav-icon {
  font-size: 15px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Collapsed Sidebar ── */
.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .sidebar-header {
  padding: 20px 12px;
  justify-content: center;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-header small,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-info .name,
.sidebar.collapsed .user-info .role,
.sidebar.collapsed .user-info #logoutBtn,
.sidebar.collapsed .theme-toggle .nav-text {
  display: none;
}

.sidebar.collapsed .sidebar-toggle {
  margin: 0;
}

.sidebar.collapsed .nav-item {
  padding: 10px 0;
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .nav-item .nav-icon {
  margin: 0;
  font-size: 17px;
}

.sidebar.collapsed .user-info {
  padding: 12px 8px;
  text-align: center;
}

.sidebar.collapsed .theme-toggle {
  padding: 8px 0;
  justify-content: center;
}

/* ── Theme Toggle & User Info ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  margin-top: 2px;
  background: none;
  border: none;
  color: var(--text-sidebar);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.theme-toggle-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}

.sidebar .user-info {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
}

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

.sidebar .user-info .role {
  font-size: 11px;
  color: var(--text-sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#logoutBtn {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-sidebar);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  width: 100%;
  transition: all 0.2s;
}

#logoutBtn:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ── Main Content ── */
.main {
  flex: 1;
  margin-left: 250px;
  padding: 28px 32px;
  min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
}

.page-section {
  display: none;
  animation: fadeIn 0.2s ease;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

/* ── Mobile Header ── */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* ── Responsive Design ── */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-sidebar);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  .mobile-header-title {
    font-size: 15px;
    font-weight: 600;
  }

  .mobile-menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
  }

  .mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.12);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 101;
    backdrop-filter: blur(2px);
  }

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

  .sidebar {
    transform: translateX(-100%);
    width: 280px !important;
    z-index: 102;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  }

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

  .sidebar.collapsed {
    transform: translateX(-100%);
    width: 280px !important;
  }

  .sidebar.collapsed .sidebar-header h2,
  .sidebar.collapsed .sidebar-header small,
  .sidebar.collapsed .nav-text,
  .sidebar.collapsed .user-info .name,
  .sidebar.collapsed .user-info .role,
  .sidebar.collapsed .user-info #logoutBtn,
  .sidebar.collapsed .theme-toggle .nav-text {
    display: block;
  }

  .sidebar.collapsed .sidebar-header {
    padding: 20px 20px;
    justify-content: space-between;
  }

  .sidebar.collapsed .nav-item {
    padding: 9px 20px;
    justify-content: flex-start;
    gap: 12px;
  }

  .sidebar.collapsed .nav-item .nav-icon {
    font-size: 15px;
  }

  .sidebar.collapsed .user-info {
    padding: 14px 20px;
    text-align: left;
  }

  .sidebar.collapsed .theme-toggle {
    padding: 8px 20px;
    justify-content: flex-start;
  }

  .main {
    margin-left: 0 !important;
    padding: 16px;
    padding-top: 64px;
  }

  .login-container {
    padding: 80px 16px 24px;
  }

  .login-box {
    width: 100%;
    max-width: 400px;
    padding: 28px 20px 24px;
  }

  .login-box h1 {
    font-size: 22px;
  }

  .login-box .subtitle {
    margin-bottom: 24px;
    font-size: 13px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .sidebar-toggle {
    display: none;
  }

  /* Better mobile tap targets */
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  select.form-control {
    font-size: 16px;
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .toast-container {
    right: 10px;
    left: 10px;
    top: 60px;
  }

  .toast {
    min-width: 0;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 12px;
    padding-top: 62px;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .login-box {
    padding: 24px 18px 20px;
  }
}
