@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+JP:wght@300;400;500;700&family=Outfit:wght@400;600;700&display=swap');

:root {
  --bg-dark: #070a13;
  --bg-gradient: radial-gradient(circle at 15% 20%, rgba(20, 35, 75, 0.45) 0%, rgba(7, 10, 19, 1) 70%),
                 radial-gradient(circle at 85% 85%, rgba(18, 45, 65, 0.35) 0%, rgba(7, 10, 19, 1) 70%);
  --glass-bg: rgba(18, 26, 46, 0.65);
  --glass-bg-hover: rgba(26, 38, 66, 0.8);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-gold: rgba(230, 194, 128, 0.35);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  
  --accent-gold: #e6c280;
  --accent-gold-gradient: linear-gradient(135deg, #f7d698 0%, #d4a656 100%);
  --accent-cyan: #00f2fe;
  --accent-teal: #4facfe;
  --accent-spartan: #ff4b4b;
  
  --text-main: #f0f4f8;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;
  
  --msg-user-bg: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  --msg-ai-bg: rgba(23, 32, 56, 0.75);
  
  --border-radius-sm: 10px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
}

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

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Background animated glow orbs */
.ambient-glow {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  animation: pulseGlow 12s infinite alternate ease-in-out;
}

.glow-1 {
  top: -100px;
  left: -100px;
  background: #3b82f6;
}

.glow-2 {
  bottom: -100px;
  right: -100px;
  background: #d97706;
  animation-delay: -6s;
}

@keyframes pulseGlow {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.3) translate(50px, 30px); }
}

/* App Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: rgba(11, 16, 30, 0.85);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 24px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  background: var(--accent-gold-gradient);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--text-dark);
  box-shadow: 0 0 20px rgba(230, 194, 128, 0.4);
}

.brand-info h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #e6c280);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Section Titles */
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Persona Selection Cards */
.persona-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.persona-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.persona-card:hover {
  background: var(--glass-bg-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.persona-card.active {
  background: rgba(230, 194, 128, 0.12);
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(230, 194, 128, 0.15);
}

.persona-card[data-persona="spartan"].active {
  background: rgba(255, 75, 75, 0.12);
  border-color: var(--accent-spartan);
  box-shadow: 0 0 20px rgba(255, 75, 75, 0.2);
}

.persona-icon {
  font-size: 24px;
  background: rgba(255, 255, 255, 0.05);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.persona-details h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}

.persona-details p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Quick Actions in Sidebar */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-btn:hover {
  background: rgba(230, 194, 128, 0.15);
  border-color: var(--accent-gold);
  transform: translateX(4px);
}

/* Sidebar Footer / API Status */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.api-status-btn {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}

.api-status-btn:hover {
  border-color: var(--accent-cyan);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.demo {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

/* Main Chat Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Header */
.top-header {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(7, 10, 19, 0.6);
  backdrop-filter: blur(16px);
}

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

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 24px;
  cursor: pointer;
}

.header-title h2 {
  font-size: 18px;
  font-weight: 600;
}

.header-title span {
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.action-icon-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-icon-btn:hover {
  background: var(--glass-bg-hover);
  border-color: rgba(255,255,255,0.25);
}

/* Chat Timeline */
.chat-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  display: flex;
  gap: 16px;
  max-width: 850px;
  animation: fadeIn 0.3s ease;
}

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

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

.msg-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.message.ai .msg-avatar {
  background: var(--accent-gold-gradient);
  color: var(--text-dark);
}

.message.ai[data-persona="spartan"] .msg-avatar {
  background: linear-gradient(135deg, #ff4b4b 0%, #b91c1c 100%);
  color: white;
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
}

.msg-bubble {
  padding: 18px 22px;
  border-radius: var(--border-radius-md);
  font-size: 15px;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.message.ai .msg-bubble {
  background: var(--msg-ai-bg);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 4px;
}

.message.user .msg-bubble {
  background: var(--msg-user-bg);
  border-top-right-radius: 4px;
  color: white;
}

/* Markdown Formats inside AI Bubble */
.msg-bubble h3, .msg-bubble h4 {
  margin: 12px 0 8px 0;
  color: var(--accent-gold);
}

.msg-bubble p {
  margin-bottom: 10px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul, .msg-bubble ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.msg-bubble li {
  margin-bottom: 6px;
}

.msg-bubble code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  color: #ff80bf;
}

.msg-bubble pre {
  background: #04070f;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.msg-bubble pre code {
  background: none;
  padding: 0;
  color: #a5b4fc;
}

/* Attached Image inside message */
.msg-image {
  max-width: 320px;
  max-height: 240px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  cursor: zoom-in;
  transition: transform 0.2s;
}

.msg-image:hover {
  transform: scale(1.02);
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-gold);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Section */
.chat-input-area {
  padding: 20px 32px 28px;
  background: rgba(7, 10, 19, 0.8);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
}

/* Image Preview Bar */
.image-preview-bar {
  display: none;
  padding: 10px 14px;
  background: rgba(20, 30, 55, 0.8);
  border: 1px solid var(--glass-border-gold);
  border-radius: 12px;
  margin-bottom: 12px;
  align-items: center;
  justify-content: space-between;
  animation: fadeIn 0.2s;
}

.preview-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--accent-gold);
}

.preview-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-gold);
}

.remove-img-btn {
  background: rgba(255, 75, 75, 0.2);
  border: 1px solid rgba(255, 75, 75, 0.4);
  color: #ff8080;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.remove-img-btn:hover {
  background: var(--accent-spartan);
  color: white;
}

/* Input Box Container */
.input-wrapper {
  background: var(--glass-bg);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(230, 194, 128, 0.2);
}

.attach-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--accent-gold);
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.attach-btn:hover {
  background: var(--accent-gold);
  color: var(--text-dark);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 15px;
  font-family: inherit;
  padding: 8px 4px;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: var(--accent-gold-gradient);
  border: none;
  color: var(--text-dark);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(230, 194, 128, 0.3);
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(230, 194, 128, 0.45);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

.modal-card {
  background: #0d1322;
  border: 1px solid var(--glass-border-gold);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--glass-shadow);
}

.modal-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--accent-gold);
}

.modal-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.api-input-group {
  margin-bottom: 24px;
}

.api-input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.api-input-group input {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 12px 14px;
  color: white;
  font-family: monospace;
  font-size: 14px;
  outline: none;
}

.api-input-group input:focus {
  border-color: var(--accent-gold);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent-gold-gradient);
  border: none;
  color: var(--text-dark);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
}

/* Security Gate Overlay */
.security-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 16, 0.88);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.security-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.security-card {
  background: linear-gradient(145deg, rgba(16, 24, 45, 0.9) 0%, rgba(9, 13, 26, 0.95) 100%);
  border: 1px solid rgba(230, 194, 128, 0.4);
  border-radius: var(--border-radius-lg);
  padding: 40px 36px;
  width: 90%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 40px rgba(230, 194, 128, 0.15);
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.security-badge {
  display: inline-block;
  background: rgba(230, 194, 128, 0.15);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.security-brand-logo {
  width: 64px;
  height: 64px;
  background: var(--accent-gold-gradient);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 32px;
  color: var(--text-dark);
  margin: 0 auto 16px;
  box-shadow: 0 0 30px rgba(230, 194, 128, 0.5);
}

.security-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.security-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.passcode-section {
  text-align: left;
  margin-bottom: 24px;
}

.passcode-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.passcode-input-wrapper {
  display: flex;
  gap: 8px;
}

#passcode-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--accent-gold);
  font-size: 20px;
  font-family: monospace;
  letter-spacing: 6px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

#passcode-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(230, 194, 128, 0.25);
}

.passcode-submit-btn {
  background: var(--accent-gold-gradient);
  border: none;
  color: var(--text-dark);
  font-weight: 700;
  padding: 0 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.passcode-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(230, 194, 128, 0.4);
}

.passcode-error {
  display: none;
  font-size: 12px;
  color: #ff4b4b;
  margin-top: 8px;
  font-weight: 500;
}

.biometric-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 11px;
}

.biometric-divider::before, .biometric-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.biometric-divider span {
  padding: 0 12px;
}

.biometric-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.4);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.25s;
  color: white;
  text-align: left;
}

.biometric-btn:hover {
  background: rgba(0, 242, 254, 0.12);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.25);
  transform: translateY(-2px);
}

.biometric-btn span {
  font-size: 28px;
}

.biometric-text strong {
  display: block;
  font-size: 14px;
  color: var(--accent-cyan);
  margin-bottom: 2px;
}

.biometric-text span {
  font-size: 11px;
  color: var(--text-muted);
}

.security-footer {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.lock-btn {
  border-color: rgba(230, 194, 128, 0.35);
  color: var(--accent-gold);
}

.lock-btn:hover {
  background: rgba(230, 194, 128, 0.15);
}

/* Responsive for iPad & Mobile */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .mobile-toggle {
    display: block;
  }
  
  .top-header {
    padding: 0 16px;
  }
  
  .chat-timeline {
    padding: 16px;
  }
  
  .chat-input-area {
    padding: 16px;
  }
}

