/* ================================
   SF Pro Display Regular font
   ================================ */
@font-face {
  font-family: 'SF Pro Display';
  src: url('SFPRODISPLAYREGULAR.OTF') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Update root font */
html, body, #chat {
  font-family: 'SF Pro Display', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}



/* ================================
   Root variables
   ================================ */
:root {
  /* Common */
  --radius: 20px;
  --transition: 0.3s ease;
}

/* Dark Theme (default) */
:root[data-theme="dark"] {
  --bg: #1b1d23;
  --panel: #27292f;
  --card: #202328;
  --muted: #9aa4b2;
  --text: #e6eef8;
  --accent: #7c5cff;
  --accent-2: #06b6d4;
  --glass: rgba(255,255,255,0.05);
  --shadow: 0 8px 30px rgba(0,0,0,0.5);
  --input-bg: #2a2c33;
  --border: rgba(255,255,255,0.1);
}

/* Light Theme */
:root[data-theme="light"] {
  --bg: #dddddd;
  --panel: #ffffff;
  --card: #f7f8fa;
  --muted: #6b7280;
  --text: #111827;  
  --accent: #7c5cff;
  --accent-2: #06b6d4;
  --glass: #dddddd;
  --shadow: 0 8px 30px rgba(0,0,0,0.096);
  --input-bg: #f7f8fa;
  --border: rgba(0,0,0,0.247);
  --glasshover: #c9c9c9 ;
}

/* Chat bubbles light mode */
:root[data-theme="light"] .bubble.bot { background: #f7f8fa; color: #111827; }
:root[data-theme="light"] .bubble.user { background: #e0e0e0; color: #111827; }

/* ================================
   Global Reset
   ================================ */
* { box-sizing: border-box; margin:0; padding:0; }
html, body, #chat { height: 100%; width: 100%; font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
body { background: var(--bg); color: var(--text); transition: background var(--transition), color var(--transition); }

/* ================================
   Layout
   ================================ */
.app { display: flex; height: 100vh; gap: 20px; padding: 28px; transition: all var(--transition); }
.sidebar { width: 300px; background: var(--panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; transition: background var(--transition); }
.main { flex: 1; display: flex; flex-direction: column; gap: 12px; }

/* ================================
   Branding
   ================================ */
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; }
.brand h1 { margin: 0; font-size: 18px; }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ================================
   Presets
   ================================ */
.preset-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-right: 6px; }
.preset-item { background: var(--glass); padding: 10px; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; backdrop-filter: blur(8px); transition: background var(--transition); }
.preset-item:hover { background: var(--glasshover); }
.preset-controls { margin-top: auto; }

/* ================================
   Buttons
   ================================ */
.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn.mini { padding: 6px 8px; font-size: 13px; }
.btn.ghost { background: transparent; border: 1px dashed var(--border); }
.icon-btn { background: transparent; border: 1px solid var(--border); padding: 8px; border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.icon-btn:hover { background: var(--glass); }

/* ================================
   Chat
   ================================ */
.chat { flex: 1; overflow-y: auto; padding: 18px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; transition: background var(--transition); }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row.user { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 7px 18px;
  border-radius: var(--radius);
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
  background: var(--panel);
  transition: background var(--transition), color var(--transition);
}
.bubble.bot { background: var(--card); }
.bubble.user { background: linear-gradient(180deg, rgba(255,255,255,0.05)); color: var(--text); }

/* ================================
   Composer — ChatGPT-style Input Bar
   ================================ */
.composer {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;

  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

/* ================================
   Composer textarea — auto-grow + scroll
   ================================ */
.composer-input {
  position: relative; /* make send button position relative to this */
  width: 100%;
}

.composer-input textarea {
  width: 100%;
  min-height: 56px;       /* starting height */
  max-height: 150px;      /* max height before scroll */
  padding: 16px 60px 16px 20px; /* space for send button */
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  resize: none;           /* remove drag handle */
  overflow-y: auto;       /* scrollbar appears after max height */
  box-sizing: border-box;
  transition: border 0.25s ease, background 0.25s ease;
}

/* Focus effect */
.composer-input textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  outline: none;
}



/* Custom modern gray scrollbar */
.composer-input textarea::-webkit-scrollbar {
  width: 6px;
}
.composer-input textarea::-webkit-scrollbar-thumb {
  background-color: rgba(128,128,128,0.5);
  border-radius: 3px;
}
.composer-input textarea::-webkit-scrollbar-track {
  background: transparent;
}


/* Focus effect */
.composer-input textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  outline: none;
}

/* ================================
   Send button inside textarea
   ================================ */
.send-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.send-btn:hover {
  opacity: 0.85;
}
.send-btn::before {
  content: "➤";
  color: white;
  font-size: 18px;
  margin-left: 2px;
}

/* Optional: modern gray scrollbar */
.composer-input textarea::-webkit-scrollbar {
  width: 6px;
}

.composer-input textarea::-webkit-scrollbar-thumb {
  background-color: rgba(128,128,128,0.5);
  border-radius: 3px;
}
.composer-input textarea::-webkit-scrollbar-track {
  background: transparent;
}

/* Tools row */
.composer-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  opacity: 0.9;
}

/* Dropdown */
.select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
}

/* ================================
   Markdown & code
   ================================ */
.markdown { font-size: 15px; color: var(--text); }
.markdown h1, .markdown h2, .markdown h3 { color: var(--text); }
.markdown pre {
  background: var(--panel);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.copy-btn {
  position: absolute;
  right: 8px; top: 8px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 12px;
}

/* ================================
   Typing animation
   ================================ */
.typing-dots { display:inline-block; }
.typing-dots span { display:inline-block; animation:typing 1s infinite; }
.typing-dots span:nth-child(2){ animation-delay:0.15s; }
.typing-dots span:nth-child(3){ animation-delay:0.3s; }
@keyframes typing { 0%{opacity:0.2;transform:translateY(0)}50%{opacity:1;transform:translateY(-6px)}100%{opacity:0.2;transform:translateY(0)} }

/* ================================
   Responsive
   ================================ */
@media (max-width: 900px){
  .app { flex-direction: column; padding: 12px; }
  .sidebar { width: 100%; order: 2; }
  .main { order: 1; }
  .preset-list { flex-direction: row; gap: 6px; overflow-x: auto; }
  .preset-item { min-width: 140px; }
  .composer { max-width: 100%; padding: 12px; }
}

@media (max-width: 480px){
  .composer-input textarea {
    min-height: 50px;
    font-size: 15px;
    padding: 12px 45px 12px 12px;
    border-radius: 18px;
  }
  .send-btn {
    width: 34px;
    height: 34px;
  }
  .send-btn::before { font-size: 14px; }
  .brand h1 { font-size: 16px; }
}


/* ================================
   Sidebar mobile hidden + slide-in
   ================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;           /* hide sidebar offscreen */
    height: 100%;
    width: 320px;            /* slightly wider for readability */
    padding: 18px;
    box-sizing: border-box;
    z-index: 1000;
    transition: left 0.3s ease;
    background: var(--panel);
    box-shadow: 2px 0 12px rgba(0,0,0,0.3);
    border-radius: 0 12px 12px 0;
    overflow-y: auto;        /* allow scrolling if content is tall */
  }

  .sidebar.active {
    left: 0;                 /* slide in */
  }

  /* Dark overlay behind sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 900;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Make preset content more readable */
  .preset-list {
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 200px); /* leaves space for buttons/footer */
    overflow-y: auto;
    padding-right: 6px;
  }
  .preset-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .preset-item > div:last-child {
    display: flex;
    gap: 6px;
    width: 100%;
  }
}

/* Hide mobile menu button on desktop */
@media (min-width: 901px) {
  .icon-btn1 {
    display: none;
  }
}

.icon-btn1 { background: transparent; border: 1px solid var(--border); padding: 8px; border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.icon-btn1:hover { background: var(--glass); }

.presets {
  display: flex;
  flex-direction: column;
  gap: 12px; /* vertical space between children */
  padding: 8px 0; /* optional padding inside sidebar */
}

.presets-header {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px; /* extra spacing just for the header if needed */
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px; /* spacing between preset items */
  overflow-y: auto;
  max-height: 400px; /* optional, prevents overflow on small screens */
}

.preset-controls {
  margin-top: 6px; /* small separation from the list */
}

/* ================================
   Modern scrollbar for chat and presets
   ================================ */

/* For Webkit browsers (Chrome, Edge, Safari) */
.chat::-webkit-scrollbar,
.preset-list::-webkit-scrollbar {
  width: 8px;
}

.chat::-webkit-scrollbar-track,
.preset-list::-webkit-scrollbar-track {
  background: transparent; /* or subtle color */
}

.chat::-webkit-scrollbar-thumb,
.preset-list::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2); /* gray thumb */
  border-radius: 8px;
}

.chat::-webkit-scrollbar-thumb:hover,
.preset-list::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* For Firefox */
.chat, .preset-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

/* IMAGE UPLOADER LOGIC FOR NEXT UPDATE!

#imagePreviewContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.image-preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 12px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

REMOVE ME WHEN YOU UPDATE THE IMAGE UPLOADER LOGIC!*/

/* Footer disclaimer like ChatGPT */
.footer-mistakes {
  font-size: 12px;
  color: var(--muted);      /* same muted color as your theme */
  text-align: center;       /* centered at the bottom */
  padding: 8px 16px;
  margin-top: 1px;
  line-height: 1.4;
  opacity: 0.8;             /* slightly faded */
  user-select: none;        /* optional: prevents selection */
}

/* Optional: responsive smaller font on mobile */
@media (max-width: 480px) {
  .footer-mistakes {
    font-size: 11px;
    padding: 6px 12px;
  }
}


/* Mobile-specific adjustments */
@media (max-width: 900px) {
  .chat {
    max-height: calc(100vh - 180px); /* slightly smaller on mobile */
    padding: 12px;
  }

}

/* --- MOBILE FIXES --- */
@media (max-width: 768px) {

  /* Намаляваме височината на чат полето */
  .chat {
    height: calc(100vh - 700px); /* нагласяме да остане стабилна височина */
    max-height: calc(100vh - 270px);
    flex: none;
  }

  /* Sidebar overlay fixes */
  .sidebar.active {
    max-width: 80%;
  }
}





