/* ========================================
   VEEN AI STUDIO – COMPLETE STYLE (FIXED MOBILE)
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0f0f23;
  color: #e0e0e0;
  overflow: hidden;      /* prevent page scroll */
}

/* ===== App Layout ===== */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;         /* dynamic viewport height (mobile address bar safe) */
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: #16213e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  transition: width 0.3s ease;
}

.sidebar-header {
  padding: 20px 15px;
  border-bottom: 1px solid #1a1a2e;
}

.sidebar-header h1 {
  font-size: 20px;
  color: #4c8bf5;
  margin-bottom: 10px;
}

.project-selector {
  display: flex;
  gap: 8px;
}

.project-selector input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1e1e3a;
  color: #fff;
  font-size: 13px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  min-height: 0;   /* allow scrolling inside */
}

/* Chat history */
.chat-history {
  margin-bottom: 20px;
}

.chat-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.chat-list {
  max-height: 200px;
  overflow-y: auto;
}

.chat-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #b0b0b0;
}

.chat-item:hover {
  background: rgba(255,255,255,0.08);
}

.chat-item.active {
  background: rgba(76,139,245,0.2);
  border-left: 3px solid #4c8bf5;
  color: #fff;
}

/* File explorer */
.file-explorer {
  margin-bottom: 20px;
}

.explorer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.file-tree {
  font-size: 13px;
  max-height: 250px;
  overflow-y: auto;
}

.tree-item {
  padding: 2px 0;
}

.dir {
  font-weight: 500;
  color: #4fc3f7;
  cursor: pointer;
}

.file {
  color: #ccc;
  cursor: pointer;
  padding: 2px 8px;
  display: inline-block;
  border-radius: 4px;
  transition: background 0.2s;
}

.file:hover {
  background: rgba(255,255,255,0.08);
}

.upload-area {
  margin-top: 10px;
}

.drop-zone {
  border: 2px dashed #444;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.drop-zone:hover {
  border-color: #4c8bf5;
}

.drop-zone p {
  font-size: 13px;
  color: #888;
  margin-bottom: 10px;
}

.upload-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-small {
  padding: 5px 10px;
  border: 1px solid #333;
  border-radius: 5px;
  background: #1e1e3a;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-small:hover {
  background: #2a2a4a;
}

/* Model selector */
.model-selector {
  margin-top: 15px;
}

.model-selector label {
  display: block;
  color: #999;
  font-size: 12px;
  margin-bottom: 4px;
}

.model-selector select {
  width: 100%;
  padding: 6px 8px;
  background: #1e1e3a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 13px;
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  height: 100%;
  min-height: 0;            /* important for flex to allow shrinking */
  overflow: hidden;
}

.chat-header {
  padding: 15px 20px;
  border-bottom: 1px solid #223;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e1e3a;
  flex-shrink: 0;          /* prevent header shrinking */
}

.chat-header h2 {
  color: #fff;
  font-size: 16px;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;            /* allow shrinking */
}

.message {
  max-width: 95%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 14px;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 75%;
}

.assistant-message {
  align-self: flex-start;
  background: #262650;
  color: #e5e5e5;
  border-bottom-left-radius: 4px;
  max-width: 98%;
}

.system-message {
  align-self: center;
  color: #888;
  font-style: italic;
}

/* Message formatting */
.message p { margin-bottom: 8px; }
.message p:last-child { margin-bottom: 0; }
.message h1, .message h2, .message h3, .message h4 { margin: 12px 0 6px; color: #fff; }
.message ul, .message ol { margin: 6px 0; padding-left: 22px; }
.message a { color: #60a5fa; text-decoration: underline; }
.message code { background: rgba(255,255,255,0.15); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.user-message code { background: rgba(255,255,255,0.25); }

/* Code blocks */
.code-block {
  background: #0d1117;
  border-radius: 10px;
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid #30363d;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  font-size: 12px;
  color: #8b949e;
}

.copy-btn {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: #30363d;
  color: #fff;
}

.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
}

.code-block code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  background: transparent;
  padding: 0;
  color: #e6edf3;
  white-space: pre;
  font-size: 13px;
  line-height: 1.5;
}

/* Loading */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 10px;
}

.loading-orb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #4c8bf5;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0.5; }
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  background: #4c8bf5;
  border-radius: 50%;
  animation: bounce 0.6s infinite alternate;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.loading-text {
  color: #888;
  font-size: 13px;
}

/* ===== INPUT AREA ===== */
.input-area {
  padding: 15px 20px 20px;
  background: #1e1e3a;
  border-top: 1px solid #223;
  flex-shrink: 0;            /* keep at bottom, don't shrink */
  z-index: 10;               /* ensure above messages */
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: flex-end;
  background: #1e1e3a;
  border: 1px solid #333;
  border-radius: 24px;
  padding: 8px 12px;
  gap: 10px;
  box-shadow: none;
}

.input-wrapper:focus-within {
  border-color: #4c8bf5;
  box-shadow: 0 0 0 2px rgba(76,139,245,0.2);
}

#userInput {
  flex: 1;
  border: none;
  background: transparent;
  color: #fff;
  resize: none;
  font-size: 15px;
  padding: 8px 4px;
  outline: none;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  margin: 0;
}

#userInput::placeholder {
  color: #888;
}

.attach-btn {
  background: transparent;
  border: none;
  color: #888;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.attach-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.send-btn {
  background: #4c8bf5;
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #3a7bd5;
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== ATTACHMENT MENU (Hidden by default) ===== */
.attachment-menu {
  display: none;
  position: absolute;
  bottom: 60px;
  left: 10px;
  background: #1e1e3a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 8px;
  z-index: 1000;
  box-shadow: 0 6px 16px rgba(0,0,0,0.6);
}

.attachment-menu.show {
  display: block;
}

.attachment-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: #fff;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.2s;
}

.attachment-menu button:hover {
  background: rgba(255,255,255,0.1);
}

/* ===== MOBILE RESPONSIVE ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
}

.mobile-hamburger {
  display: none;
}

@media (max-width: 768px) {
  .app {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }

  /* Sidebar slides from left */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 10000;
    background: #16213e;
    display: flex;
    flex-direction: column;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar .sidebar-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  .sidebar .sidebar-header {
    padding-top: 60px;  /* space for hamburger */
  }

  .sidebar-overlay.show {
    display: block;
  }

  .chat-area {
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chat-header {
    padding-left: 60px;  /* space for hamburger */
    flex-shrink: 0;
  }

  .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .input-area {
    flex-shrink: 0;
    padding-bottom: 15px;
    background: #1e1e3a;  /* ensure it has background */
    z-index: 10;
  }

  .file-viewer {
    display: none;
  }

  /* Hamburger button */
  .mobile-hamburger {
    display: block;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 20000;
    background: rgba(0,0,0,0.3);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
  }
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #1a1a2e;
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#loadingText {
    transition: opacity 0.3s ease;
}