/**
 * CoreX UI Components — Glacier glassmorphism
 * Requires tokens.css
 */

/* Focus visibility (keyboard) */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100%;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
}

/* Glass panel / card */
.product-panel,
.cx-panel {
  background: var(--color-glass);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  border: 1px solid var(--border-primary);
  box-shadow: var(--glow-primary);
  border-radius: var(--radius-lg);
}

.cx-panel--elevated {
  background: var(--color-glass-elevated);
  backdrop-filter: blur(var(--blur-elevated));
  -webkit-backdrop-filter: blur(var(--blur-elevated));
}

.glass-nav {
  background: rgba(10, 14, 26, 0.75);
  backdrop-filter: blur(var(--blur-elevated));
  -webkit-backdrop-filter: blur(var(--blur-elevated));
  border-bottom: 1px solid var(--border-subtle);
}

.cx-btn .material-symbols-outlined {
  font-family: "Material Symbols Outlined", sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 1.15em;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  flex-shrink: 0;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined", sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* Buttons */
.cx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}

.cx-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cx-btn--primary {
  background: rgba(var(--color-primary-rgb), 0.2);
  border-color: var(--border-primary-strong);
  color: var(--color-primary);
}

.cx-btn--primary:hover:not(:disabled) {
  background: rgba(var(--color-primary-rgb), 0.35);
  box-shadow: var(--glow-primary-strong);
}

.cx-btn--solid {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
}

.cx-btn--solid:hover:not(:disabled) {
  box-shadow: var(--glow-primary-strong);
  filter: brightness(1.05);
}

.cx-btn--ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
  color: var(--color-on-surface);
  backdrop-filter: blur(8px);
}

.cx-btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.cx-btn--nav {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
}

/* Inputs — force readable dark fields (Tailwind forms plugin overrides otherwise) */
.cx-input,
.cx-select,
#chat-input {
  width: 100%;
  background-color: #121826 !important;
  background-image: none !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #f1f5f9 !important;
  -webkit-text-fill-color: #f1f5f9;
  caret-color: #7dd3fc;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  transition:
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.cx-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aabc4' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.9rem center !important;
  padding-right: 2.25rem;
}

.cx-select option {
  background: #0f1524;
  color: #e8eef8;
}

.cx-input::placeholder,
#chat-input::placeholder {
  color: #94a3b8 !important;
  opacity: 1;
  -webkit-text-fill-color: #94a3b8;
}

.cx-input:-webkit-autofill,
.cx-input:-webkit-autofill:hover,
.cx-input:-webkit-autofill:focus,
#chat-input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #121826 inset !important;
  -webkit-text-fill-color: #f1f5f9 !important;
  caret-color: #7dd3fc;
  transition: background-color 9999s ease-in-out 0s;
}

.cx-input:hover,
.cx-select:hover,
#chat-input:hover {
  border-color: rgba(125, 211, 252, 0.35);
}

.cx-input:focus,
.cx-select:focus,
#chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary), var(--glow-primary);
}

/* Chat widget — modern composer */
#corex-chat-widget #chat-popup {
  border: 1px solid rgba(125, 211, 252, 0.22);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

#corex-chat-widget #chat-messages {
  background:
    radial-gradient(ellipse at top right, rgba(125, 211, 252, 0.06), transparent 55%),
    rgba(8, 12, 22, 0.35);
}

#corex-chat-widget .chat-bubble--assistant {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e8eef8;
  border-radius: 1rem 1rem 1rem 0.25rem;
  font-size: 13px;
  line-height: 1.55;
}

#corex-chat-widget .chat-bubble--user {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.28), rgba(125, 211, 252, 0.12));
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: #fff;
  border-radius: 1rem 1rem 0.25rem 1rem;
  font-size: 13px;
}

#corex-chat-widget #chat-input {
  background-color: #0b1020 !important;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 999px;
  padding: 0.7rem 2.75rem 0.7rem 1rem;
  font-size: 13px !important;
  color: #f8fafc !important;
  -webkit-text-fill-color: #f8fafc;
}

#corex-chat-widget #chat-send {
  right: 0.55rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(125, 211, 252, 0.15);
  color: #7dd3fc;
}

#corex-chat-widget #chat-send:hover {
  background: rgba(125, 211, 252, 0.28);
  color: #fff;
}

/* Mobile nav */
#mobile-nav:not([hidden]) {
  display: block;
}

#mobile-nav[hidden] {
  display: none !important;
}

#corex-chat-widget {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.cx-label {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
}

/* Skeleton loaders */
.cx-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(125, 211, 252, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: cx-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.cx-skeleton--text {
  height: 0.875rem;
  width: 100%;
}

.cx-skeleton--title {
  height: 1.5rem;
  width: 60%;
}

.cx-skeleton--kpi {
  height: 4.5rem;
  width: 100%;
}

.cx-skeleton--avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
}

@keyframes cx-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cx-skeleton {
    animation: none;
    background: rgba(255, 255, 255, 0.06);
  }
}

/* Text contrast helpers (replace white/40 where AA fails) */
.text-muted {
  color: var(--color-on-surface-muted);
}

.text-secondary {
  color: var(--color-on-surface-variant);
}

/* Lazy section placeholder */
.cx-lazy-section[data-lazy="pending"] .cx-lazy-content {
  display: none;
}

.cx-lazy-section[data-lazy="pending"] .cx-lazy-skeleton {
  display: block;
}

.cx-lazy-section[data-lazy="loaded"] .cx-lazy-skeleton {
  display: none;
}

.cx-lazy-section[data-lazy="loaded"] .cx-lazy-content {
  display: block;
  animation: cx-fade-in var(--duration-slow) var(--ease-out);
}

@keyframes cx-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-suggestion {
  font-size: 11px;
  line-height: 1.3;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.25);
  background: rgba(125, 211, 252, 0.08);
  color: rgba(232, 238, 248, 0.9);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.chat-suggestion:hover {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(125, 211, 252, 0.16);
}

/* Form submit overlay */
.cx-form-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(6, 10, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.cx-form-overlay[hidden] {
  display: none !important;
}

.cx-form-overlay__card {
  width: min(400px, 100%);
  text-align: center;
  padding: 2rem 1.6rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(125, 211, 252, 0.3);
  background: rgba(15, 21, 36, 0.98);
  box-shadow: 0 0 48px rgba(125, 211, 252, 0.18);
}

.cx-form-overlay__spinner,
.cx-btn-spinner {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto 1rem;
  border-radius: 999px;
  border: 2px solid rgba(125, 211, 252, 0.2);
  border-top-color: var(--color-primary, #7dd3fc);
  animation: cx-spin 0.7s linear infinite;
}

.cx-btn-spinner {
  width: 1rem;
  height: 1rem;
  margin: 0;
  display: inline-block;
  vertical-align: -0.15rem;
}

.cx-form-overlay__title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 0.4rem;
}

.cx-form-overlay__sub {
  font-size: 0.8125rem;
  color: rgba(232, 238, 248, 0.7);
  margin: 0;
}

body.cx-form-loading {
  overflow: hidden;
}

#form-status {
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.9rem 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

#form-status.cx-form-status--ok {
  border-color: rgba(94, 234, 212, 0.45);
  background: rgba(94, 234, 212, 0.12);
  color: #b6fff0;
}

#form-status.cx-form-status--error {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
}

#contact-form.cx-form--locked {
  opacity: 0.92;
}

#contact-form.cx-form--locked input,
#contact-form.cx-form--locked select,
#contact-form.cx-form--locked button {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.75;
}

#contact-form.cx-form--locked #lead-submit {
  opacity: 1;
  background: rgba(94, 234, 212, 0.18);
  border-color: rgba(94, 234, 212, 0.4);
  color: #b6fff0;
}

@keyframes cx-spin {
  to { transform: rotate(360deg); }
}

