/* ╔══════════════════════════════════════════════════════════════╗
   ║  MO Qutp - التخطيط الرئيسي (النمط الأبيض الثمين)             ║
   ║  Sidebar, Header, Content Area                               ║
   ╚══════════════════════════════════════════════════════════════╝ */

/* ===== App Layout ===== */
.app {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  background-color: var(--bg-primary);
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  right: 0;
  top: 0;
  z-index: var(--z-sidebar);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid var(--border-secondary);
  min-height: 80px;
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-600), var(--accent-rose));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  color: white;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand h2 {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--primary-800);
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.sidebar-brand small {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: 500;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-title {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: var(--space-md) var(--space-md) var(--space-xs);
  font-weight: 700;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 14px;
  margin: 3px 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  position: relative;
  white-space: nowrap;
  min-height: 44px;
  font-weight: 500;
}

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

.sidebar-item.active {
  background: #f3e8ff;
  color: var(--primary-700);
  font-weight: 700;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 65%;
  background: var(--primary-600);
  border-radius: var(--radius-full);
}

.sidebar-item-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: 0.85;
}

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

.sidebar-item-text {
  font-size: var(--text-sm);
  overflow: hidden;
}

.sidebar-item-badge {
  margin-right: auto;
  margin-left: 0;
  background: var(--accent-rose);
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: #fafafa;
}

.sidebar-footer-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-600), var(--secondary-400));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sidebar-footer-info {
  overflow: hidden;
}

.sidebar-footer-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-footer-role {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ===== Main Content Area ===== */
.main {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
}

/* ===== Header ===== */
.header {
  height: var(--header-height);
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-primary);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.header-breadcrumb span {
  color: var(--text-secondary);
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--primary-50);
  color: var(--primary-600);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-search {
  position: relative;
  width: 260px;
}

.header-search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 16px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.header-search input:focus {
  background: #ffffff;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-action-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
  position: relative;
  transition: all var(--transition-fast);
}

.header-action-btn:hover {
  background: #ffffff;
  color: var(--primary-600);
  border-color: var(--primary-300);
  box-shadow: var(--shadow-sm);
}

.notification-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-rose);
  border: 2px solid white;
}

/* ===== Content Area ===== */
.content {
  flex: 1;
  padding: var(--space-xl);
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

/* ===== Responsive & Mobile Fix (Samsung Internet Safe) ===== */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

@media screen and (max-width: 1400px), screen and (max-device-width: 1200px), (pointer: coarse), (hover: none) {
  .sidebar {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: -320px !important;
    left: auto !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 99999 !important;
    transform: none !important;
    box-shadow: none !important;
  }

  .sidebar.open {
    display: flex !important;
    right: 0 !important;
    animation: slideInSidebarRTL 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: -10px 0 40px rgba(15, 23, 42, 0.35) !important;
  }

  .main {
    margin-right: 0 !important;
    width: 100% !important;
  }

  .menu-toggle {
    display: flex !important;
  }

  .header-search {
    width: 180px;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99990;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
  }

  .sidebar-overlay.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
}

@keyframes slideInSidebarRTL {
  from {
    right: -320px;
    opacity: 0;
  }
  to {
    right: 0;
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .content {
    padding: var(--space-md);
  }

  .header {
    padding: 0 var(--space-md);
  }

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

  .header-search {
    display: none;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: var(--text-xl);
  }
}
