/**
 * Portal Header v3 - Rebuilt from Scratch
 * 
 * MAX Z-INDEX - Simple Structure
 * 
 * @package RivaClientPortal
 * @version 1.4.0
 */

/* ========================================
   GLOBAL GRADIENT BACKGROUND - TÜM PORTAL
   ======================================== */

.riva-portal-page .rcp-gradient-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(120deg, #1a1f3a, #0e364f, #2d6a4f, #7b2cbf);
  background-size: 400% 400%;
  animation: rcpGradient 18s ease infinite;
  z-index: 0;
  pointer-events: none;
}

@keyframes rcpGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ========================================
   TOPBAR - TEMİZ VE NET
   ======================================== */

.rcp-header {
  position: fixed;
  top: 0;
  left: 0 !important;
  right: 0;
  width: 100vw;
  margin-left: 0 !important;
  height: 64px;
  padding-top: env(safe-area-inset-top); /* iOS safe area */
  z-index: 1100 !important; /* Fixed z-index */
  /* REMOVED: Direct background - using layered approach for glass effect */
  /* Stacking: gradient overlay (::before) + blur (::after) */
  isolation: isolate; /* Create new stacking context for pseudo-elements only */
}

/* Premium Dark Glass - Blur Layer (Desktop & Mobile) */
.rcp-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(12, 16, 24, 0.35); /* Dark glass base - slightly more opaque for better readability */
  backdrop-filter: blur(14px) saturate(180%); /* Premium blur effect */
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: -1; /* Behind header content */
  pointer-events: none;
}

/* Subtle Gradient Overlay (Desktop & Mobile) */
.rcp-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, 
    rgba(0, 122, 255, 0.08) 0%,    /* Subtle blue glow at top */
    rgba(12, 16, 24, 0.15) 100%    /* Dark fade at bottom */
  );
  z-index: -1;
  pointer-events: none;
}

.rcp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  width: 100%;
  max-width: 100%;
  position: relative; /* Ensure dropdowns can position relative to topbar */
  overflow: visible !important; /* CRITICAL: Allow dropdowns to overflow */
  box-sizing: border-box; /* Padding dahil tam genişlik */
}

.rcp-topbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: visible !important; /* Allow dropdowns to overflow */
  position: relative;
  z-index: 10001; /* Above hamburger to prevent dropdown overlap on left side */
}

/* Mobile Sidebar Toggle */
.rcp-sidebar__toggle {
  display: none; /* Desktop'ta gizli */
  background: none;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #ffffff;
  position: relative;
  z-index: 1105; /* Just above header */
  opacity: 1;
  visibility: visible;
}

/* Hide hamburger when user menu is open (clean UI) */
.rcp-user-menu--active ~ .rcp-topbar__left .rcp-sidebar__toggle,
body:has(.rcp-user-menu--active) .rcp-sidebar__toggle {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.rcp-sidebar__toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.rcp-sidebar__hamburger {
  display: block;
  width: 20px;
  height: 2px;
  background: #ffffff;
  position: relative;
  transition: all 0.3s ease;
}

.rcp-sidebar__hamburger::before,
.rcp-sidebar__hamburger::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: #ffffff;
  transition: all 0.3s ease;
}

.rcp-sidebar__hamburger::before {
  top: -6px;
}

.rcp-sidebar__hamburger::after {
  top: 6px;
}

.rcp-sidebar__toggle:hover .rcp-sidebar__hamburger {
  background: #ffd700;
}

.rcp-sidebar__toggle:hover .rcp-sidebar__hamburger::before,
.rcp-sidebar__toggle:hover .rcp-sidebar__hamburger::after {
  background: #ffd700;
}

.rcp-topbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: visible !important; /* Allow dropdowns to overflow */
  position: relative; /* Dropdown positioning reference */
}

/* Logo */
.rcp-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rcp-logo__image {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
}

.rcp-logo__text {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========================================
   NOTIFICATIONS
   ======================================== */

.rcp-notifications {
  position: relative;
}

.rcp-notifications__toggle {
  position: relative;
  background: none;
  border: none;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  color: rgba(255, 255, 255, 0.7);
}

.rcp-notifications__toggle:hover {
  background: rgba(10, 132, 255, 0.15);
  color: #ffffff;
}

.rcp-notifications__icon {
  font-size: 20px;
  display: block;
}

.rcp-notifications__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #ff453a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rcp-notifications__dropdown {
  position: fixed; /* FIXED instead of absolute to escape stacking context */
  top: calc(64px + env(safe-area-inset-top) + 8px); /* Below header + safe area */
  right: 16px;
  width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 9999 !important; /* Very high to escape any stacking context */
}

.rcp-notifications--active .rcp-notifications__dropdown {
  display: block;
  animation: dropdownFadeIn 0.2s ease-out;
}

.rcp-notifications__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rcp-notifications__header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

.rcp-notifications__content {
  padding: 8px;
}

/* ========================================
   USER MENU
   ======================================== */

.rcp-user-menu {
  position: relative;
}

.rcp-user-menu__toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  color: #ffffff;
}

.rcp-user-menu__toggle:hover {
  background: rgba(10, 132, 255, 0.15);
}

.rcp-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.rcp-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rcp-avatar__initials {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.rcp-avatar--lg {
  width: 48px;
  height: 48px;
}

.rcp-avatar--lg .rcp-avatar__initials {
  font-size: 18px;
}

.rcp-user-menu__name {
  font-size: 14px;
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rcp-user-menu__arrow {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease;
}

.rcp-user-menu--active .rcp-user-menu__arrow {
  transform: rotate(180deg);
}

.rcp-user-menu__dropdown {
  position: fixed; /* FIXED instead of absolute to escape stacking context */
  top: calc(64px + env(safe-area-inset-top) + 8px); /* Below header + safe area */
  right: 16px;
  min-width: 280px;
  max-height: calc(100vh - 80px - env(safe-area-inset-top)); /* Prevent overflow below screen */
  overflow-y: auto; /* Allow scroll for long content */
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 9999 !important; /* Very high to escape any stacking context */
}

.rcp-user-menu--active .rcp-user-menu__dropdown {
  display: block;
  animation: dropdownFadeIn 0.2s ease-out;
}

.rcp-user-menu__info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.rcp-user-menu__details {
  flex: 1;
  min-width: 0;
}

.rcp-user-menu__details .rcp-user-menu__name {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  margin: 0 0 4px 0;
  max-width: none;
}

.rcp-user-menu__email {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rcp-user-menu__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 0;
}

.rcp-user-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #ffffff;
  text-decoration: none;
  transition: background 0.2s ease;
  font-size: 14px;
}

.rcp-user-menu__item:hover {
  background: rgba(10, 132, 255, 0.15);
}

.rcp-user-menu__item--danger {
  color: #ff453a;
}

.rcp-user-menu__item--danger:hover {
  background: rgba(255, 69, 58, 0.15);
}

.rcp-user-menu__icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* ========================================
   SIDEBAR - ŞEFFAF BACKGROUND
   ======================================== */

.rcp-sidebar {
  position: fixed;
  top: 64px;
  left: 0 !important;
  bottom: 0;
  width: 280px;
  margin-left: 0 !important;
  background: rgba(12, 16, 24, 0.98); /* Solid dark background - NO BLUR */
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  z-index: 9999 !important; /* CRITICAL: Override diğer CSS dosyalarındaki z-index */
  transition: transform 0.3s ease;
  transform: translateX(0); /* Desktop: Açık */
}

/* Mobile Close Button - REMOVED (kullanıcılar overlay veya hamburger ile kapatır) */

.rcp-sidebar__content {
  padding: 24px 0;
}

/* ========================================
   NAVIGATION
   ======================================== */

.rcp-nav {
  padding: 0 16px;
}

.rcp-nav__section {
  margin-bottom: 32px;
}

.rcp-nav__section:last-child {
  margin-bottom: 0;
}

.rcp-nav__title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
  padding: 0 12px;
}

.rcp-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.2s ease;
  position: relative;
  font-size: 14px;
  font-weight: 500;
}

.rcp-nav__item:hover {
  background: rgba(10, 132, 255, 0.15);
  color: #ffffff;
  transform: translateX(4px);
}

.rcp-nav__item--active {
  background: #0a84ff;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.4);
}

.rcp-nav__item--active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #0a84ff;
  border-radius: 0 2px 2px 0;
}

.rcp-nav__item--whatsapp {
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.rcp-nav__item--whatsapp:hover {
  transform: translateX(4px) scale(1.02);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

.rcp-nav__icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.rcp-nav__text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rcp-nav__badge {
  background: #ff453a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ========================================
   SIDEBAR OVERLAY - MOBILE
   ======================================== */

.rcp-sidebar-overlay {
  display: none;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.5) !important; /* Semi-transparent dark overlay, NO BLUR */
  z-index: 9998 !important; /* CRITICAL: Sidebar altında (9999), content üstünde */
  transform: none !important; /* Prevent any transform inheritance */
  backdrop-filter: none !important; /* NO BLUR on overlay */
  -webkit-backdrop-filter: none !important; /* NO BLUR on overlay */
}

.rcp-sidebar-overlay.active {
  display: block !important;
}

/* ========================================
   MAIN CONTENT - Offset removed (using portal.css standard)
   ======================================== */

.rcp-main__content {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */

@media (max-width: 1024px) {
  .rcp-topbar {
    padding: 0 20px;
  }
  
  .rcp-sidebar {
    width: 260px;
  }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */

@media (max-width: 768px) {
  /* Premium Glass Effect on Mobile */
  .rcp-header {
    margin: 0; /* ✅ Tam genişlik için boşlukları kaldır */
    width: 100%; /* ✅ Tam ekran genişlik */
    left: 0;
    right: 0;
    border-radius: 0; /* ✅ Mobil'de yuvarlak köşe yok (modern tasarım) */
    overflow: visible !important; /* CRITICAL: Don't clip dropdowns! */
  }
  
  /* Pseudo-elements düz köşe */
  .rcp-header::before {
    border-radius: 0;
    overflow: hidden;
  }
  
  .rcp-header::after {
    border-radius: 0;
    overflow: hidden;
  }
  
  .rcp-topbar {
    padding: 0 16px;
  }
  
  .rcp-logo__text {
    font-size: 18px;
  }
  
  .rcp-user-menu__name {
    display: none; /* Sadece avatar göster */
  }
  
  /* Mobile hamburger görünür */
  .rcp-sidebar__toggle {
    display: block !important;
  }
  
  /* Sidebar - Kapalı */
  .rcp-sidebar {
    width: 280px;
    top: 0 !important; /* Full height on mobile */
    left: 0 !important; /* Flush to left edge */
    margin-left: 0 !important; /* No left margin */
    height: 100vh;
    max-height: 100vh;
    bottom: auto; /* Override bottom from desktop */
    transform: translateX(-100%); /* Gizli */
    z-index: 9999 !important; /* CRITICAL: Overlay'ın üstünde olmalı (portal.css override) */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile iOS */
    /* FIX: Scroll için flexbox yapısı */
    display: flex;
    flex-direction: column;
    /* FIX: Tam solid background - NO BLUR */
    background: rgba(12, 16, 24, 1) !important; /* Tamamen solid, şeffaflık yok */
  }
  
  /* Sidebar açık durumu */
  .rcp-sidebar.rcp-sidebar--open {
    transform: translateX(0); /* Açık */
  }
  
  /* FIX: Sidebar content scroll için */
  .rcp-sidebar__content {
    padding: 24px 0;
    padding-bottom: 180px !important; /* Extra bottom padding for mobile browser UI + WhatsApp button */
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Scroll için yeterli height */
    min-height: 0; /* Flexbox için önemli */
    overscroll-behavior-y: contain; /* Prevent parent scroll when at top/bottom */
  }
  
  /* Close button removed - not needed */
  
  /* Main content - Full width */
  .rcp-main {
    margin-left: 0;
  }
  
  .rcp-main__content {
    padding: 20px 16px;
  }
  
  /* Overlay aktif */
  .rcp-sidebar-overlay {
    z-index: 9998 !important; /* Sidebar altında */
  }
  
  /* Dropdown'lar daha dar */
  .rcp-notifications__dropdown {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
  }
  
  .rcp-user-menu__dropdown {
    width: calc(100vw - 32px);
    right: 16px;
  }
}

@media (max-width: 480px) {
  .rcp-topbar {
    padding: 0 12px;
  }
  
  .rcp-topbar__right {
    gap: 8px;
  }
  
  .rcp-main__content {
    padding: 16px 12px;
  }
  
  .rcp-notifications__dropdown {
    max-height: 300px;
  }
}

/* ========================================
   DESKTOP - SIDEBAR HER ZAMAN AÇIK
   ======================================== */

@media (min-width: 769px) {
  .rcp-sidebar__close {
    display: none !important; /* Desktop'ta hiç görünmez */
  }
  
  .rcp-sidebar-overlay {
    display: none !important; /* Desktop'ta overlay yok */
  }
  
  .rcp-sidebar {
    transform: translateX(0) !important; /* Her zaman açık */
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  .rcp-header {
    border-bottom: 2px solid #ffffff;
  }
  
  .rcp-nav__item--active {
    background: #ffffff;
    color: #000000;
  }
}

