@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ═══════════════════════════════════════════════════════════════
   CSS VARIABLES
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg-primary: #18181a;
  --bg-secondary: #101011;
  --bg-card: #2b2f36;
  --bg-chat-user: #3a3f47;
  --bg-input: #323236;

  --accent-primary: #3c5dff;
  --accent-hover: #5a7aff;
  --danger: #cc0000;

  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #c5c5c5;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.05);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 34px rgba(3, 5, 7, 0.6);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.8);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL RESET
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
}

body {
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */
.header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(6px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 {
  font-size: 20px;
  margin: 0;
}

.header-right {
  display: flex;
  gap: 10px;
}

.header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  border: 2px solid var(--border-subtle);
}

.list-btn {
  border: 0;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.list-btn:hover {
  background: var(--accent-hover);
}

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */
.list-modal,
.avatar-modal,
.anime-detail-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 10, 0.85);
  z-index: 60;
  backdrop-filter: blur(4px);
}

.list-modal.open,
.avatar-modal.open,
.anime-detail-modal.open {
  display: flex;
}

/* List Modal */
.list-content {
  position: relative;
  width: 750px;
  max-height: 72vh;
  overflow: auto;
  background: var(--bg-card);
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

.list-content ul.copyable-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.list-content ul.copyable-list li {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #cccccc;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.2s;
}

.list-content ul.copyable-list li:hover {
  background: rgba(255, 255, 255, 0.08);
}

.list-content ul.copyable-list .list-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.copy-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

.copy-btn:active {
  transform: scale(0.95);
}

.copy-btn.copied {
  border-color: #22c55e;
  color: #22c55e;
}

.list-content h2 {
  margin: 0 0 10px 0;
  color: var(--text-primary);
}

.list-content .close {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 32px;
  cursor: pointer;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

/* Avatar Modal */
.avatar-modal img {
  max-width: min(380px, 90vw);
  max-height: 70vh;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-xl);
}

.avatar-modal .close-btn {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Anime Detail Modal */
.anime-detail-content {
  background: #1a1d23;
  border-radius: var(--radius-xl);
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-xl);
}

.anime-detail-close {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 32px;
  cursor: pointer;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.6);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  z-index: 61;
  backdrop-filter: blur(10px);
}

.anime-detail-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.anime-detail-body {
  padding: 28px;
}

.anime-detail-header {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.anime-detail-image {
  width: 215px;
  height: 300px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.anime-detail-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.anime-detail-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.anime-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}

.meta-item:last-child {
  border-bottom: none;
}

.meta-label {
  font-weight: 600;
  color: var(--accent-primary);
  min-width: 90px;
  font-size: 14px;
  flex-shrink: 0;
}

.meta-value {
  color: #e0e0e0;
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
  word-wrap: break-word;
  word-break: break-word;
}

.anime-detail-synopsis {
  margin-top: 8px;
  margin-bottom: 24px;
}

.anime-detail-synopsis h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(60, 93, 255, 0.3);
}

.anime-detail-synopsis p {
  color: var(--text-muted);
  line-height: 1.8;
  font-size: 15px;
  margin: 0;
  text-align: justify;
}

.mal-button {
  display: inline-block;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(60, 93, 255, 0.3);
}

.mal-button:hover {
  background: linear-gradient(135deg, #2a4de6 0%, #4868ff 100%);
  box-shadow: 0 6px 20px rgba(60, 93, 255, 0.5);
}

/* ═══════════════════════════════════════════════════════════════
   CHAT AREA
   ═══════════════════════════════════════════════════════════════ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.messages {
  padding: 20px 20px 160px 20px;
  flex: 1;
  min-height: min-content;
}

.chat-helper {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 640px;
  width: 90%;
  text-align: center;
  color: var(--text-primary);
  padding: 20px;
  pointer-events: none;
  z-index: 1;
}

/* Chat Messages */
.chat-message {
  max-width: 70%;
  padding: 12px 14px;
  border-radius: var(--radius-xl);
  word-wrap: break-word;
  display: inline-block;
  clear: both;
  font-size: 16px;
  line-height: 1.7;
  margin: 12px 0;
}

.chat-message.user {
  background: var(--bg-chat-user);
  color: var(--text-primary);
  float: right;
  margin-right: 70px;
  border-bottom-right-radius: 6px;
}

.chat-message.bot {
  background: var(--bg-primary);
  color: var(--text-primary);
  float: left;
  white-space: normal;
  line-height: 1.7;
  margin-left: 70px;
}

/* Anime Card */
.anime-card {
  white-space: normal;
  border-top: 1.5px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  margin: 16px 0;
}

.anime-card:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 8px;
}

.anime-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.anime-info-row {
  margin-left: 16px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.info-label {
  color: var(--accent-primary);
  font-weight: 600;
  white-space: nowrap;
}

.info-value {
  color: var(--text-secondary);
  word-wrap: break-word;
  word-break: break-word;
}

.info-separator {
  color: rgba(255, 255, 255, 0.3);
  margin: 0 6px;
}

.detail-btn {
  margin-left: 16px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.detail-btn:hover {
  background: var(--accent-hover);
}

/* Suggested Prompts Bar */
.suggested-prompts-bar {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: min(calc(100% - 40px), 850px);
  max-width: 900px;
  padding: 0 20px;
  opacity: 1;
  pointer-events: auto;
  z-index: 30;
}

.suggested-prompts-bar.hidden {
  display: none;
}

.prompt-chip {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  background: rgba(58, 63, 71, 0.8);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}

.prompt-chip:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Input Bar */
.input-bar {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--bg-input);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(calc(100% - 40px), 850px);
  max-width: 700px;
  z-index: 40;
}

.input-bar input[type=text] {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  font-size: 15px;
  padding: 10px;
}

.input-bar button {
  border: none;
  background: var(--accent-primary);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.input-bar button:hover {
  background: var(--accent-hover);
}

.input-bar button#clear-btn {
  background: var(--danger);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.input-bar button#clear-btn:hover {
  background: #e60000;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE - MOBILE (with minimal fix)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .chat-message,
  .chat-message.bot {
    max-width: 100%;
    font-size: 15px;
  }

  .chat-message.user {
    margin-right: 0.5px;
  }

  .chat-message.bot {
    margin-left: 0.5px;
  }

  .messages {
    padding: 16px 12px 180px;
  }

  .input-bar,
  .suggested-prompts-bar {
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: none;
  }

  /* MINIMAL MOBILE FIX - Prevent keyboard overlap */
  .input-bar {
    position: fixed;
    bottom: 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 12px);
  }

  .suggested-prompts-bar {
    bottom: 90px;
    gap: 8px;
    padding: 0 10px;
  }

  .prompt-chip {
    font-size: 12px;
    padding: 8px 14px;
  }

  .anime-detail-content {
    width: 95%;
    max-height: 90vh;
  }

  .anime-detail-body {
    padding: 20px;
  }

  .anime-detail-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .anime-detail-image {
    width: 180px;
    height: 252px;
  }

  .anime-detail-title {
    font-size: 22px;
  }

  .meta-label {
    min-width: 75px;
    font-size: 13px;
  }

  .meta-value {
    font-size: 13px;
  }

  .header {
    padding: 0 16px;
  }

  .header h1 {
    font-size: 18px;
  }

  .header-avatar {
    width: 38px;
    height: 38px;
  }

  .list-btn {
    font-size: 13px;
    padding: 8px 12px;
  }

  .chat-helper {
    padding: 16px;
    width: 88%;
  }

  .chat-helper h2 {
    font-size: 22px;
  }

  .chat-helper p {
    font-size: 15px;
  }

  .anime-card {
    margin: 14px 0;
  }

  .anime-title {
    font-size: 15px;
  }

  .anime-info-row {
    font-size: 13px;
    line-height: 1.6;
    margin-left: 12px;
  }

  .info-separator {
    margin: 0 4px;
  }

  .detail-btn {
    margin-left: 12px;
    padding: 6px 12px;
    font-size: 12px;
  }

  .list-content {
    width: 90%;
    max-height: 80vh;
  }

  .list-content ul.copyable-list {
    grid-template-columns: 1fr;
  }

  .input-bar button {
    width: 40px;
    height: 40px;
  }

  .input-bar input[type=text] {
    font-size: 14px;
  }
}