/* Core Variables */
:root {
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --bg-dark: #0B0F19;
  --bg-sidebar: #131A2A;
  --bg-card: #1F2937;
  --bg-input: #374151;
  --text-main: #FDFDFD;
  --text-muted: #9CA3AF;
  --border: #374151;
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;
  --font-family: 'Plus Jakarta Sans', sans-serif;
  --transition: 0.3s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background: var(--bg-dark); color: var(--text-main); overflow: hidden; height: 100vh; }

.hidden { display: none !important; }
.view { display: none; height: 100%; width: 100%; }
.view.active-view { display: flex; }

/* ======== LOGIN VIEW ======== */
.login-container { align-items: center; justify-content: center; background: radial-gradient(circle at center, #1E1B4B 0%, var(--bg-dark) 100%); }
.login-box {
  background: var(--bg-sidebar); border: 1px solid var(--border); padding: 3rem; border-radius: 1.5rem; width: 100%; max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); text-align: center;
}
.login-subtitle { color: var(--text-muted); margin: 0.5rem 0 2rem 0; font-size: 0.9rem; }
.form-group { text-align: left; margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.8rem; text-transform: uppercase; font-weight: 700; color: var(--text-muted); margin-bottom: 0.5rem; }
.form-group input,
.form-group select {
  width: 100%; padding: 0.8rem 1rem; background: var(--bg-input); border: 1px solid var(--border);
  color: white; border-radius: 0.5rem; outline: none; transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
.submit-btn { background: var(--primary); color: white; border: none; padding: 0.9rem 1.5rem; border-radius: 0.5rem; outline: none; cursor: pointer; font-weight: 600; transition: var(--transition); }
.submit-btn:hover { background: var(--primary-hover); transform: translateY(-2px); }
.submit-btn:disabled { opacity: 0.6; pointer-events: none; }
.full-width { width: 100%; }
.error-text { color: var(--error); font-size: 0.85rem; margin-bottom: 1rem; }
.success-text { color: var(--success); font-size: 0.85rem; margin-bottom: 1rem; }
.toggle-copy { margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }

/* ======== DASHBOARD VIEW ======== */
.dashboard-layout { display: flex; width: 100%; height: 100%; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-size: 1.5rem; font-weight: 700; color: white; justify-content: center; }

/* Sidebar */
.sidebar {
  width: 320px; background: var(--bg-sidebar); border-right: 1px solid var(--border); padding: 2rem 1.5rem;
  display: flex; flex-direction: column; gap: 2rem; transition: transform 0.3s ease; z-index: 100;
}
.profile-card { background: var(--bg-card); padding: 1.25rem; border-radius: 1rem; display: flex; align-items: center; gap: 1rem; border: 1px solid var(--border); position: relative;}
.avatar { background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.avatar.lg { width: 44px; height: 44px; font-size: 1.25rem; }
.profile-info h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.role-badge { background: rgba(99, 102, 241, 0.2); color: #A5B4FC; font-size: 0.7rem; text-transform: uppercase; padding: 0.2rem 0.5rem; border-radius: 0.25rem; }
#logout-btn { position: absolute; right: 1rem; top: 1rem; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.75rem; text-decoration: underline; }

.sidebar-section h3 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 1rem; letter-spacing: 0.05em; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 0.75rem; font-size: 0.9rem; }
.stat-row strong { color: white; }

.status-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; font-size: 0.85rem; }
.badge { padding: 0.2rem 0.5rem; border-radius: 1rem; font-size: 0.7rem; font-weight: 700; background: var(--bg-input); }
.badge.ok { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge.warn { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.badge.bad { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.mt-auto { margin-top: auto; }

/* Main Content */
.main-content { flex: 1; padding: 2rem; display: flex; flex-direction: column; overflow-y: auto; position: relative;}
.main-header h1 { font-size: 2rem; margin-bottom: 0.5rem; background: linear-gradient(135deg, #A5B4FC, #818CF8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Suggested Questions */
.suggested-questions { margin: 1.5rem 0; }
.helper { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.chips-container { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.chip { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-main); padding: 0.5rem 1rem; border-radius: 2rem; font-size: 0.85rem; cursor: pointer; transition: var(--transition); }
.chip:hover { background: var(--primary); border-color: var(--primary); }

/* Chat Container */
.chat-container { flex: 1; display: flex; flex-direction: column; background: rgba(31, 41, 55, 0.5); border: 1px solid var(--border); border-radius: 1rem; overflow: hidden; margin-bottom: 1rem; }
.chat-history { flex: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; }
.message { display: flex; gap: 1rem; max-width: 85%; }
.message.user-message { align-self: flex-end; flex-direction: row-reverse; }
.user-message .avatar { background: #0EA5E9; width: 36px; height: 36px; }
.ai-message .avatar { width: 36px; height: 36px; background: var(--primary); }
.bubble { background: var(--bg-sidebar); padding: 1rem 1.25rem; border-radius: 1rem; border: 1px solid var(--border); line-height: 1.5; font-size: 0.95rem; }
.user-message .bubble { background: var(--primary); color: white; border-top-right-radius: 0; border: none;}
.ai-message .bubble { border-top-left-radius: 0; }
.typing-indicator { display: flex; gap: 4px; align-items: center; }
.typing-indicator span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: typing 1.4s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.5); opacity: 1; } }

/* Form */
.question-form { display: flex; padding: 1rem; background: var(--bg-sidebar); border-top: 1px solid var(--border); gap: 1rem; }
.question-form textarea { flex: 1; background: var(--bg-input); border: 1px solid var(--border); color: white; border-radius: 1rem; padding: 0.8rem 1.25rem; width: 100%; outline: none; font-family: inherit; resize: none; overflow: hidden;}
.question-form textarea:focus { border-color: var(--primary); }
.send-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; padding: 0; border-radius: 50%; margin-top: auto;}

/* Mobile Layout Helpers */
.mobile-header { display: none; align-items: center; justify-content: space-between; padding: 1rem; background: var(--bg-sidebar); border-bottom: 1px solid var(--border); }
.icon-btn { background: none; border: none; font-size: 1.5rem; color: white; cursor: pointer; }
.desktop-only { display: flex; }
.mobile-only { display: none; }

/* ======== RESPONSIVE (MOBILE) ======== */
@media (max-width: 768px) {
  .dashboard-layout { flex-direction: column; }
  .mobile-header { display: flex; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  
  .sidebar {
    position: absolute; top: 0; left: 0; height: 100%; width: 85%; max-width: 320px;
    transform: translateX(-100%); transition: transform 0.3s ease; box-shadow: 10px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  #menu-close { align-self: flex-end; margin-bottom: 1rem; }
  
  .main-content { padding: 1rem; }
  .main-header h1 { font-size: 1.5rem; }
  .message { max-width: 95%; }
}
