/* Greek Chat App - Mediterranean Theme */

:root {
  --greek-blue: #0D5EAF;
  --greek-blue-light: #1976D2;
  --greek-white: #FFFFFF;
  --olive: #8B7355;
  --olive-light: #A08060;
  --sand: #F5F1EB;
  --message-own: #E3F2FD;
  --message-other: #FFFFFF;
  --text-dark: #1A1A1A;
  --text-muted: #666666;
  --shadow: rgba(0, 0, 0, 0.1);
}

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

html, body {
  height: 100%;
  min-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--sand);
  color: var(--text-dark);
}

.hidden {
  display: none !important;
}

/* Welcome Screen */
.welcome-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--greek-blue) 0%, var(--greek-blue-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.welcome-card {
  background: var(--greek-white);
  border-radius: 20px;
  padding: 40px 30px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 340px;
  width: 100%;
}

.welcome-card h1 {
  font-size: 2rem;
  color: var(--greek-blue);
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

#welcome-form input,
#login-form input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid var(--sand);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s;
}

#welcome-form input:focus,
#login-form input:focus {
  border-color: var(--greek-blue);
}

#welcome-form button,
#login-form button {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--greek-blue);
  color: var(--greek-white);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

#welcome-form button:hover,
#login-form button:hover {
  background: var(--greek-blue-light);
}

/* Login message */
.login-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
}

.login-message.success {
  background: #E8F5E9;
  color: #2E7D32;
}

.login-message.error {
  background: #FFEBEE;
  color: #C62828;
}

/* Chat Container */
.chat-container {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--greek-white);
  box-shadow: 0 0 20px var(--shadow);
}

/* Header */
.chat-header {
  background: var(--greek-blue);
  color: var(--greek-white);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px var(--shadow);
}

.header-logo {
  width: 48px;
  height: 48px;
  cursor: pointer;
  transition: transform 0.2s;
}

.header-logo:hover {
  transform: scale(1.1);
}

.header-logo.spin {
  animation: spin 0.6s ease-in-out;
}

@keyframes spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

/* Confetti */
.confetti {
  position: fixed;
  pointer-events: none;
  font-size: var(--size, 2rem);
  z-index: 3000;
  animation: confetti-fall var(--duration, 3s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform:
      translateX(0)
      translateY(0)
      rotate(0deg)
      scale(0.3);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translateX(var(--drift, 0px))
      translateY(var(--fall, 100vh))
      rotate(var(--spin, 720deg))
      scale(var(--end-scale, 1.5));
  }
}

.header-text {
  font-size: 1.1rem;
  font-weight: 600;
}

.header-profile {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

.header-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-avatar-placeholder {
  font-size: 1.2rem;
}

/* Messages Area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sand);
}

/* Message Wrapper (with avatar) */
.message-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 85%;
}

.message-wrapper.own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-wrapper.other {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
}

.message-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--olive-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--greek-white);
  flex-shrink: 0;
  cursor: pointer;
}

.message-wrapper.own .message-avatar,
.message-wrapper.own .message-avatar-placeholder {
  display: none;
}

/* Message Bubble */
.message {
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: 0 1px 3px var(--shadow);
}

.message-wrapper.own .message {
  background: var(--message-own);
  border-bottom-right-radius: 4px;
}

.message-wrapper.other .message {
  background: var(--message-other);
  border-bottom-left-radius: 4px;
}

.message-author {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--greek-blue);
  margin-bottom: 4px;
  cursor: pointer;
}

.message-author:hover {
  text-decoration: underline;
}

.message-wrapper.own .message-author {
  display: none;
}

.message-text {
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
  cursor: pointer;
}

.message-translation {
  font-size: 0.85rem;
  font-style: italic;
  color: #1976D2;
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(144, 202, 249, 0.1);
  border-radius: 4px;
  cursor: pointer;
}

.message-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* New Messages Button */
.new-messages-btn {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--greek-blue);
  color: var(--greek-white);
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 100;
  transition: background 0.2s, transform 0.2s;
}

.new-messages-btn:hover {
  background: var(--greek-blue-light);
  transform: translateX(-50%) scale(1.05);
}

/* Message Form */
.message-form {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--greek-white);
  border-top: 1px solid var(--sand);
}

.message-form input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--sand);
  border-radius: 24px;
  outline: none;
  transition: border-color 0.2s;
}

.message-form input[type="text"]:focus {
  border-color: var(--greek-blue);
}

.message-form button[type="submit"] {
  width: 48px;
  height: 48px;
  background: var(--greek-blue);
  color: var(--greek-white);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-form button[type="submit"]:hover {
  background: var(--greek-blue-light);
}

.attach-btn {
  width: 48px;
  height: 48px;
  background: var(--sand);
  color: var(--greek-blue);
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attach-btn:hover {
  background: var(--olive-light);
  color: var(--greek-white);
}

/* Safe area for mobile */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .message-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* Scrollbar styling */
.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--olive-light);
  border-radius: 3px;
}

/* Avatar Upload */
.avatar-upload {
  margin-bottom: 20px;
}

.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px dashed var(--sand);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  background: var(--sand);
  transition: border-color 0.2s;
}

.avatar-preview:hover {
  border-color: var(--greek-blue);
}

.avatar-preview.has-image {
  border-style: solid;
  border-color: var(--greek-blue);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  font-size: 2rem;
}

.avatar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.avatar-preview.has-image .avatar-placeholder,
.avatar-preview.has-image .avatar-hint {
  display: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--greek-white);
  border-radius: 20px;
  padding: 40px 30px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--sand);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.modal-close:hover {
  background: var(--olive-light);
  color: var(--greek-white);
}

.modal-content h2 {
  text-align: center;
  color: var(--greek-blue);
  margin-bottom: 24px;
}

#edit-profile-form input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid var(--sand);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s;
}

#edit-profile-form input[type="text"]:focus {
  border-color: var(--greek-blue);
}

#edit-profile-form button[type="submit"] {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--greek-blue);
  color: var(--greek-white);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

#edit-profile-form button[type="submit"]:hover {
  background: var(--greek-blue-light);
}

/* User Profile View */
.user-profile-view {
  text-align: center;
  padding-top: 10px;
}

.user-profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 20px;
  background: var(--olive-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--greek-white);
  overflow: hidden;
  border: 4px solid var(--greek-blue);
}

.user-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-profile-view h2 {
  color: var(--greek-blue);
  margin: 0;
}

/* Image Messages */
.message-image {
  max-width: 100%;
  border-radius: 12px;
  display: block;
  cursor: pointer;
}

.message {
  min-width: 0;
  overflow: hidden;
}

/* Image Viewer Overlay */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.image-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--greek-white);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.3);
}
