/**
 * Sovereign Mobile Dock & Bento Cockpit
 * Executive Porcelain Light Design System (NEVER Dark Mode)
 * Enforces: Golden Thumb Zone (y >= 450px), 48px trucker targets, 16px iOS anti-zoom
 */

:root {
  --vx-sov-canvas: #f8fafc;
  --vx-sov-card: #ffffff;
  --vx-sov-border: #e2e8f0;
  --vx-sov-ink: #0f172a;
  --vx-sov-sub: #475569;
  --vx-sov-muted: #64748b;
  --vx-sov-accent: var(--vx-accent, #2563eb);
  --vx-sov-accent-glow: var(--vx-accent-glow, rgba(37, 99, 235, 0.28));
  --vx-sov-success: #16a34a;
  --vx-sov-warning: #d97706;
}

/* ─── DESKTOP INVARIANT: STRICTLY N = 0 FOOTPRINT ─── */
@media screen and (min-width: 821px) {
  #vxSovereignMobileDock,
  #vxPreFlightOverlay,
  #vxLiveTwinStatus,
  .vx-mobile-only-cockpit {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* ─── MOBILE ONLY DOCK (<= 820px) ─── */
@media screen and (max-width: 820px) {
  #vxSovereignMobileDock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99990;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--vx-sov-border);
    box-shadow: 0 -4px 20px -2px rgba(15, 23, 42, 0.08);
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)) 14px;
    box-sizing: border-box;
    max-width: 100vw;
    overflow-x: hidden;
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Quick Semantic Chips */
  .vx-sov-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .vx-sov-chips::-webkit-scrollbar {
    display: none;
  }

  .vx-sov-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    color: var(--vx-sov-sub);
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 32px;
  }
  .vx-sov-chip:active {
    background: #e2e8f0;
    transform: scale(0.97);
  }
  .vx-sov-chip.vx-active {
    background: var(--vx-sov-accent);
    color: #ffffff;
    border-color: var(--vx-sov-accent);
  }

  /* Intent Input Bar */
  .vx-sov-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
  }

  #vxMobileIntentInput {
    flex: 1;
    height: 48px;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 24px;
    padding: 0 16px;
    font-size: 16px !important; /* CRITICAL: Anti-iOS auto-zoom standard */
    color: var(--vx-sov-ink);
    box-sizing: border-box;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
  }
  #vxMobileIntentInput:focus {
    border-color: var(--vx-sov-accent);
    box-shadow: 0 0 0 3px var(--vx-sov-accent-glow);
  }

  .vx-sov-icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    border: none;
    background: var(--vx-sov-accent);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    flex-shrink: 0;
    box-shadow: 0 3px 10px var(--vx-sov-accent-glow);
    transition: transform 0.12s ease;
  }
  .vx-sov-icon-btn:active {
    transform: scale(0.94);
  }
  .vx-sov-icon-btn:focus-visible,
  .vx-sov-chip:focus-visible,
  .vx-pf-close:focus-visible,
  #vxBtnSovereignExecute:focus-visible {
    outline: 2px solid var(--vx-sov-accent);
    outline-offset: 2px;
  }
  .vx-sov-icon-btn.vx-loading {
    animation: vxSovSpin 0.75s linear infinite;
    pointer-events: none;
    opacity: 0.85;
  }
  @keyframes vxSovSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  /* Pre-Flight Bento Card Sheet */
  #vxPreFlightOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100020;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  #vxPreFlightOverlay.vx-open {
    opacity: 1;
    pointer-events: auto;
  }

  #vxPreFlightCard {
    background: #ffffff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.2);
    padding: 16px 18px calc(16px + env(safe-area-inset-bottom, 0px)) 18px;
    max-height: 85vh;
    overflow-y: auto;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #vxPreFlightOverlay.vx-open #vxPreFlightCard {
    transform: translateY(0);
  }

  .vx-pf-grabber {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 0 auto 14px auto;
  }

  .vx-pf-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .vx-pf-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dcfce7;
    color: #15803d;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }
  .vx-pf-close {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    color: #475569;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .vx-pf-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--vx-sov-ink);
    margin: 0 0 4px 0;
  }
  .vx-pf-client {
    font-size: 14px;
    font-weight: 600;
    color: var(--vx-sov-sub);
    margin-bottom: 14px;
  }

  /* Bento Mini Ledger */
  .vx-pf-ledger {
    background: #f8fafc;
    border: 1px solid var(--vx-sov-border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
  }
  .vx-pf-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--vx-sov-sub);
    margin-bottom: 6px;
  }
  .vx-pf-row:last-child {
    margin-bottom: 0;
  }
  .vx-pf-row.vx-pf-total {
    font-size: 18px;
    font-weight: 800;
    color: var(--vx-sov-ink);
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
    margin-top: 8px;
  }

  /* 48px/52px Trucker Action Lever */
  #vxBtnSovereignExecute {
    width: 100%;
    min-height: 52px;
    background: var(--vx-sov-accent);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 4px 16px var(--vx-sov-accent-glow);
    transition: transform 0.12s ease, opacity 0.18s ease;
  }
  #vxBtnSovereignExecute:active {
    transform: scale(0.98);
  }
  #vxBtnSovereignExecute:disabled {
    opacity: 0.65;
    cursor: not-allowed;
  }

  /* Dynamic Island Status Capsule (Ley Tola) */
  #vxLiveTwinStatus {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100030;
    background: rgba(15, 23, 42, 0.94);
    color: #ffffff;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  #vxLiveTwinStatus.vx-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  .vx-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
  }
}
/* Home-only entry above the existing navigation; proposals do not invade capture/Director. */
#vxSovereignMobileDock [hidden],#vxPreFlightOverlay[hidden]{display:none!important}
@media(min-width:821px){#vxLivingGlassOverlay{display:none!important}}
@media(max-width:820px){
 #vxSovereignMobileDock{bottom:calc(76px + env(safe-area-inset-bottom,0px));left:8px;right:8px;border:1px solid var(--vx-sov-border);border-radius:14px;padding:8px;max-height:calc(100dvh - 100px);overflow-y:auto}
 #vxApexToggle{width:100%;min-height:48px;background:var(--vx-sov-accent);color:white;border:0;border-radius:10px;font-size:16px;font-weight:700}
 #vxApexPanel{padding-top:8px}#vxApexPanel label{display:block;color:var(--vx-sov-ink)}
 #vxMobileIntentInput{min-width:0;border-radius:12px}
 .vx-sov-chip,.vx-pf-close{min-height:48px;min-width:48px}
 .vx-sov-chips{padding-top:8px}.vx-sov-chip{font-size:14px;text-decoration:none}
 #vxApexCheckpoint{margin:4px;color:var(--vx-sov-sub);font-size:14px}
 #vxLiveTwinStatus{max-width:calc(100vw - 32px);box-sizing:border-box;width:max-content;white-space:normal}
 .vx-pf-badge{background:#e2e8f0;color:#334155}
 #vxPreFlightCard p{overflow-wrap:anywhere}#vxPfSubtotal{white-space:nowrap}
 #vxLivingGlassOverlay{position:fixed;inset:0;background:rgba(15,23,42,.6);z-index:100050;display:flex;align-items:center;justify-content:center;padding:12px;box-sizing:border-box}
 #vxLivingGlassCard{background:white;color:#0f172a;padding:16px;max-width:440px;width:100%;max-height:85dvh;overflow-y:auto;border-radius:16px;box-sizing:border-box;overflow-wrap:anywhere}
 #vxBtnCloseGlass,.vx-apex-link{display:inline-flex;align-items:center;justify-content:center;min-height:48px;min-width:48px;font-size:16px}
 .vx-apex-link{padding:0 12px;background:var(--vx-sov-accent);color:white;border-radius:12px}
}
@media(max-width:820px){
 #vxSovereignMobileDock .vx-sov-chips{overflow:visible;align-items:stretch}
 #vxSovereignMobileDock .vx-sov-chip{flex:1 1 0;min-width:48px;white-space:normal;overflow-wrap:normal;text-align:center;justify-content:center;padding:8px 6px;box-sizing:border-box;line-height:1.25}
 #vxApexToggle:focus-visible,#vxBtnCloseGlass:focus-visible,.vx-apex-link:focus-visible{outline:3px solid var(--vx-sov-accent);outline-offset:3px}
}
@media(prefers-reduced-motion:reduce){#vxSovereignMobileDock,#vxPreFlightOverlay,#vxPreFlightCard,#vxLiveTwinStatus{transition:none!important}.vx-sov-icon-btn.vx-loading{animation:none!important}}
