/**
 * 9jaonCloud Universal App Switcher (Google 9-Dot Waffle Menu)
 * Ultra-Luxury Glassmorphism Dark Theme + 100% Mobile Responsive
 */

:root {
  --waffle-bg: rgba(11, 15, 25, 0.97);
  --waffle-border: rgba(255, 255, 255, 0.1);
  --waffle-text-primary: #f8fafc;
  --waffle-text-secondary: #94a3b8;
  --waffle-hover-bg: rgba(255, 255, 255, 0.08);
  --waffle-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --waffle-font: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nineja-waffle-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-family: var(--waffle-font);
  z-index: 1000;
}

/* Waffle Icon Trigger Button */
.nineja-waffle-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 40px;
  height: 40px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nineja-waffle-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.2);
}

.nineja-waffle-btn:active {
  transform: translateY(0);
}

.nineja-waffle-btn svg {
  width: 20px;
  height: 20px;
}

/* Waffle Dropdown Box */
.nineja-waffle-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 380px;
  max-width: 95vw;
  background: var(--waffle-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--waffle-border);
  border-radius: 20px;
  box-shadow: var(--waffle-shadow);
  display: none;
  flex-direction: column;
  z-index: 999999;
  overflow: hidden;
  animation: waffleFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.nineja-waffle-dropdown.active {
  display: flex;
}

@keyframes waffleFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.nineja-waffle-header {
  padding: 16px 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.nineja-waffle-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: #ffffff;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.nineja-waffle-tag {
  font-size: 11px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* User Session Bar */
.nineja-waffle-user-bar {
  padding: 10px 18px;
  background: rgba(59, 130, 246, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #cbd5e1;
}

.nineja-waffle-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nineja-waffle-user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
}

/* Grid of Apps */
.nineja-waffle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nineja-waffle-grid::-webkit-scrollbar {
  width: 5px;
}

.nineja-waffle-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

/* App Card */
.nineja-waffle-app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 6px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--waffle-text-primary);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nineja-waffle-app-card:hover {
  background: var(--waffle-hover-bg);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  text-decoration: none;
}

.nineja-waffle-app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nineja-waffle-app-card:hover .nineja-waffle-app-icon {
  transform: scale(1.1);
}

.nineja-waffle-app-title {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nineja-waffle-app-cat {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
  display: block;
}

/* Footer */
.nineja-waffle-footer {
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.nineja-waffle-footer a {
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}

.nineja-waffle-footer a:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS FIX
   Fixes menu hiding or overflowing off-screen on mobile devices
   ========================================================================== */
@media (max-width: 576px) {
  .nineja-waffle-dropdown {
    position: fixed !important;
    top: 60px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 80px) !important;
    border-radius: 18px !important;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9) !important;
    z-index: 9999999 !important;
  }

  .nineja-waffle-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    padding: 12px 8px !important;
    max-height: calc(100vh - 200px) !important;
  }

  .nineja-waffle-app-card {
    padding: 10px 4px !important;
  }

  .nineja-waffle-app-icon {
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
  }

  .nineja-waffle-app-title {
    font-size: 11px !important;
  }
}
