/**
 * Rafidain floating chat assistant — standalone (index + Netlify).
 * Prefix: rcb-
 */

.rcb-root {
  --rcb-lapis: #1b3d6e;
  --rcb-lapis2: #0f1a2e;
  --rcb-gold: #e8b84b;
  --rcb-gold-d: #c9921a;
  --rcb-text: #e8edf5;
  --rcb-muted: rgba(232, 237, 245, 0.72);
  --rcb-radius: 18px;
  position: fixed;
  z-index: 880;
  inset-inline-end: max(12px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  font-family: "Cairo", "Segoe UI", system-ui, sans-serif;
  direction: rtl;
  text-align: right;
}

.rcb-fab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 999px;
  border: 1px solid rgba(232, 184, 75, 0.45);
  background: linear-gradient(135deg, var(--rcb-lapis), var(--rcb-lapis2));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(13, 34, 64, 0.5), 0 0 0 1px rgba(232, 184, 75, 0.15);
  transition: transform 0.18s ease, box-shadow 0.2s ease;
  max-width: calc(100vw - 24px);
}

.rcb-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(13, 34, 64, 0.55), 0 0 28px rgba(232, 184, 75, 0.22);
}

.rcb-fab:focus-visible {
  outline: 3px solid var(--rcb-gold);
  outline-offset: 3px;
}

.rcb-fab-ico {
  font-size: 1.35rem;
  line-height: 1;
}

.rcb-fab-txt {
  white-space: nowrap;
}

@media (max-width: 380px) {
  .rcb-fab-txt {
    display: none;
  }
  .rcb-fab {
    padding: 14px 16px;
  }
}

.rcb-panel {
  position: absolute;
  inset-inline-end: 0;
  bottom: calc(100% + 12px);
  width: min(100vw - 24px, 400px);
  max-height: min(85vh, 560px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #121f36, #0a1220);
  border: 1px solid rgba(232, 184, 75, 0.35);
  border-radius: var(--rcb-radius);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.rcb-panel[hidden] {
  display: none !important;
}

.rcb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(232, 184, 75, 0.1);
  border-bottom: 1px solid rgba(232, 184, 75, 0.22);
  flex-shrink: 0;
}

.rcb-title {
  font-weight: 900;
  font-size: 15px;
  color: var(--rcb-gold);
  margin: 0;
}

.rcb-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rcb-icon-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--rcb-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.rcb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.rcb-icon-btn--close {
  font-size: 22px;
  line-height: 1;
  padding: 0;
  width: 40px;
}

.rcb-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.rcb-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--rcb-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 3px solid transparent;
}

.rcb-tab[aria-selected="true"] {
  color: var(--rcb-gold);
  border-bottom-color: var(--rcb-gold-d);
}

.rcb-view {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.rcb-view--active {
  display: flex;
}

.rcb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.rcb-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.rcb-bubble--user {
  align-self: flex-start;
  background: rgba(27, 61, 110, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--rcb-text);
}

.rcb-bubble--assistant {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(232, 184, 75, 0.2);
  color: var(--rcb-text);
}

.rcb-meta {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--rcb-muted);
  opacity: 0.9;
}

.rcb-hint {
  margin: 0 12px 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--rcb-muted);
  flex-shrink: 0;
}

.rcb-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  align-items: flex-end;
}

.rcb-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--rcb-text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.rcb-input::placeholder {
  color: rgba(232, 237, 245, 0.45);
}

.rcb-input:focus {
  outline: none;
  border-color: rgba(232, 184, 75, 0.5);
  box-shadow: 0 0 0 2px rgba(232, 184, 75, 0.15);
}

.rcb-send {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--rcb-gold-d), var(--rcb-gold));
  color: #0a1220;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.rcb-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rcb-handoff {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rcb-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rcb-field label {
  font-size: 12px;
  font-weight: 800;
  color: var(--rcb-muted);
}

.rcb-field input,
.rcb-field textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--rcb-text);
  font-size: 14px;
  font-family: inherit;
}

.rcb-field textarea {
  min-height: 72px;
  resize: vertical;
}

.rcb-field input:focus,
.rcb-field textarea:focus {
  outline: none;
  border-color: rgba(232, 184, 75, 0.45);
}

.rcb-handoff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.rcb-btn-secondary {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--rcb-text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.rcb-status {
  font-size: 13px;
  color: var(--rcb-gold);
  margin: 0;
  min-height: 1.2em;
}

@media (prefers-reduced-motion: reduce) {
  .rcb-fab {
    transition: none;
  }
  .rcb-fab:hover {
    transform: none;
  }
}

.rcb-open .rcb-fab {
  box-shadow: 0 8px 28px rgba(13, 34, 64, 0.45);
}
