/* ── GLOBAL CHAT WIDGET ─────────────────────────────────────────── */
#sr-widget-overlay {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: 'Inter', sans-serif;
}

.sr-widget-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.sr-widget-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.5);
}
.sr-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

.sr-widget-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 400px;
  height: 640px;
  max-height: calc(100vh - 120px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(15, 23, 42, 0.05);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: srPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sr-widget-panel.open {
  display: flex;
}

@keyframes srPopIn {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Chat Topbar */
.sr-topbar {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.sr-topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sr-room-code {
  font-family: monospace;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 6px;
}
.sr-close-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}
.sr-close-btn:hover { color: #fff; }

/* Info Bar */
.sr-info-bar {
  background: #f1f5f9;
  padding: 8px 16px;
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
}
.sr-status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #22c55e;
}

/* Messages Area */
.sr-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

/* Input Area */
.sr-input-area {
  background: #fff;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.sr-textarea {
  flex: 1;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  resize: none;
  max-height: 80px;
  outline: none;
  transition: all 0.2s;
}
.sr-textarea:focus {
  background: #fff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.sr-send-btn {
  width: 40px; height: 40px;
  background: #3b82f6; color: #fff;
  border: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.sr-send-btn:hover { background: #2563eb; }
.sr-attach-btn {
  width: 40px; height: 40px;
  background: #e2e8f0; color: #475569;
  border: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.sr-attach-btn:hover { background: #cbd5e1; color: #0f172a; }

/* Upload Progress */
.sr-upload-progress {
  display: none; align-items: center; gap: 10px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 12px; padding: 10px 14px;
  margin-bottom: 8px;
}
.sr-upload-progress.show { display: flex; }
.sr-progress-bar-wrap { height: 6px; background: #dbeafe; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.sr-progress-bar-fill { height: 100%; width: 0%; background: #3b82f6; transition: width 0.2s; }

/* Custom Notifications */
.sr-notification {
  position: absolute;
  top: 60px;
  left: 20px;
  right: 20px;
  background: #ef4444;
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}
.sr-notification.show {
  transform: translateY(0);
  opacity: 1;
}
.sr-notification.success {
  background: #22c55e;
}

/* Messages Formatting */
.sr-msg { display: flex; flex-direction: column; max-width: 85%; }
.sr-msg.mine { align-self: flex-end; align-items: flex-end; }
.sr-msg.other { align-self: flex-start; align-items: flex-start; }
.sr-msg-nick { font-size: 0.7rem; font-weight: 600; color: #64748b; margin-bottom: 4px; padding: 0 4px; }
.sr-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}
.sr-msg.mine .sr-msg-bubble { background: #3b82f6; color: #fff; border-bottom-right-radius: 4px; }
.sr-msg.other .sr-msg-bubble { background: #e2e8f0; color: #0f172a; border-bottom-left-radius: 4px; }

.sr-msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
  opacity: 0;
  transition: opacity .15s;
}
.sr-msg:hover .sr-msg-actions { opacity: 1; }
.sr-msg-action-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid #d5dce8;
  background: #fff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.68rem;
}
.sr-msg-action-btn:hover {
  border-color: #93c5fd;
  color: #1e40af;
  background: #eff6ff;
}

.sr-msg-expand-link {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 6px;
  color: #1d9bf0;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  text-decoration: none;
}
.sr-msg-expand-link:hover {
  text-decoration: underline;
}

/* File Offer Cards */
.sr-file-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px; font-size: 0.8rem; color: #0f172a; min-width: 200px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.sr-msg.mine .sr-file-card { background: #eff6ff; border-color: #bfdbfe; }
.sr-file-header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.sr-file-icon { width: 32px; height: 32px; border-radius: 8px; background: #e2e8f0; color: #475569; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.sr-file-name { font-weight: 600; word-break: break-all; }
.sr-file-size { font-size: 0.7rem; color: #64748b; }
.sr-file-btn { width: 100%; padding: 6px; margin-top: 4px; border-radius: 6px; border: none; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.sr-file-btn-primary { background: #3b82f6; color: #fff; }
.sr-file-btn-primary:hover { background: #2563eb; }
.sr-file-btn-outline { background: transparent; border: 1px solid #cbd5e1; color: #475569; }
.sr-file-btn-outline:hover { background: #f1f5f9; }
.sr-file-download { display: inline-flex; width: 100%; justify-content: center; align-items: center; gap: 6px; background: #22c55e; color: #fff; padding: 6px; border-radius: 6px; text-decoration: none; font-weight: 600; margin-top: 4px; }
.sr-file-download:hover { background: #16a34a; color: #fff; }

/* System Message */
.sr-sys-msg { align-self: center; background: #e2e8f0; color: #475569; font-size: 0.75rem; padding: 4px 12px; border-radius: 12px; font-weight: 500; }

.sr-owner-controls {
  padding: 8px 16px;
  background: #fff5f5;
  border-bottom: 1px solid #fed7d7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #c53030;
}
.sr-delete-btn {
  background: #e53e3e;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: 600;
}
.sr-delete-btn:hover { background: #c53030; }
.sr-lobby-area {
  padding: 20px;
  display: none;
  flex-direction: column;
  gap: 16px;
  background: #fff;
  flex: 1;
  overflow-y: auto;
}
.sr-lobby-area.active { display: flex; }
.sr-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  outline: none;
  font-family: 'Inter', sans-serif;
}
.sr-input:focus { border-color: #3b82f6; }
.sr-btn {
  width: 100%;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
}
.sr-btn:hover:not(:disabled) { background: #2563eb; }
.sr-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(30%);
}

/* Chat UI Container */
.sr-chat-ui {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.sr-chat-ui.active { display: flex; }

/* ── Verify Button ─────────────────────────────────── */
.sr-verify-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: #374151;
  transition: all 0.25s ease;
}
.sr-verify-btn:hover:not(:disabled) {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 2px 12px rgba(59,130,246,.1);
}
.sr-verify-btn.verified {
  border-color: #10b981;
  background: #ecfdf5;
  color: #059669;
  cursor: default;
}
.sr-verify-btn:disabled {
  cursor: default;
}
.sr-verify-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  border-radius: 8px;
  color: #64748b;
  font-size: 1rem;
  flex-shrink: 0;
  transition: all 0.25s ease;
}
.sr-verify-icon.verified {
  background: #10b981;
  color: #fff;
}
.sr-verify-text {
  flex: 1;
  text-align: left;
}
.sr-verify-arrow {
  color: #94a3b8;
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.sr-verify-btn:hover:not(:disabled) .sr-verify-arrow {
  transform: translateX(3px);
}

/* ── Captcha Modal ─────────────────────────────────── */
.sr-captcha-modal {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  flex-direction: column;
}
.sr-captcha-modal.open {
  display: flex;
}
.sr-captcha-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
}
.sr-captcha-modal-content {
  position: relative;
  z-index: 1;
  margin: auto 16px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: srModalSlideUp 0.3s ease-out;
}
@keyframes srModalSlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sr-captcha-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
}
.sr-captcha-modal-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sr-captcha-modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px;
}
.sr-captcha-modal-close:hover { color: #0f172a; }
.sr-captcha-modal-body {
  padding: 20px 16px;
  display: flex;
  justify-content: center;
}

/* ── MOBILE RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 576px) {
  #sr-widget-overlay {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
  }

  .sr-widget-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
  }

  .sr-widget-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100% !important;
    height: 90vh;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.2);
  }

  .sr-widget-panel.open ~ .sr-widget-btn {
    display: none !important;
  }

  .sr-captcha-modal-inner {
    width: 95% !important;
    max-width: 95% !important;
    margin: 0 auto;
    border-radius: 16px;
  }
}
