:root {
  --ipsw-primary: #2563eb;
  --ipsw-primary-dark: #1e40af;
  --ipsw-primary-soft: rgba(37, 99, 235, 0.1);
  --ipsw-surface: #f8fafc;
  --ipsw-bg: #ffffff;
  --ipsw-text: #1e293b;
  --ipsw-muted: #64748b;
  --ipsw-subtle: #94a3b8;
  --ipsw-border: #e2e8f0;
  --ipsw-success: #22c55e;
  --ipsw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --ipsw-radius: 1.5rem;
}

.ips-widget-root,
.ips-widget-root * { box-sizing: border-box; }

.ips-widget-root {
  position: fixed;
  z-index: 999999;
  inset: auto 24px 24px auto;
  font-family: 'Poppins', system-ui, sans-serif;
  line-height: 1.5;
  color: var(--ipsw-text);
}

/* Launcher Button */
.ips-widget-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 1rem;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ips-widget-launcher:hover {
  transform: scale(1.1) rotate(3deg);
  box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.5);
}

.ips-widget-launcher[aria-expanded="true"] {
  transform: rotate(45deg);
}

.ips-widget-launcher__icon {
  font-size: 1.5rem;
}

.ips-widget-launcher__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Tooltip */
.ips-widget-launcher__tooltip {
  position: absolute;
  right: 100%;
  margin-right: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.2s ease;
}

.ips-widget-launcher:hover .ips-widget-launcher__tooltip {
  opacity: 1;
  transform: translateX(0);
}

.ips-widget-launcher__tooltip-inner {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 8px 16px;
  border-radius: 1rem;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Panel */
.ips-widget-panel {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 2rem;
  box-shadow: var(--ipsw-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Header */
.ips-widget-header {
  padding: 20px;
  background: linear-gradient(to right, #2563eb, #4f46e5);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ips-widget-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ips-widget-logo {
  width: 40px;
  height: 40px;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.ips-widget-brand__copy strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.ips-widget-subtitle {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.ips-widget-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 999px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

.ips-widget-controls {
  display: flex;
  gap: 8px;
}

.ips-widget-control {
  width: 32px;
  height: 32px;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ips-widget-control:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Status Bar */
.ips-widget-status {
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid var(--ipsw-border);
}

.ips-widget-status__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
}

.ips-widget-status__badge {
  background: var(--ipsw-primary-soft);
  color: var(--ipsw-primary);
  padding: 4px 8px;
  border-radius: 0.5rem;
}

.ips-widget-status__meta {
  color: var(--ipsw-muted);
}

/* Navigation */
.ips-widget-nav {
  display: flex;
  padding: 8px;
  gap: 8px;
  background: rgba(255, 255, 255, 0.3);
}

.ips-widget-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 0;
  background: transparent;
  border-radius: 1rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--ipsw-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.ips-widget-tab[data-active="1"] {
  background: #fff;
  color: var(--ipsw-primary);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Steps */
.ips-widget-step {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ips-widget-section-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.ips-widget-section-copy {
  margin: 0;
  font-size: 13px;
  color: var(--ipsw-muted);
}

/* Form */
.ips-widget-form-card {
  background: #fff;
  padding: 16px;
  border-radius: 1.5rem;
  border: 1px solid var(--ipsw-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ips-field span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ipsw-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.ips-input, .ips-textarea, .ips-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--ipsw-border);
  border-radius: 1rem;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
}

.ips-input:focus, .ips-textarea:focus {
  outline: none;
  border-color: var(--ipsw-primary);
}

.ips-button-primary {
  background: var(--ipsw-primary);
  color: #fff;
  border: 0;
  padding: 12px;
  border-radius: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.ips-button-primary:hover {
  opacity: 0.9;
}

/* Thread */
.ips-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 20px;
}

/* Composer */
.ips-composer-shell {
  padding: 16px;
  background: #fff;
  border-top: 1px solid var(--ipsw-border);
}

.ips-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ips-composer__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ips-composer__toolbar {
  display: flex;
  gap: 8px;
}

.ips-toolbar-button, .ips-upload-label {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ipsw-surface);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 14px;
}

.ips-composer__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ips-composer-hint {
  font-size: 11px;
  color: var(--ipsw-muted);
}

.ips-send-message {
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  background: var(--ipsw-primary);
  color: #fff;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .ips-widget-panel[data-fullscreen="1"] {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
}
