/* ==========================================================================
   PORTAL DESIGN SYSTEM - IPHONE 15 PRO MAX & MOBILE HIGH-PERFORMANCE
   Engineered for 120Hz ProMotion Displays & Zero-Latency Page Load
   ========================================================================== */

:root {
  /* Color Palette - Light Enterprise */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-subtle: #e2e8f0;
  --border-focus: #cbd5e1;

  --text-main: #0f172a;       /* Slate 900 */
  --text-muted: #64748b;      /* Slate 500 */
  --text-light: #94a3b8;      /* Slate 400 */
  --text-white: #ffffff;

  /* Accent 1: Agent Controller */
  --agent-primary: #4f46e5;
  --agent-secondary: #3b82f6;
  --agent-border: #c7d2fe;

  /* Accent 2: CRM */
  --crm-primary: #0284c7;
  --crm-secondary: #0d9488;
  --crm-border: #bae6fd;

  /* Accent 3: Billing & POS */
  --pay-primary: #059669;
  --pay-secondary: #10b981;
  --pay-border: #a7f3d0;

  /* Status Colors */
  --status-green: #10b981;
  --status-green-bg: #ecfdf5;
  --status-green-border: #a7f3d0;

  /* Pre-computed shadows optimized for mobile GPU compositor */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 1px 3px 0 rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 16px 30px -8px rgba(15, 23, 42, 0.1);

  /* Native Apple San Francisco + System Font (Instant 0ms FCP on iPhone) */
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-full: 9999px;
  --transition-smooth: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Base Reset & Zero-Delay Touch */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 16px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* Ambient Background Aesthetics - Uses absolute (NOT fixed) for 120Hz smooth scrolling */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  transform: translate3d(0, 0, 0);
}

.glow-1 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(99, 102, 241, 0.02) 50%, transparent 70%);
  top: -60px;
  left: 8%;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.10) 0%, rgba(14, 165, 233, 0.02) 50%, transparent 70%);
  bottom: -80px;
  right: 8%;
}

.ambient-grid-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(148, 163, 184, 0.12) 1px, transparent 0);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.75;
}

/* Portal Layout Wrapper */
.portal-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header Section */
.portal-header {
  text-align: center;
  max-width: 640px;
  margin-bottom: 36px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--status-green-bg);
  border: 1px solid var(--status-green-border);
  padding: 5px 13px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.06);
}

.pulse-indicator {
  position: relative;
  width: 8px;
  height: 8px;
  background-color: var(--status-green);
  border-radius: 50%;
}

.pulse-indicator::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background-color: var(--status-green);
  opacity: 0.4;
  animation: pulse-ring 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  transform: translate3d(0, 0, 0);
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.7; }
  70% { transform: scale(2); opacity: 0; }
  100% { transform: scale(2); opacity: 0; }
}

.status-text {
  font-size: 0.825rem;
  font-weight: 600;
  color: #065f46;
  letter-spacing: 0.01em;
}

.portal-title {
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 10px;
}

.gradient-text {
  background: linear-gradient(135deg, #3b82f6 0%, #4f46e5 50%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Mobile Quick Navigation Bar - Hidden on Desktop */
.mobile-quick-bar {
  display: none;
}

/* Main Cards Grid (3 Columns on Desktop) */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  width: 100%;
  margin-bottom: 24px;
}

/* Individual Portal Card */
.portal-card {
  position: relative;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  contain: layout style;
}

.card-inner {
  position: relative;
  z-index: 2;
  padding: 30px 24px 22px;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.card-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 1;
}

.agent-card .card-glow {
  background: radial-gradient(circle at top right, rgba(79, 70, 229, 0.07), transparent 70%);
}

.crm-card .card-glow {
  background: radial-gradient(circle at top right, rgba(2, 132, 199, 0.07), transparent 70%);
}

.pay-card .card-glow {
  background: radial-gradient(circle at top right, rgba(5, 150, 105, 0.07), transparent 70%);
}

/* Desktop Hover States */
@media (hover: hover) and (pointer: fine) {
  .portal-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
  }

  .agent-card:hover { border-color: var(--agent-border); }
  .crm-card:hover { border-color: var(--crm-border); }
  .pay-card:hover { border-color: var(--pay-border); }

  .portal-card:hover .card-glow { opacity: 1; }
  .portal-card:hover .arrow-icon { transform: translateX(3px); }
  .portal-card:hover .portal-icon { transform: scale(1.05); }
}

.portal-card:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-sm);
}

/* Card Top Section */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.icon-box {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-icon {
  background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.crm-icon {
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.pay-icon {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.portal-icon {
  width: 25px;
  height: 25px;
  transition: transform 0.2s ease;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.tag-online, .tag-active {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.tag-ready {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.tag-online .dot, .tag-active .dot { background: #10b981; }
.tag-ready .dot { background: #0284c7; }

.key-hint {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--text-light);
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

/* Card Content */
.card-content {
  flex-grow: 1;
  margin-bottom: 22px;
}

.card-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.agent-card .card-category { color: #4f46e5; }
.crm-card .card-category { color: #0284c7; }
.pay-card .card-category { color: #059669; }

.card-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.52;
  margin-bottom: 16px;
}

/* Feature checklist pills */
.feature-pills {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.feature-pills li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #334155;
}

.check-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.agent-card .check-icon { color: #4f46e5; }
.crm-card .check-icon { color: #0284c7; }
.pay-card .check-icon { color: #059669; }

/* Card Footer Actions */
.card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  transition: transform 0.15s ease, background 0.15s ease;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

.btn-primary {
  flex: 1;
  color: var(--text-white);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.btn-agent { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%); }
.btn-crm { background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%); }
.btn-pay { background: linear-gradient(135deg, #059669 0%, #047857 100%); }

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

.arrow-icon {
  width: 17px;
  height: 17px;
}

/* Copy URL Button */
.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
  touch-action: manipulation;
}

.btn-copy:active {
  transform: scale(0.92);
  background: #e2e8f0;
}

.copy-icon {
  width: 17px;
  height: 17px;
}

/* Quick Info Bar */
.portal-quickinfo {
  margin-top: 4px;
  margin-bottom: 18px;
}

.info-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.815rem;
  color: var(--text-muted);
  background: #ffffff;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid #e2e8f0;
}

.mini-icon {
  width: 14px;
  height: 14px;
  color: #3b82f6;
  flex-shrink: 0;
}

/* Footer */
.portal-footer {
  text-align: center;
}

.copyright {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 20px -3px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  z-index: 1000;
}

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

.toast-icon {
  width: 18px;
  height: 18px;
  color: #34d399;
  flex-shrink: 0;
}

/* ==========================================================================
   IPHONE & MOBILE OPTIMIZATIONS (120Hz ProMotion Ready)
   ========================================================================== */

/* Tablet (721px - 1080px) */
@media screen and (max-width: 1080px) and (min-width: 721px) {
  .portal-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
  }
}

/* Mobile Devices (Max 720px) */
@media screen and (max-width: 720px) {
  body {
    padding: 12px 10px 24px;
    justify-content: flex-start;
  }

  /* Completely eliminate blur & heavy mask on mobile for 120fps lock */
  .ambient-glow {
    display: none;
  }

  .ambient-grid-pattern {
    opacity: 0.45;
  }

  .portal-wrapper {
    padding: 6px 2px 16px;
  }

  .portal-header {
    margin-bottom: 14px;
  }

  .status-pill {
    padding: 5px 12px;
    margin-bottom: 10px;
  }

  .portal-title {
    font-size: 1.6rem;
    margin-bottom: 6px;
  }

  /* Mobile Quick Navigation Bar */
  .mobile-quick-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 8px 6px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 6px 2px;
    border-radius: var(--radius-md);
    flex: 1;
    text-align: center;
    touch-action: manipulation;
  }

  .mobile-nav-item:active {
    background: #f1f5f9;
    transform: scale(0.95);
  }

  .mobile-nav-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  }

  .mobile-nav-icon svg {
    width: 21px;
    height: 21px;
  }

  .item-agent .mobile-nav-icon { background: linear-gradient(135deg, #4f46e5, #3b82f6); }
  .item-crm .mobile-nav-icon { background: linear-gradient(135deg, #0284c7, #0d9488); }
  .item-pay .mobile-nav-icon { background: linear-gradient(135deg, #059669, #10b981); }

  /* Mobile 1-Column Stack */
  .portal-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 18px;
  }

  .portal-card {
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  }

  .card-inner {
    padding: 20px 16px 16px;
  }

  .card-top {
    margin-bottom: 14px;
  }

  .icon-box {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .portal-icon {
    width: 23px;
    height: 23px;
  }

  .card-title {
    font-size: 1.25rem;
  }

  .card-desc {
    font-size: 0.865rem;
    margin-bottom: 12px;
    line-height: 1.48;
  }

  .feature-pills {
    gap: 6px;
  }

  .feature-pills li {
    font-size: 0.815rem;
  }

  .key-hint {
    display: none;
  }

  .card-footer {
    padding-top: 13px;
  }

  .btn {
    padding: 11px 14px;
    font-size: 0.895rem;
  }

  .btn-copy {
    width: 42px;
    height: 42px;
  }

  .portal-quickinfo {
    margin-top: 4px;
    margin-bottom: 14px;
  }

  .info-item {
    font-size: 0.765rem;
    padding: 6px 12px;
  }

  .copyright {
    font-size: 0.74rem;
  }
}

/* Small Screens (iPhone SE / Foldables / <360px) */
@media screen and (max-width: 360px) {
  .card-inner {
    padding: 16px 12px 12px;
  }

  .card-title {
    font-size: 1.15rem;
  }

  .btn {
    font-size: 0.84rem;
    padding: 9px 10px;
    gap: 5px;
  }
}
