/* ==========================================================================
   AJAIB CS ASSISTANT — TACTILE SKEUOMORPHIC DESIGN SYSTEM
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-main: #0b0d12;
  --panel-bg: #141721;
  --panel-card: #1c202e;
  --panel-card-accent: #23283a;
  
  --debossed-bg: #090b0f;
  --text-main: #e2e8f0;
  --text-muted: #8b95a8;
  --text-dim: #5c667a;

  --accent-cyan: #00d2ff;
  --accent-blue: #0088ff;
  --accent-green: #00ff88;
  --accent-amber: #ffaa00;
  --accent-red: #ff3355;

  /* Skeuomorphic Bevel & Shadow Tokens */
  --bevel-light: rgba(255, 255, 255, 0.08);
  --bevel-dark: rgba(0, 0, 0, 0.7);

  --shadow-raised: 
    0 4px 12px rgba(0, 0, 0, 0.6), 
    inset 0 1px 1px rgba(255, 255, 255, 0.12),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5);

  --shadow-button: 
    0 4px 8px rgba(0, 0, 0, 0.5), 
    inset 0 1px 1px rgba(255, 255, 255, 0.18),
    inset 0 -2px 4px rgba(0, 0, 0, 0.6);

  --shadow-button-active: 
    0 1px 2px rgba(0, 0, 0, 0.8), 
    inset 0 2px 4px rgba(0, 0, 0, 0.7);

  --shadow-debossed: 
    inset 2px 2px 8px rgba(0, 0, 0, 0.85), 
    inset -1px -1px 3px rgba(255, 255, 255, 0.04),
    0 1px 1px rgba(255, 255, 255, 0.05);

  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(0, 136, 255, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(0, 255, 136, 0.03) 0%, transparent 50%);
}

/* ==========================================================================
   APP CONTAINER (TERMINAL CHASSIS)
   ========================================================================== */

.app-container {
  width: 100%;
  max-width: 1100px;
  height: 92vh;
  max-height: 900px;
  background: linear-gradient(145deg, #181c29 0%, #10131d 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.9),
    inset 0 1px 2px rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   TOP HEADER (SKEUOMORPHIC BRAND BAR)
   ========================================================================== */

.skeuo-header {
  background: linear-gradient(180deg, #222737 0%, #161a26 100%);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  z-index: 10;
}

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

.sidebar-toggle-btn {
  padding: 8px 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #0088ff 0%, #00d2ff 100%);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  color: #fff;
  box-shadow: 
    0 4px 10px rgba(0, 136, 255, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.4),
    inset 0 -2px 3px rgba(0, 0, 0, 0.4);
}

.brand-info h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.brand-info .sub-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* LED Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 12px;
  border-radius: 20px;
  box-shadow: var(--shadow-debossed);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.led-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--text-dim);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
}

.led-dot.active {
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green), inset 0 1px 1px rgba(255,255,255,0.6);
}

.status-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.model-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(0, 136, 255, 0.12);
  color: var(--accent-cyan);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(0, 210, 255, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   WORKSPACE & SIDEBAR DRAWER
   ========================================================================== */

.workspace-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.sidebar-drawer {
  width: 280px;
  background: linear-gradient(180deg, #131722 0%, #0b0d13 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  box-shadow: inset -2px 0 8px rgba(0, 0, 0, 0.5);
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 5;
}

.sidebar-drawer.collapsed {
  margin-left: -280px;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-new-chat-btn {
  width: 100%;
  padding: 10px;
  font-size: 13px;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s ease;
  user-select: none;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.session-item.active {
  background: linear-gradient(135deg, rgba(0, 136, 255, 0.2) 0%, rgba(0, 210, 255, 0.08) 100%);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-raised);
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.session-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-time {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.session-delete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.session-delete-btn:hover {
  color: var(--accent-red);
  background: rgba(255, 51, 85, 0.15);
}

/* ==========================================================================
   BUTTON SYSTEM (PHYSICAL 3D BEVELED BUTTONS)
   ========================================================================== */

.skeuo-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #2b3145 0%, #1a1e2b 100%);
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-button);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.1s ease;
  user-select: none;
}

.skeuo-btn:hover {
  background: linear-gradient(180deg, #323950 0%, #202535 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.skeuo-btn:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-button-active);
  background: linear-gradient(180deg, #161924 0%, #222838 100%);
}

.primary-btn {
  background: linear-gradient(180deg, #0088ff 0%, #0055cc 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 4px 10px rgba(0, 136, 255, 0.3), var(--shadow-button);
}

.primary-btn:hover {
  background: linear-gradient(180deg, #1aa0ff 0%, #0066ee 100%);
}

.danger-btn {
  background: linear-gradient(180deg, #ff3355 0%, #cc1133 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn {
  padding: 8px 12px;
}

/* ==========================================================================
   DEBOSSED SCREEN DISPLAY
   ========================================================================== */

.debossed-screen {
  flex: 1;
  background-color: var(--debossed-bg);
  box-shadow: var(--shadow-debossed);
  border: 1px solid rgba(0, 0, 0, 0.8);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.debossed-screen::-webkit-scrollbar {
  width: 8px;
}

.debossed-screen::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.4);
}

.debossed-screen::-webkit-scrollbar-thumb {
  background: #252b3b;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Welcome Hero Card */
.skeuo-card {
  background: linear-gradient(145deg, #1e2333 0%, #151824 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: var(--shadow-raised);
}

.welcome-card {
  padding: 32px;
  text-align: center;
  max-width: 680px;
  margin: 40px auto;
}

.hero-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #252c40 0%, #141824 100%);
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  color: var(--accent-cyan);
  box-shadow: var(--shadow-raised);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.welcome-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 10px;
  color: #fff;
}

.welcome-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.suggested-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(180deg, #242b3d 0%, #171b28 100%);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-button);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip-btn:hover {
  border-color: var(--accent-cyan);
  color: #fff;
  transform: translateY(-1px);
}

.chip-btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-button-active);
}

/* ==========================================================================
   CHAT MESSAGES & BUBBLES
   ========================================================================== */

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message-row {
  display: flex;
  gap: 14px;
  max-width: 88%;
}

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

.message-row.assistant-row {
  align-self: flex-start;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: var(--shadow-button);
  border: 1px solid rgba(255,255,255,0.1);
}

.user-row .avatar {
  background: linear-gradient(135deg, #0088ff 0%, #0044aa 100%);
  color: #fff;
}

.assistant-row .avatar {
  background: linear-gradient(135deg, #2a3146 0%, #151926 100%);
  color: var(--accent-cyan);
}

.bubble {
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}

.user-row .bubble {
  background: linear-gradient(180deg, #1b263b 0%, #111a2b 100%);
  border: 1px solid rgba(0, 136, 255, 0.3);
  color: #e6f0ff;
  box-shadow: var(--shadow-debossed);
  border-bottom-right-radius: 4px;
}

.assistant-row .bubble {
  background: linear-gradient(145deg, #1e2333 0%, #141724 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  box-shadow: var(--shadow-raised);
  border-bottom-left-radius: 4px;
  width: 100%;
}

/* Formatting in responses */
.bubble p {
  margin-bottom: 10px;
}

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

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

.bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-link {
  color: var(--accent-cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
  font-weight: 600;
  transition: all 0.15s ease;
}

.chat-link:hover {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(0, 210, 255, 0.6);
}

/* Sources Collapsible Card */
.sources-card {
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.sources-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.sources-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sources-content {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.source-item {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.source-title {
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.score-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0, 255, 136, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(0, 255, 136, 0.3);
}

.source-text {
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Metadata Bar */
.meta-info-bar {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}

/* ==========================================================================
   BOTTOM FOOTER (INPUT CONSOLE)
   ========================================================================== */

.skeuo-footer {
  background: linear-gradient(180deg, #171b28 0%, #0e111a 100%);
  padding: 18px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
}

.input-console-form {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.debossed-textarea-wrapper {
  flex: 1;
  background: var(--debossed-bg);
  box-shadow: var(--shadow-debossed);
  border: 1px solid rgba(0, 0, 0, 0.9);
  border-radius: 14px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
}

.debossed-textarea-wrapper textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 14px;
  color: #fff;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
}

.debossed-textarea-wrapper textarea::placeholder {
  color: var(--text-dim);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.send-btn {
  height: 48px;
  padding: 0 24px;
  border-radius: 12px;
}

.stop-btn {
  height: 48px;
  padding: 0 20px;
  border-radius: 12px;
}

/* ==========================================================================
   MODAL OVERLAY (AUTH VAULT)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  width: 100%;
  max-width: 440px;
  padding: 32px;
}

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.vault-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #0088ff 0%, #0044aa 100%);
  border-radius: 16px;
  margin: 0 auto 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 136, 255, 0.4), var(--shadow-raised);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #fff;
}

.modal-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.debossed-input-wrapper {
  background: var(--debossed-bg);
  box-shadow: var(--shadow-debossed);
  border: 1px solid rgba(0, 0, 0, 0.9);
  border-radius: 10px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  height: 46px;
}

.debossed-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #fff;
}

.toggle-eye {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
}

.toggle-eye:hover {
  color: #fff;
}

.auth-error-badge {
  font-size: 12px;
  color: var(--accent-red);
  background: rgba(255, 51, 85, 0.12);
  border: 1px solid rgba(255, 51, 85, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-footer {
  margin-top: 20px;
  text-align: center;
}

.secure-tag {
  font-size: 10px;
  color: var(--text-dim);
}

/* Utilities */
.hidden {
  display: none !important;
}

.full-width {
  width: 100%;
}

/* Streaming Cursor Indicator */
.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 14px;
  background-color: var(--accent-cyan);
  vertical-align: middle;
  margin-left: 2px;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    height: 100vh;
    border-radius: 0;
  }

  .sidebar-drawer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 50;
    margin-left: -280px;
  }

  .sidebar-drawer.open {
    margin-left: 0;
  }
  
  .skeuo-header {
    padding: 12px 16px;
  }
  
  .btn-label {
    display: none;
  }
  
  .message-row {
    max-width: 96%;
  }
}
