*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #e0f2ff, #f1f5f9);
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
  color: #0f172a;
}

/* Layout */
.fullheight {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.app {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  width: 100%;
  max-width: 720px;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.app-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(120deg, #ffd500, #ffd500);
  color: white;

  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-circle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.app-header h1 {
  font-size: 20px;
  line-height: 1.1;
}

.app-header p {
  font-size: 12px;
  opacity: 0.9;
}

/* Chat area */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Messages */
.message-row {
  display: flex;
  margin-bottom: 4px;
  width: 100%;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  align-items: flex-start;
}

.message-bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.message-row.user .message-bubble {
  background: #0ea5e9;
  color: white;
  border-bottom-right-radius: 4px;
}

.message-row.assistant .message-bubble {
  background: #e2e8f0;
  color: #0f172a;
  border-bottom-left-radius: 4px;
}

.message-bubble.hidden {
  display: none;
}

.meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.message-row.assistant .meta {
  margin-left: 4px;
}

.message-row.user .meta {
  margin-right: 4px;
  text-align: right;
}

/* Avatar */
.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.avatar-circle .avatar-img {
  width: 30px;
  height: 30px;
  object-fit: cover;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 32px;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #64748b;
  opacity: 0.4;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* Input bar */
.input-bar {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(248, 250, 252, 0.96);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#user-input {
  flex: 1;
  border: 1px solid #cbd5f5;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  resize: none;
  max-height: 96px;
  outline: none;
  background: white;
}

#user-input:focus {
  border-color: #ffd500;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.35);
}

#send-button {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  background: #ffd500;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.05s ease, opacity 0.1s ease;
  white-space: nowrap;
}

#send-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#send-button:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

/* Language switcher */
.lang-switcher {
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.lang-button {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 6px 8px;
}

.lang-button span {
  color: #0f172a;
  font-weight: 500;
}

.lang-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  z-index: 1000;
}

.lang-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}

.lang-option:hover {
  background: rgba(0, 0, 0, 0.05);
}

.lang-flag {
  width: 18px;
  height: 18px;
  border-radius: 3px;
}

/* Assistant message actions under each assistant message */
.message-block {
  display: flex;
  flex-direction: column;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 0px;
  margin-left: 38px;
  margin-top: 0px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.message-block:hover .message-actions {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 600px) {
  .message-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.action-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.action-btn img {
  width: 18px;
  height: 18px;
}

.action-btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

/* RTL alignment support for Arabic */
html[dir="rtl"] .message-actions {
  margin-left: 0;
  margin-right: 58px;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .app {
    border-radius: 18px;
  }

  .chat-container {
    padding: 12px 12px;
  }

  .input-bar {
    padding: 8px 10px;
  }
}
