/* ===== RINEXA AI - STYLE.CSS ===== */
:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --accent: #7c5cfc;
  --accent2: #a78bfa;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --border: rgba(124,92,252,0.2);
  --user-bg: linear-gradient(135deg, #7c5cfc, #a78bfa);
  --ai-bg: #1a1a24;
  --radius: 18px;
  --shadow: 0 4px 24px rgba(124,92,252,0.15);
}
[data-theme="light"] {
  --bg: #f0f0f8;
  --bg2: #e8e8f0;
  --bg3: #ffffff;
  --text: #1a1a2e;
  --text2: #4a4a6a;
  --ai-bg: #ffffff;
  --border: rgba(124,92,252,0.3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: -280px; top: 0; bottom: 0;
  width: 280px; background: var(--bg2);
  border-right: 1px solid var(--border);
  transition: left 0.3s ease; z-index: 1000;
  display: flex; flex-direction: column; padding: 16px;
}
.sidebar.open { left: 0; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 999;
}
.sidebar-overlay.show { display: block; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.sidebar-logo-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--user-bg); display: flex; align-items: center;
  justify-content: center; font-weight: 900; color: white; font-size: 18px;
}
.sidebar-close {
  background: none; border: none; color: var(--text2);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.sidebar-close:hover { background: var(--bg3); }
.sidebar-menu { display: flex; flex-direction: column; gap: 4px; }
.sidebar-btn {
  background: none; border: none; color: var(--text);
  padding: 12px 16px; border-radius: 12px; cursor: pointer;
  text-align: left; font-size: 15px; display: flex; align-items: center;
  gap: 12px; transition: background 0.2s;
}
.sidebar-btn:hover, .sidebar-btn.active { background: var(--bg3); color: var(--accent2); }
.sidebar-icon { font-size: 16px; }
.sidebar-panel { display: none; margin-top: 16px; flex: 1; overflow-y: auto; }
.sidebar-panel.show { display: block; }
.sidebar-panel h3 { font-size: 14px; color: var(--text2); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; }
.settings-item { margin-bottom: 16px; }
.settings-item label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.settings-item select {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 14px;
}
.settings-btn {
  width: 100%; padding: 10px; border-radius: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 14px;
}
.settings-btn:hover { background: var(--accent); color: white; }
.settings-btn.danger { border-color: rgba(239,68,68,0.4); color: #f87171; }
.settings-btn.danger:hover { background: #ef4444; color: white; }
.history-item {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font-size: 13px; color: var(--text2); border: 1px solid transparent;
  margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item:hover { background: var(--bg3); border-color: var(--border); color: var(--text); }
.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.media-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; }

/* ===== MAIN APP ===== */
.app {
  height: 100vh; display: flex; flex-direction: column;
  background: var(--bg);
}

/* ===== HEADER ===== */
.header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 100;
}
.menu-btn, .new-chat-icon {
  background: none; border: none; color: var(--text2);
  font-size: 20px; cursor: pointer; padding: 6px 8px;
  border-radius: 10px; transition: all 0.2s;
}
.menu-btn:hover, .new-chat-icon:hover { background: var(--bg3); color: var(--accent2); }
.header-title { flex: 1; display: flex; align-items: center; gap: 10px; }
.header-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--user-bg); display: flex; align-items: center;
  justify-content: center; font-weight: 900; color: white; font-size: 18px;
}
.header-name { font-weight: 700; font-size: 16px; }
.header-status { font-size: 12px; color: #22c55e; }

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== WELCOME ===== */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 40px 20px;
  flex: 1;
}
.welcome-logo {
  width: 80px; height: 80px; border-radius: 24px;
  background: var(--user-bg); display: flex; align-items: center;
  justify-content: center; font-weight: 900; color: white;
  font-size: 40px; margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(124,92,252,0.3);
}
.welcome-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.welcome-sub { color: var(--text2); font-size: 15px; margin-bottom: 32px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 480px; }
.quick-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: 20px;
  cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.quick-btn:hover { background: var(--accent); border-color: var(--accent); color: white; }

/* ===== MESSAGES ===== */
.messages { display: flex; flex-direction: column; gap: 12px; }
.message { display: flex; gap: 10px; max-width: 85%; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message.user { flex-direction: row-reverse; align-self: flex-end; }
.message.ai { align-self: flex-start; }
.message-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--user-bg); display: flex; align-items: center;
  justify-content: center; font-weight: 900; font-size: 14px; color: white;
}
.message.ai .message-avatar { background: var(--bg3); border: 1px solid var(--border); color: var(--accent2); }
.message-bubble {
  padding: 12px 16px; border-radius: var(--radius); line-height: 1.6;
  font-size: 15px; position: relative;
}
.message.user .message-bubble {
  background: var(--user-bg); color: white;
  border-bottom-right-radius: 6px;
}
.message.ai .message-bubble {
  background: var(--ai-bg); color: var(--text);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
}
.message-bubble img { max-width: 100%; border-radius: 12px; margin-top: 8px; cursor: pointer; }
.message-time { font-size: 11px; color: var(--text2); margin-top: 4px; text-align: right; }
.message.user .message-time { text-align: right; }
.message.ai .message-time { text-align: left; }

/* ===== TYPING ===== */
.typing-indicator {
  display: flex; gap: 6px; padding: 14px 16px;
  background: var(--ai-bg); border: 1px solid var(--border);
  border-radius: var(--radius); border-bottom-left-radius: 6px;
  width: fit-content; align-self: flex-start; margin-top: 4px;
}
.typing-dot {
  width: 8px; height: 8px; background: var(--accent2);
  border-radius: 50%; animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== IMAGE PREVIEW ===== */
.image-preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: var(--bg3);
  border-top: 1px solid var(--border);
}
.image-preview-bar img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.image-preview-bar span { flex: 1; font-size: 13px; color: var(--text2); }
.image-preview-bar button {
  background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: 16px; padding: 4px 8px;
}

/* ===== INPUT AREA ===== */
.input-area {
  padding: 12px 16px 16px; background: var(--bg2);
  border-top: 1px solid var(--border);
}
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.attach-btn, .mic-btn, .send-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  cursor: pointer; font-size: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.attach-btn { background: var(--bg3); color: var(--text2); }
.attach-btn:hover { background: var(--accent); color: white; }
.mic-btn { background: var(--bg3); color: var(--text2); }
.mic-btn.recording { background: #ef4444; color: white; animation: pulse 1s infinite; }
.mic-btn:hover { background: var(--accent); color: white; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.send-btn { background: var(--user-bg); color: white; }
.send-btn:hover { opacity: 0.85; transform: scale(1.05); }
.input-box {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; color: var(--text);
  font-size: 15px; resize: none; outline: none; font-family: inherit;
  max-height: 120px; line-height: 1.5; transition: border-color 0.2s;
}
.input-box:focus { border-color: var(--accent); }
.input-box::placeholder { color: var(--text2); }
.mic-status {
  font-size: 12px; color: #ef4444; text-align: center;
  margin-top: 6px; min-height: 16px;
}

/* ===== MODAL ===== */
.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-content {
  background: var(--bg2); border-radius: 20px;
  width: 100%; max-width: 480px; max-height: 80vh;
  overflow: hidden; border: 1px solid var(--border);
}
.image-modal-content { max-width: 90vw; background: transparent; border: none; position: relative; }
.image-modal-content img { max-width: 100%; max-height: 80vh; border-radius: 12px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text2);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; position: absolute; top: 12px; right: 12px;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; max-height: calc(80vh - 60px); }
.memory-item { padding: 10px 14px; background: var(--bg3); border-radius: 10px; margin-bottom: 8px; }
.memory-item .key { font-size: 12px; color: var(--accent2); margin-bottom: 4px; text-transform: uppercase; }
.memory-item .value { font-size: 15px; color: var(--text); }

/* ===== CODE BLOCKS ===== */
.message-bubble pre {
  background: #0d0d1a; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; overflow-x: auto;
  margin-top: 8px; font-size: 13px;
}
.message-bubble code { color: #a78bfa; font-family: 'Courier New', monospace; }
.message-bubble a { color: var(--accent2); text-decoration: underline; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .message { max-width: 92%; }
  .welcome-title { font-size: 22px; }
  .quick-actions { gap: 8px; }
  .quick-btn { font-size: 12px; padding: 8px 12px; }
}
