/* C:\xampp\htdocs\paul-ai\style.css */

:root {
  /* Light Theme */
  --bg-color: #f0f4f8;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.5);
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --user-msg-bg: #dbeafe;
  --user-msg-text: #1e3a8a;
  --ai-msg-bg: #ffffff;
  --code-bg: #f1f5f9;
  --danger-color: #ef4444;
  --sidebar-bg: rgba(255, 255, 255, 0.95);
  --session-hover: rgba(59, 130, 246, 0.08);
  --session-active: rgba(59, 130, 246, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --user-msg-bg: #1e3a8a;
    --user-msg-text: #bfdbfe;
    --ai-msg-bg: #1e293b;
    --code-bg: #0f172a;
    --sidebar-bg: rgba(15, 23, 42, 0.98);
    --session-hover: rgba(96, 165, 250, 0.1);
    --session-active: rgba(96, 165, 250, 0.2);
  }
}

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

html,
body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow: hidden;
}

/* ─── App Container ─────────────────────────────── */
#app-container {
  width: 100%;
  max-width: 860px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (min-width: 768px) {
  #app-container {
    height: 95dvh;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  }
}

@media (prefers-color-scheme: dark) {
  @media (min-width: 768px) {
    #app-container {
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    }
  }
}

/* ─── Utilities ──────────────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

.hidden {
  display: none !important;
}

h1, h2, h3 { font-weight: 600; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Verification Overlay ───────────────────────── */
#verification-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  text-align: center;
  padding: 2rem;
  border-radius: inherit;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 72px;
  height: 72px;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.small-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.error-text {
  color: var(--danger-color);
  font-size: 0.875rem;
  min-height: 1.2rem;
}

/* ─── Chat Interface Layout ──────────────────────── */
#chat-interface {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
}

/* Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.25rem;
  z-index: 10;
  flex-shrink: 0;
  border-bottom: 1px solid var(--glass-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Messages scroll area — FIXED: id selector, flex:1 so footer stays pinned */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Footer — flex-shrink:0 keeps it always at the bottom */
.chat-footer {
  padding: 1rem 1.25rem;
  z-index: 10;
  flex-shrink: 0;
  border-top: 1px solid var(--glass-border);
}

/* ─── Message Bubbles ────────────────────────────── */
.message {
  display: flex;
  max-width: 82%;
  animation: fadeSlideIn 0.25s ease forwards;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.message.ai-message,
.message.system-message {
  align-self: flex-start;
}

.message-content {
  padding: 0.875rem 1.1rem;
  border-radius: 18px;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  position: relative;
}

.user-message .message-content {
  background-color: var(--user-msg-bg);
  color: var(--user-msg-text);
  border-bottom-right-radius: 4px;
}

.ai-message .message-content {
  background-color: var(--ai-msg-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.system-message .message-content {
  background-color: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  margin: 0 auto;
  max-width: 420px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* ─── Markdown inside messages ───────────────────── */
.message-content p        { margin-bottom: 0.65rem; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre {
  background-color: var(--code-bg);
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-size: 0.875em;
}
.message-content code {
  font-family: "Courier New", Courier, monospace;
  background-color: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.875em;
}
.message-content pre code { padding: 0; background: transparent; }
.message-content ul,
.message-content ol  { margin-left: 1.5rem; margin-bottom: 0.65rem; }
.message-content blockquote {
  border-left: 3px solid var(--primary-color);
  padding-left: 0.9rem;
  color: var(--text-secondary);
  margin: 0.65rem 0;
}

/* ─── Reasoning Block ────────────────────────────── */
.reasoning-block {
  margin: 0.75rem 0;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.reasoning-block summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.875em;
  color: var(--text-secondary);
  user-select: none;
  transition: background-color 0.2s;
}
.reasoning-block summary:hover { background-color: rgba(0,0,0,0.05); }

.reasoning-content {
  padding: 0.875rem 1rem;
  font-size: 0.875em;
  color: var(--text-secondary);
  border-top: 1px solid var(--glass-border);
  max-height: 350px;
  overflow-y: auto;
  background-color: var(--glass-bg);
}
.reasoning-content > *:first-child { margin-top: 0; }
.reasoning-content > *:last-child  { margin-bottom: 0; }

/* ─── Input Form ─────────────────────────────────── */
#chat-form { display: flex; flex-direction: column; }

.input-wrapper {
  display: flex;
  align-items: flex-end;
  background-color: var(--ai-msg-bg);
  border: 1.5px solid var(--glass-border);
  border-radius: 24px;
  padding: 0.4rem 0.4rem 0.4rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#chat-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 0.5rem 0.75rem 0.5rem 0;
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  max-height: 150px;
  outline: none;
  line-height: 1.45;
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
}

.icon-btn:hover { background-color: var(--session-hover); }

.btn.primary {
  background-color: var(--primary-color);
  color: white;
}
.btn.primary:hover {
  background-color: var(--primary-hover);
  transform: scale(1.05);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.6rem;
}

/* ─── Sidebar ────────────────────────────────────── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
#sidebar-backdrop.open { display: block; }

#chat-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  z-index: 50;
  background: var(--sidebar-bg) !important;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--glass-border);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#chat-sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sidebar-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: calc(100% - 1.5rem);
  margin: 0.75rem 0.75rem 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  border: 1.5px solid var(--primary-color);
  background: transparent;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.new-chat-btn:hover {
  background: var(--session-active);
}

#session-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0.25rem 0.5rem 1rem;
}

.session-item {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  text-align: left;
  position: relative;
}
.session-item:hover { background: var(--session-hover); }
.session-item.active { background: var(--session-active); }

.session-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 1.5rem;
}

.session-date {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.session-delete-btn {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 1rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.session-item:hover .session-delete-btn { opacity: 1; }
.session-delete-btn:hover { color: var(--danger-color); background: rgba(239,68,68,0.1); }

.sessions-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ─── Typing indicator ───────────────────────────── */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 6px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Policy pages ───────────────────────────────── */
.policy-container {
  background: var(--ai-msg-bg);
  padding: 3rem;
  border-radius: 20px;
  max-width: 800px;
  width: 90%;
  margin: 2rem auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  max-height: 90vh;
  overflow-y: auto;
}
.policy-container h1    { margin-bottom: 0.5rem; }
.policy-container h2    { margin-top: 2rem; margin-bottom: 1rem; }
.policy-container p     { margin-bottom: 1rem; line-height: 1.6; }
.policy-container .btn  {
  background-color: var(--primary-color);
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  margin-top: 1rem;
}
.policy-container .btn:hover { background-color: var(--primary-hover); }

