/* ============================================================
   chat.css — Contact Form + Chat Widget
   Portfolio · Luigipower5798
   ============================================================ */

/* ── 1. CONTACT FORM ──────────────────────────────────────── */

.contact-form {
  width: 100%;
  max-width: 680px;
  margin: 0 auto 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.form-group label {
  font-size: .8rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.form-group input,
.form-group textarea {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: .85rem 1rem;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
  font-size: .92rem;
  line-height: 1.5;
  outline: none;
  transition: border-color .22s ease, box-shadow .22s ease, background .22s ease;
  width: 100%;
  resize: vertical;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #475569;
}

.form-group input:hover,
.form-group textarea:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.055);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: #6c63ff;
  background: rgba(108, 99, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.18);
}

.form-group textarea {
  min-height: 130px;
}

/* Submit button — reuse btn-primary style */
.form-submit {
  align-self: flex-start;
  margin-top: .25rem;
  cursor: pointer;
  border: none;
  font-family: 'Inter', sans-serif;
}

/* Feedback messages */
.form-feedback {
  font-size: .87rem;
  padding: .65rem 1rem;
  border-radius: 8px;
  display: none;
  margin-top: .25rem;
  font-weight: 500;
}

.form-feedback.success {
  display: block;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.form-feedback.error {
  display: block;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.form-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none !important;
}


/* ── 2. CHAT WIDGET ───────────────────────────────────────── */

.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* Toggle button */
.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 30px rgba(108, 99, 255, 0.45);
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
  flex-shrink: 0;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(108, 99, 255, 0.55);
}

/* Pulse animation when there are unread messages */
.chat-toggle.has-unread {
  animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(108, 99, 255, 0.45); }
  50% { box-shadow: 0 8px 40px rgba(108, 99, 255, 0.75), 0 0 0 8px rgba(108, 99, 255, 0.12); }
}

/* Unread badge */
.chat-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

/* Chat panel */
.chat-panel {
  width: 360px;
  height: 520px;
  background: #0d1221;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(108, 99, 255, 0.1);
  transform: translateY(110%) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  transform-origin: bottom right;
}

.chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

@media (max-width: 420px) {
  .chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 80px;
  }
  .chat-widget { right: 16px; bottom: 16px; }
}

/* Chat header */
.chat-header {
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.chat-header-name {
  font-weight: 700;
  font-size: .92rem;
  color: #fff;
}

.chat-header-status {
  font-size: .73rem;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: .1rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.8);
  animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.chat-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .85rem;
  line-height: 1;
  transition: background .2s;
  flex-shrink: 0;
}

.chat-close-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* Name prompt */
.chat-name-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
}

.chat-name-prompt p {
  font-size: .9rem;
  color: #94a3b8;
  line-height: 1.5;
}

.chat-name-prompt input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: .75rem 1rem;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  text-align: center;
  transition: border-color .2s, box-shadow .2s;
}

.chat-name-prompt input:focus {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.18);
}

.chat-name-prompt .btn-primary {
  cursor: pointer;
  border: none;
  font-family: 'Inter', sans-serif;
  width: 100%;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

/* Message bubbles */
.chat-msg-wrap {
  display: flex;
  flex-direction: column;
}

.chat-msg-wrap.msg-visitor { align-items: flex-end; }
.chat-msg-wrap.msg-admin   { align-items: flex-start; }

.chat-bubble {
  max-width: 78%;
  padding: .6rem .9rem;
  border-radius: 14px;
  font-size: .855rem;
  line-height: 1.55;
  word-break: break-word;
}

.msg-visitor .chat-bubble {
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-admin .chat-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.chat-msg-time {
  font-size: .65rem;
  color: #475569;
  margin-top: .18rem;
  padding: 0 .1rem;
}

/* Empty messages state */
.chat-msgs-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: .82rem;
  text-align: center;
  padding: 1rem;
}

/* Input area */
.chat-input-area {
  padding: .6rem .75rem .75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: .4rem;
  align-items: center;
}

/* Upload preview pill — sits above the input row */
.chat-upload-preview {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(108,99,255,.1);
  border: 1px solid rgba(108,99,255,.25);
  border-radius: 8px;
  padding: .3rem .65rem;
  font-size: .76rem;
  color: #a5b4fc;
}
.chat-upload-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.chat-upload-preview button { margin-left: auto; background: none; border: none; color: #ef4444; cursor: pointer; font-size: .85rem; line-height: 1; flex-shrink: 0; }

/* Lightbox */
.chat-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.chat-lightbox.open { display: flex; }
.chat-lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

/* File bubbles */
.chat-file-img {
  max-width: 180px;
  max-height: 140px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
  transition: opacity .15s;
}
.chat-file-img:hover { opacity: .85; }

.chat-file-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.2);
  padding-bottom: .1rem;
}
.chat-file-link:hover { border-bottom-color: currentColor; }

.chat-input-area input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: .65rem .9rem;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
  font-size: .88rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.chat-input-area input::placeholder { color: #475569; }

.chat-input-area input:focus {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

#chatSendBtn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
}

#chatSendBtn:hover { opacity: .85; transform: scale(1.05); }
#chatSendBtn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* Session closed state */
/* Read receipts */
.chat-receipt { font-size: .7rem; margin-left: .2rem; transition: color .3s; }
.chat-receipt.sent { color: rgba(255,255,255,.4); }
.chat-receipt.seen { color: #4ade80; }

.chat-session-closed {
  padding: .6rem .9rem;
  background: rgba(100, 116, 139, 0.1);
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 8px;
  text-align: center;
  font-size: .78rem;
  color: #64748b;
  margin: .5rem;
}
