/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: #1a1a2e;
  background: #f0f2f5;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Login Screen */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
}

.login-icon {
  width: 100px;
  height: 100px;
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1a1a2e;
}

.login-card p {
  color: #666;
  margin-bottom: 32px;
  font-size: 14px;
}

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  min-height: 44px;
}

.btn-microsoft:hover {
  background: #f8f8f8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Chat Screen */
#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1a1a2e;
  color: #fff;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 28px;
  height: 28px;
}

#header h1 {
  font-size: 18px;
  font-weight: 600;
}

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

#user-name {
  font-size: 14px;
  opacity: 0.8;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  max-width: 80%;
}

.message-user {
  align-self: flex-end;
}

.message-agent {
  align-self: flex-start;
  gap: 8px;
}

.agent-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-content {
  padding: 10px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-user .message-content {
  background: #0078d4;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-agent .message-content {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message-system {
  align-self: center;
  max-width: 90%;
  font-size: 13px;
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 4px 12px;
}

.message-error {
  color: #d32f2f;
}

/* Typing Indicator */
.typing-indicator .message-content {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 20px;
}

.dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
.dot:nth-child(3) { animation-delay: 0s; }

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Attachment Preview */
#attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: #e8f0fe;
  border-top: 1px solid #d0d9e8;
  font-size: 13px;
  color: #333;
  flex-shrink: 0;
}

#attachment-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#remove-attachment {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 2px 6px;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remove-attachment:hover {
  color: #d32f2f;
}

/* Input Area */
#input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: #f0f2f5;
  color: #0078d4;
}

#message-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-height: 44px;
}

#message-input:focus {
  border-color: #0078d4;
}

#message-input::placeholder {
  color: #aaa;
}

.btn-send {
  background: #0078d4;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
}

.btn-send:hover {
  background: #006abc;
}

.btn-send:active {
  background: #005a9e;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .message {
    max-width: 90%;
  }

  #header h1 {
    font-size: 16px;
  }

  #input-area {
    padding: 8px 12px;
  }

  .btn-send {
    padding: 10px 16px;
    font-size: 14px;
  }

  .login-card {
    padding: 32px 24px;
  }
}
