/* ==========================================================================
   Apple Fluid Glass & iOS Neumorphism Design System
   Human Interface Guidelines - Dark Mode Translucent Glass & Tactile Depth
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --apple-bg: #07080a;
  --apple-surface: rgba(28, 28, 32, 0.65);
  --apple-surface-elevated: rgba(38, 38, 44, 0.75);
  --apple-surface-recessed: rgba(12, 13, 16, 0.6);
  --apple-border: rgba(255, 255, 255, 0.08);
  --apple-border-highlight: rgba(255, 255, 255, 0.16);
  --apple-blue: #0a84ff;
  --apple-blue-hover: #0071e3;
  --apple-green: #30d158;
  --apple-text-primary: #f5f5f7;
  --apple-text-secondary: #86868b;
  --apple-text-tertiary: #636366;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", sans-serif;
  background-color: var(--apple-bg);
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(30, 41, 59, 0.4), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(15, 23, 42, 0.3), transparent);
  background-attachment: fixed;
  color: var(--apple-text-primary);
  letter-spacing: -0.011em;
}

code, pre, .font-mono {
  font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   Apple Fluid Glass Materials
   ========================================================================== */

.apple-glass {
  background: var(--apple-surface);
  backdrop-filter: blur(35px) saturate(190%);
  -webkit-backdrop-filter: blur(35px) saturate(190%);
  border: 1px solid var(--apple-border);
  box-shadow: 
    0 12px 32px -8px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 0 var(--apple-border-highlight);
}

.apple-glass-card {
  background: var(--apple-surface);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--apple-border);
  border-radius: 20px;
  box-shadow: 
    0 8px 24px -4px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-glass-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
  box-shadow: 
    0 14px 30px -6px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   iOS Fluid Neumorphism (Depth, Bevels & Recessed Wells)
   ========================================================================== */

.apple-well {
  background: var(--apple-surface-recessed);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.04);
}

.apple-btn-primary {
  background: linear-gradient(180deg, #1a8aff 0%, #0071e3 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 4px 12px rgba(10, 132, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-btn-primary:hover {
  background: linear-gradient(180deg, #2b95ff 0%, #0a7aff 100%);
  box-shadow: 
    0 6px 16px rgba(10, 132, 255, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.apple-btn-primary:active {
  transform: scale(0.98);
}

.apple-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  color: var(--apple-text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.apple-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.apple-btn-secondary:active {
  background: rgba(255, 255, 255, 0.04);
  transform: scale(0.98);
}

/* ==========================================================================
   iOS Segmented Control
   ========================================================================== */

.ios-segmented {
  background: rgba(18, 18, 22, 0.85);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  display: inline-flex;
  gap: 2px;
}

.ios-segmented-item {
  padding: 5px 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--apple-text-secondary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  border: none;
  background: transparent;
}

.ios-segmented-item:hover {
  color: var(--apple-text-primary);
}

.ios-segmented-item.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Navigation Capsule Tabs
   ========================================================================== */

.nav-capsule {
  color: var(--apple-text-secondary);
  border-radius: 14px;
  transition: all 0.2s ease;
  position: relative;
}

.nav-capsule:hover {
  color: var(--apple-text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-capsule.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 
    0 2px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   Markdown Bubble Styling
   ========================================================================== */

.chat-markdown p {
  margin-bottom: 0.75rem;
}

.chat-markdown p:last-child {
  margin-bottom: 0;
}

.chat-markdown pre {
  margin: 0.75rem 0;
  border-radius: 14px;
  overflow-x: auto;
  background: rgba(12, 13, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.chat-markdown code:not(pre code) {
  background: rgba(255, 255, 255, 0.08);
  color: #e5e5ea;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85em;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-markdown ul, .chat-markdown ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.chat-markdown ul {
  list-style-type: disc;
}

.chat-markdown ol {
  list-style-type: decimal;
}

/* ==========================================================================
   Clean Apple Fluid Scrollbar & Form Controls
   ========================================================================== */

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Apple Smooth Toast Notification */
.apple-toast {
  background: rgba(30, 30, 36, 0.85);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.apple-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Cursor typing effect without neon */
.typing-cursor::after {
  content: '│';
  color: var(--apple-blue);
  animation: appleBlink 1s step-start infinite;
  margin-left: 2px;
  font-weight: 300;
}

@keyframes appleBlink {
  50% { opacity: 0; }
}

/* ==========================================================================
   Clean Modal Animations & Dialog Elevation
   ========================================================================== */

#modal-auth:not(.hidden),
#modal-topup:not(.hidden),
#modal-create-key:not(.hidden) {
  animation: modalOverlayFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#modal-auth:not(.hidden) > div,
#modal-topup:not(.hidden) > div,
#modal-create-key:not(.hidden) > div {
  animation: modalDialogPopIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

@keyframes modalDialogPopIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

