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

/* === BASE === */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #e5ddd5;
  color: #111;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   WHATSAPP CHAT LAYOUT
   ============================================ */
.wa-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: #e5ddd5;
  box-shadow: 0 0 40px rgba(0,0,0,0.2);
}

/* --- Header --- */
.wa-header-cols {
  display: flex;
  flex-direction: row;
  align-items: center;
  background: #fff;
  padding: 10px 16px;
  border-bottom: 1px solid #d8d8d8;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}
.wa-header-col-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 40%;
}
.wa-header-logo-large {
  height: 56px;
  max-width: 180px;
  object-fit: contain;
}
.wa-header-col-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 60%;
}
.wa-header-title-row {
  font-weight: 700;
  font-size: 18px;
  color: #075e54;
  margin-bottom: 3px;
}
.wa-header-link-row {
  font-size: 14px;
  display: flex;
  justify-content: flex-end;
}
.wa-header-restart-link {
  color: #128c7e;
  text-decoration: underline;
  font-weight: 600;
  cursor: pointer;
}
.wa-header-restart-link:hover {
  color: #075e54;
}
/* --- Background wallpaper --- */
.wa-bg {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23b2bfba' fill-opacity='0.18'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

/* --- Messages area --- */
.wa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  position: relative;
  scroll-behavior: smooth;
}
.wa-messages::-webkit-scrollbar { width: 4px; }
.wa-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

/* --- Date divider --- */
.wa-date-divider {
  text-align: center;
  margin: 12px 0;
  position: relative;
}
.wa-date-divider span {
  background: rgba(225,245,254,0.9);
  color: #4a4a4a;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* --- Message bubbles --- */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  margin-bottom: 4px;
  position: relative;
}
.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.msg .bubble {
  padding: 8px 12px 20px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  min-width: 80px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.13);
}
.user-type-selection {
  margin-bottom: 12px;
  margin-left: 10px;
  width: 75%;
  max-width: 75%;
}
.user-type-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  width: 100%;
  box-sizing: border-box;
}
.user-type-buttons button {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: 1px solid #c5dcd7;
  background: #f7fff8;
  color: #075e54;
  font-size: 15px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
}
.user-type-buttons button:hover {
  background: #e6f7f0;
}
.user-type-buttons button:active {
  background: #d0eee4;
}
.wa-header-col-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 60%;
  align-items: flex-end;
}
.wa-header-title-row {
  font-weight: 700;
  font-size: 18px;
  color: #075e54;
  margin-bottom: 3px;
  text-align: right;
  width: 100%;
}
.msg.user .bubble {
  background: #dcf8c6;
  border-top-right-radius: 2px;
  color: #111;
}
.msg.assistant .bubble {
  background: #ffffff;
  border-top-left-radius: 2px;
  color: #111;
}
/* Tail on user bubble */
.msg.user .bubble::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid #dcf8c6;
  border-left: 8px solid transparent;
}
/* Tail on assistant bubble */
.msg.assistant .bubble::after {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid #ffffff;
  border-right: 8px solid transparent;
}
.msg .meta {
  position: absolute;
  bottom: 4px;
  right: 10px;
  font-size: 10.5px;
  color: #7a7a7a;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.msg.user .meta { color: #5b9466; }
.msg .checkmarks { font-size: 11px; }

/* --- Typing indicator --- */
.typing-indicator .bubble {
  padding: 12px 14px 12px 14px;
}
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  background: #8d8d8d;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* --- Input area --- */
.wa-input-area {
  background: #f0f0f0;
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.wa-input-wrap {
  flex: 1;
  background: #fff;
  border-radius: 24px;
  display: flex;
  align-items: flex-end;
  padding: 6px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.wa-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: #111;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.5;
  padding: 0;
}
.wa-input-wrap textarea::placeholder { color: #999; }
.wa-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #075e54;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.wa-send-btn:hover { background: #128c7e; }
.wa-send-btn:active { background: #064940; }
.wa-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #075e54;
}

/* ============================================
   ADMIN PANEL STYLES
   ============================================ */
.admin-page {
  min-height: 100vh;
  background: #f0f2f5;
  overflow-y: auto;
}
.admin-container {
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.admin-titlebar {
  background: #fff;
  color: #075e54;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1.5px solid #e0e0e0;
}
.admin-titlebar h1 {
  font-size: 18px;
  font-weight: 600;
  color: #075e54;
}
.admin-titlebar a {
  color: #075e54;
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid #b2dfdb;
  border-radius: 12px;
  background: #f6fffc;
  transition: background 0.2s, color 0.2s;
}
.admin-titlebar a:hover {
  background: #e0f7fa;
  color: #128c7e;
}
.admin-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  padding: 20px;
  margin-bottom: 16px;
}
.admin-card h2 {
  font-size: 14px;
  font-weight: 600;
  color: #075e54;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8f5e9;
}
.form-group { margin-bottom: 16px; }
.label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
label {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}
.form-group select,
.form-group textarea,
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  color: #111;
  transition: border-color 0.2s;
}
.form-group select:focus,
.form-group textarea:focus,
.form-group input:focus {
  outline: none;
  border-color: #128c7e;
  background: #fff;
}
.form-group textarea { resize: vertical; }
.admin-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.btn-primary {
  background: #075e54;
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #128c7e; }
.btn-secondary {
  background: transparent;
  color: #075e54;
  border: 1.5px solid #075e54;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: #e8f5e9; }
.status-message {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: none;
}
.status-message.success { background: #e8f5e9; color: #1b5e20; display: block; }
.status-message.error { background: #ffebee; color: #b71c1c; display: block; }
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e0f2f1;
  color: #00796b;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
}
.tooltip {
  display: none;
  position: absolute;
  left: 24px;
  top: -4px;
  background: #333;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  padding: 6px 10px;
  border-radius: 6px;
  width: 220px;
  z-index: 100;
  line-height: 1.4;
  white-space: normal;
}
.info-icon:hover .tooltip { display: block; }

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-screen {
  min-height: 100vh;
  background: #075e54;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  text-align: center;
}
.login-card .logo {
  font-size: 48px;
  margin-bottom: 8px;
}
.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  color: #075e54;
  margin-bottom: 4px;
}
.login-card .subtitle {
  font-size: 13px;
  color: #777;
  margin-bottom: 24px;
}
.login-card .form-group { margin-bottom: 14px; text-align: left; }
.login-card label { font-size: 13px; font-weight: 600; color: #444; display: block; margin-bottom: 5px; }
.login-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fafafa;
  transition: border-color 0.2s;
}
.login-card input:focus { outline: none; border-color: #075e54; background: #fff; }
.login-card .btn-login {
  width: 100%;
  background: #075e54;
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}
.login-card .btn-login:hover { background: #128c7e; }
.login-status { font-size: 13px; margin-top: 12px; min-height: 20px; }
.login-status.error { color: #c0392b; }
.login-status.success { color: #27ae60; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 768px) {
  .wa-screen {
    max-width: 420px;
    height: 90vh;
    margin: 5vh auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 60px rgba(0,0,0,0.25);
  }
  body { background: #128c7e; overflow: auto; }
}
@media (max-width: 767px) {
  .wa-screen { border-radius: 0; }
}