/* ==========================================================================
   ChatApp (Private 2-User Edition) - Stylesheet
   ========================================================================== */

:root {
  --bg-app: #0c1317;
  --bg-chat: #0b141a;
  --bg-panel: #202c33;
  --bg-panel-hover: #222e35;
  --bg-input: #2a3942;
  --bubble-outgoing: #005c4b;
  --bubble-incoming: #202c33;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --accent-green: #00a884;
  --accent-green-bright: #25d366;
  --accent-danger: #ea4335;
  --accent-blue-tick: #53bdeb;
  --border-light: rgba(134, 150, 160, 0.15);
  --shadow-main: 0 4px 12px rgba(0, 0, 0, 0.35);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Common & Button Utilities
   ========================================================================== */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn {
  border: none;
  cursor: pointer;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background-color: var(--accent-green);
  color: #111b21;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: #029474;
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-weight: 500;
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.btn-danger-solid {
  background-color: var(--accent-danger);
  color: #fff;
  font-weight: 600;
}

.btn-danger-solid:hover {
  background-color: #d93025;
}

/* ==========================================================================
   Login Screen
   ========================================================================== */
.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #182229 0%, #0c1317 100%);
  padding: 20px;
}

.login-card {
  background: var(--bg-panel);
  padding: 40px 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-main);
  border: 1px solid var(--border-light);
}

.app-logo {
  margin-bottom: 16px;
  display: inline-block;
}

.login-card h2 {
  font-size: 24px;
  margin-bottom: 6px;
  font-weight: 600;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.input-group {
  text-align: left;
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 18px;
  letter-spacing: 2px;
  text-align: center;
  color: var(--text-primary);
  outline: none;
  transition: border 0.2s;
}

.input-group input:focus {
  border-color: var(--accent-green);
}

.error-msg {
  color: var(--accent-danger);
  font-size: 13px;
  margin-bottom: 14px;
  min-height: 18px;
}

#login-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

.quick-hints {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.quick-hints code {
  color: var(--accent-green-bright);
  background: rgba(37, 211, 102, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   Main Chat Screen
   ========================================================================== */
#chat-screen {
  display: flex;
  justify-content: center;
  background-color: #0c1317;
}

.chat-container {
  width: 100%;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-chat);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Chat Header */
.chat-header {
  height: 60px;
  background-color: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 10;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a884, #005c4b);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.user-details h3 {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
}

.status-indicator {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

.status-indicator.online {
  color: var(--accent-green-bright);
}

.status-indicator.typing {
  color: var(--accent-green-bright);
  font-style: italic;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-action-btn {
  color: var(--accent-green-bright);
  background-color: rgba(37, 211, 102, 0.1);
}

.call-action-btn:hover {
  background-color: rgba(37, 211, 102, 0.2);
  color: var(--accent-green-bright);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Date separators */
.date-separator {
  align-self: center;
  background-color: #182229;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Message Bubble */
.message-bubble {
  max-width: 75%;
  min-width: 80px;
  padding: 6px 9px 8px 9px;
  border-radius: 8px;
  position: relative;
  font-size: 14.5px;
  line-height: 1.4;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-bubble.incoming {
  align-self: flex-start;
  background-color: var(--bubble-incoming);
  border-top-left-radius: 0;
}

.message-bubble.outgoing {
  align-self: flex-end;
  background-color: var(--bubble-outgoing);
  border-top-right-radius: 0;
}

/* Image in Message */
.message-image-container {
  margin: -2px -5px 4px -5px;
  border-radius: 6px;
  overflow: hidden;
  max-width: 320px;
  max-height: 380px;
  cursor: pointer;
}

.message-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.message-image-container img:hover {
  transform: scale(1.02);
}

/* Message Footer (Time & Status) */
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  float: right;
  margin-left: 10px;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  user-select: none;
}

.bubble-ticks {
  display: inline-flex;
}

.bubble-ticks svg {
  width: 16px;
  height: 11px;
}

.bubble-ticks.read svg {
  fill: var(--accent-blue-tick);
}

.bubble-ticks.sent svg {
  fill: rgba(255, 255, 255, 0.6);
}

/* Image Upload Preview Bar */
.image-preview-bar {
  background: var(--bg-panel);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
}

.preview-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-content img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

.preview-content span {
  font-size: 13px;
  color: var(--text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat Input Footer */
.chat-footer {
  background-color: var(--bg-panel);
  padding: 8px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}

.message-form {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background-color: var(--bg-input);
  border-radius: 24px;
  padding: 4px 14px;
  gap: 8px;
}

.message-form textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 20px;
  resize: none;
  max-height: 100px;
  padding: 6px 0;
  margin: 0;
}

.message-form textarea::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  background: transparent;
  border: none;
  color: var(--accent-green);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover {
  color: var(--accent-green-bright);
}

/* ==========================================================================
   Video Call Screen
   ========================================================================== */
.call-screen {
  position: fixed;
  inset: 0;
  background-color: #0b141a;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  background-color: #111b21;
}

/* Picture in Picture Local Video */
.local-video-container {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 120px;
  height: 170px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.2);
  z-index: 110;
  background-color: #000;
  cursor: grab;
}

#local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror selfie camera */
}

/* Call Overlay Header */
.call-overlay-header {
  position: relative;
  z-index: 110;
  text-align: center;
  padding-top: 40px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
  padding-bottom: 30px;
}

.call-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a884, #005c4b);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 12px;
  border: 3px solid rgba(255, 255, 255, 0.2);
}

.call-overlay-header h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.call-overlay-header p {
  font-size: 14px;
  color: var(--accent-green-bright);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* Bottom Call Controls */
.call-controls {
  position: relative;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}

.call-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
}

.call-btn:hover {
  background-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

.call-btn.btn-danger {
  background-color: var(--accent-danger);
}

.call-btn.btn-danger:hover {
  background-color: #d93025;
}

.call-btn.muted {
  background-color: #fff;
  color: #111b21;
}

/* ==========================================================================
   Incoming Call Dialog
   ========================================================================== */
.incoming-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.incoming-box {
  background-color: var(--bg-panel);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  border: 1px solid var(--border-light);
}

.incoming-avatar-ring {
  width: 90px;
  height: 90px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 211, 102, 0.15);
  animation: pulseRing 1.6s infinite ease-in-out;
}

@keyframes pulseRing {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.incoming-avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a884, #005c4b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 600;
  color: #fff;
}

.incoming-box h3 {
  font-size: 20px;
  margin-bottom: 6px;
}

.incoming-box p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.incoming-actions {
  display: flex;
  justify-content: center;
  gap: 36px;
}

.call-action-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.call-action-circle:hover {
  transform: scale(1.1);
}

.call-action-circle.btn-danger {
  background-color: var(--accent-danger);
}

.call-action-circle.btn-success {
  background-color: var(--accent-green-bright);
}

/* ==========================================================================
   Image Lightbox Modal
   ========================================================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.92);
  z-index: 300;
  display: flex;
  flex-direction: column;
}

.lightbox-top {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
}

.lightbox-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.lightbox-body img {
  max-width: 95%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}

/* ==========================================================================
   Camera Snapshot Modal (Laptop / Mobile Camera Capture)
   ========================================================================== */
.camera-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.88);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.camera-card {
  background: var(--bg-panel);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

.camera-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background-color: #182229;
}

.camera-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.camera-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.camera-viewport-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background-color: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#snapshot-video,
#snapshot-result-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Mirror front camera / webcam */
#snapshot-video.mirrored {
  transform: scaleX(-1);
}

.camera-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.camera-footer {
  padding: 16px;
  background-color: #182229;
  border-top: 1px solid var(--border-light);
}

.camera-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* Shutter button style */
.shutter-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.shutter-btn:hover {
  transform: scale(1.06);
  border-color: var(--accent-green-bright);
}

.shutter-btn:active {
  transform: scale(0.95);
}

.shutter-inner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  display: block;
  transition: background 0.15s ease;
}

.shutter-btn:hover .shutter-inner {
  background: var(--accent-green-bright);
}

/* Flash animation on capture */
.flash-effect {
  animation: shutterFlash 0.3s ease-out;
}

@keyframes shutterFlash {
  0% { filter: brightness(3); }
  100% { filter: brightness(1); }
}

/* ==========================================================================
   Clear Chat Confirmation Modal
   ========================================================================== */
.confirm-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.confirm-card {
  background: var(--bg-panel);
  border-radius: 18px;
  padding: 30px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-light);
  animation: fadeIn 0.18s ease-out;
}

.confirm-icon-wrap {
  width: 66px;
  height: 66px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(234, 67, 53, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-card h3 {
  font-size: 19px;
  margin-bottom: 8px;
  font-weight: 600;
}

.confirm-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 18px;
}

.safe-backup-notice {
  background: rgba(0, 168, 132, 0.1);
  border: 1px solid rgba(0, 168, 132, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--accent-green-bright);
  text-align: left;
  margin-bottom: 22px;
  line-height: 1.35;
}

.confirm-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.confirm-actions button {
  flex: 1;
  padding: 12px;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 768px) {
  .chat-container {
    max-width: 100%;
    border-radius: 0;
  }
  .local-video-container {
    width: 90px;
    height: 130px;
    top: 14px;
    right: 14px;
  }
  .call-overlay-header {
    padding-top: 24px;
  }
  .call-avatar {
    width: 68px;
    height: 68px;
    font-size: 26px;
  }
  .camera-card {
    max-width: 100%;
    height: 100%;
    border-radius: 0;
    justify-content: space-between;
  }
  .camera-viewport-wrap {
    flex: 1;
    aspect-ratio: auto;
  }
}

