/* =========================
LAYOUT GERAL
========================= */
.app-page {
  display: flex;
  height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(0, 255, 136, 0.08), transparent 35%),
    linear-gradient(135deg, #020f0b, #03150f);
  color: var(--text-main);
}

.chat-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* =========================
SIDEBAR
========================= */
.sidebar {
  width: 290px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  background: rgba(6, 26, 18, 0.88);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  margin-bottom: 26px;
  transition: 0.3s ease;
}

.brand:hover {
  transform: scale(1.03);
}

.brand strong {
  color: var(--text-main);
  font-size: 1.7rem;
  font-weight: 800;
}

.brand span {
  color: var(--primary);
  font-size: 1.7rem;
  font-weight: 700;
}

.sidebar-label {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* =========================
AÇÕES DA SIDEBAR
========================= */
.new-chat-btn {
  width: 100%;
  height: 50px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #02130c;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.new-chat-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.new-chat-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.new-chat-btn .lucide {
  width: 18px;
  height: 18px;
  margin: 0;
  stroke: #02130c;
}

.side-action {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.side-action:hover {
  background: rgba(0, 255, 136, 0.06);
}

.logout-btn {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(248, 63, 109, 0.192);
  color: #ff2e62bd;
  cursor: pointer;
  transition: var(--transition);
}

.logout-btn:hover {
  background: rgba(255, 77, 122, 0.14);
}

/* =========================
LISTA DE CHATS
========================= */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-item-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.chat-item-row:hover {
  background: rgba(0, 255, 136, 0.06);
}

.chat-item-row.active {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.15);
}

.chat-item {
  min-width: 0;
  flex: 1;
  padding: 14px 8px 14px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.chat-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-row:hover .chat-item {
  color: var(--text-main);
}

.chat-item-row.active .chat-item {
  color: var(--primary);
}

.delete-chat-btn {
  width: 34px;
  height: 34px;
  margin-right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: rgba(255, 77, 122, 0.72);
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
}

.chat-item-row:hover .delete-chat-btn,
.chat-item-row.active .delete-chat-btn {
  opacity: 1;
}

.delete-chat-btn:hover {
  background: rgba(255, 77, 122, 0.14);
  color: #ff4d7a;
}

.delete-chat-btn .lucide {
  width: 16px;
  height: 16px;
  margin: 0;
  stroke: currentColor;
}

/* =========================
CARTÃO DO USUÁRIO
========================= */
.user-card {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 40px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #00ff88, #018f4c);
  border: 1px solid var(--border);
  color: #02130c;
  font-size: 14px;
  font-weight: 800;
}

.user-avatar .lucide {
  color: var(--primary);
}

.user-card strong {
  display: block;
  font-size: 14px;
}

.user-card span {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* =========================
HEADER SUPERIOR
========================= */
.top-header {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}

.mobile-menu-btn,
.mobile-sidebar-overlay {
  display: none;
}

.top-actions,
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-link,
.register-btn,
.profile-btn,
.logout-btn-header {
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.login-link {
  color: var(--primary);
  font-size: 15px;
}

.login-link:hover,
.register-btn:hover,
.profile-btn:hover {
  background: rgba(0, 255, 136, 0.08);
}

.logout-btn-header {
  color: #ff4d7a;
  border-color: rgba(255, 77, 122, 0.103);
}

/* =========================
ÁREA DE MENSAGENS
========================= */
.messages-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 40px 24px 160px;
}

.welcome-box {
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-icon {
  width: 90px;
  height: 90px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid var(--border);
}

.welcome-icon .lucide {
  width: 42px;
  height: 42px;
  margin: 0;
  stroke: var(--primary);
}

.logo {
  width: 70px;
  height: auto;
}

.welcome-box h2 {
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.842);
  font-size: 0.5rem;
}

.welcome-box p {
  max-width: 300px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* =========================
ESTADO VAZIO DO CHAT
========================= */
body.chat-empty-state .messages-area {
  padding-top: 132px;
  padding-bottom: 220px;
}

body.chat-empty-state .welcome-box {
  min-height: auto;
  margin-top: 38px;
}

body.chat-empty-state .welcome-box h2 {
  margin-bottom: 10px;
  font-size: 2.5rem;
}

body.chat-empty-state .welcome-box p {
  max-width: 640px;
}

/* =========================
MENSAGENS DO CHAT
========================= */
.chat-message {
  width: 100%;
  max-width: 900px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 5px 0;
}

.chat-message.user {
  align-items: flex-end;
}

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

.message-bubble {
  max-width: min(560px, 100%);
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chat-message.user .message-bubble {
  background: #111;
  border: 1px solid #1f3f33;
  color: #fff;
}

.chat-message.assistant .message-bubble {
  background: #00ff88;
  color: #001b10;
}

.message-content {
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
}

.chat-message.user .message-meta {
  justify-content: flex-end;
  color: rgba(255, 255, 255, 0.5);
}

.chat-message.assistant .message-meta {
  color: rgba(240, 255, 248, 0.48);
}

/* =========================
BOTÃO DE COPIAR
========================= */
.copy-message-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(240, 255, 248, 0.55);
  cursor: pointer;
  transition: var(--transition);
}

.copy-message-btn:hover,
.copy-message-btn.copied {
  background: rgba(240, 255, 248, 0.08);
  color: rgba(240, 255, 248, 0.9);
}

.copy-message-btn .lucide {
  width: 15px;
  height: 15px;
  margin: 0;
  stroke: rgba(240, 255, 248, 0.55);
  stroke-width: 2;
}

.copy-message-btn:hover .lucide,
.copy-message-btn.copied .lucide {
  stroke: rgba(240, 255, 248, 0.9);
}

.chat-message.user .copy-message-btn {
  color: rgba(255, 255, 255, 0.5);
}

.chat-message.user .copy-message-btn:hover,
.chat-message.user .copy-message-btn.copied {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.chat-message.user .copy-message-btn .lucide {
  stroke: rgba(255, 255, 255, 0.5);
}

.chat-message.user .copy-message-btn:hover .lucide,
.chat-message.user .copy-message-btn.copied .lucide {
  stroke: #ffffff;
}

/* =========================
INPUT DE MENSAGEM
========================= */
.message-form {
  position: fixed;
  left: 290px;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px;
  background: linear-gradient(to top, #020f0b 70%, transparent);
  transition:
    bottom 0.35s ease,
    transform 0.35s ease,
    background 0.35s ease,
    padding 0.35s ease;
}

.message-input-box {
  width: 100%;
  max-width: 900px;
  height: 60px;
  margin: 0 auto;
  padding: 0 8px 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(6, 26, 18, 0.95);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow:
    0 0 30px rgba(0, 255, 136, 0.08),
    0 10px 35px rgba(0, 0, 0, 0.45);
}

.message-input-box input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 15px;
}

.message-input-box input::placeholder {
  color: rgba(240, 255, 248, 0.45);
}

.message-input-box button {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  background: var(--primary);
  color: #02130c;
  cursor: pointer;
  transition: var(--transition);
}

.message-input-box button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.message-input-box button .lucide {
  width: 20px;
  height: 20px;
  margin: 0;
  stroke: #02130c;
}

.chat-warning {
  max-width: 900px;
  margin-top: 14px;
  color: rgba(240, 255, 248, 0.42);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.2px;
  text-align: center;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s ease;
}

body.chat-empty-state .message-form {
  bottom: 250px;
  padding-top: 0;
  padding-bottom: 0;
  background: transparent;
  transform: none;
}

body.chat-empty-state .message-input-box {
  height: 66px;
  border-radius: 22px;
}

body.chat-empty-state .chat-warning {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
}

/* =========================
MODAL DE AUTENTICAÇÃO
========================= */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-modal.hidden {
  display: none;
}

.auth-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.auth-modal .auth-wrapper {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-modal .auth-container {
  max-width: 470px;
  backdrop-filter: blur(6px);
}

/* =========================
MODAL DE LOGOUT
========================= */
.logout-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-modal.hidden {
  display: none;
}

.logout-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.logout-box {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  padding: 34px;
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  color: var(--text-main);
  text-align: center;
}

.logout-box h2 {
  margin-bottom: 18px;
  font-size: 1.5rem;
}

.logout-box p {
  margin-bottom: 28px;
  color: var(--text-muted);
  line-height: 1.6;
}

.confirm-logout-btn,
.cancel-logout-btn {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.confirm-logout-btn {
  margin-bottom: 8px;
  background: var(--primary);
  color: #02130c;
}

.cancel-logout-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

/* =========================
MODAL DE CONFIGURAÇÕES
========================= */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-modal.hidden {
  display: none;
}

.settings-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.settings-box {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 450px;
  padding: 30px;
  background: #081b14;
  border: 1px solid var(--border);
  border-radius: 18px;
}

.settings-box h2 {
  margin-bottom: 20px;
}

.settings-section {
  margin-bottom: 25px;
}

.settings-section h3 {
  margin-bottom: 10px;
}

.settings-muted {
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.settings-user {
  margin-top: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-user-info {
  display: flex;
  flex-direction: column;
}

.settings-user-info strong {
  color: var(--text-main);
  font-size: 16px;
}

.settings-user-info span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.setting-btn {
  width: 100%;
  margin-bottom: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: white;
  cursor: pointer;
}

.setting-btn:hover {
  border-color: var(--primary);
}

.setting-btn.danger {
  color: #ff4d7a;
  border-color: rgba(255, 77, 122, 0.3);
}

.setting-btn.active-language {
  background: rgba(0, 217, 119, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.close-settings-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #02130c;
  font-weight: 700;
  cursor: pointer;
}

#settingsAccountGuest {
  padding: 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
}

#settingsAccountGuest h3 {
  margin-bottom: 12px;
}

#settingsAccountGuest .setting-btn {
  margin-bottom: 10px;
}

#settingsLoginBtn {
  background: var(--primary);
  border: none;
  color: #02130c;
  font-weight: 700;
}

#settingsLoginBtn:hover {
  background: var(--primary-dark);
}

#settingsRegisterBtn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

#settingsRegisterBtn:hover {
  border-color: var(--primary);
}
