/* ========================================
   Altostratus Observability Agent - Styles
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* Design System - CSS Variables */
:root {
  /* Color Palette - Altostratus */
  --primary-dark: #021e5f;
  --primary: #021e5f;
  --primary-light: #0a3a8f;
  --accent: #ff0b6f;
  --accent-hover: #d4005a;
  --accent-blue: #0064ff;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --bg-light: #f8f9fa;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Spacing System (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
}

/* ========================================
   Base Styles
   ======================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
               'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-light);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   Header
   ======================================== */
.header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: white;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.header h1 { 
  font-size: 20px; 
  font-weight: 500;
  letter-spacing: -0.01em;
}

.header .logo { 
  width: 40px; 
  height: 40px; 
  background: transparent;
  border-radius: var(--radius-md); 
  display: flex; 
  align-items: center; 
  justify-content: center;
}

.header .logo img { width: 40px; height: 40px; object-fit: contain; filter: brightness(0) invert(1); }
.header .logo svg { width: 24px; height: 24px; fill: white; }

/* ========================================
   Connection Status
   ======================================== */
.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  transition: all 0.2s ease;
}

.connection-status:hover { background: rgba(255,255,255,0.15); }

.connection-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.3s, box-shadow 0.3s;
}

.connection-status.connected .dot { 
  background: var(--success); 
  box-shadow: 0 0 6px var(--success);
}

.connection-status.connecting .dot { 
  background: var(--warning); 
  animation: pulse 1s infinite; 
}

.connection-status.disconnected .dot { background: var(--error); }

.connection-status.reconnecting .dot { 
  background: var(--warning); 
  animation: pulse 0.5s infinite; 
}

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

/* ========================================
   Login Screen
   ======================================== */
.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #021e5f 0%, #001029 50%, #0a3a8f 100%);
  min-height: 100vh;
}

.login-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-10);
  max-width: 1000px;
  width: 100%;
}

.login-hero {
  flex: 1;
  color: white;
  max-width: 450px;
}

.login-hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
  line-height: 1.2;
}

.login-hero-subtitle {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.login-hero-features {
  list-style: none;
  padding: 0;
  margin: 0;
}

.login-hero-features li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 1.1rem;
  margin-bottom: var(--space-4);
  color: rgba(255, 255, 255, 0.9);
}

.login-hero-features li::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
}

.login-box {
  background: var(--bg-card);
  padding: var(--space-10);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  flex-shrink: 0;
}

.login-box h2 {
  margin-bottom: var(--space-6);
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 600;
}

.login-footer {
  text-align: center;
  padding: var(--space-6);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
}

.login-footer span {
  color: var(--accent);
  font-weight: 500;
}

.login-screen .connection-status { display: none !important; }

/* ========================================
   Forms & Inputs
   ======================================== */
.form-group { margin-bottom: var(--space-4); }

.form-group label { 
  display: block; 
  margin-bottom: var(--space-2); 
  color: var(--text-secondary); 
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-group input:focus,
.input:focus { 
  outline: none; 
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 11, 111, 0.1);
}

.form-group input::placeholder,
.input::placeholder { color: var(--text-light); }

.password-hint {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.75rem;
  color: var(--text-light);
}

.password-input-group {
  display: flex;
  gap: var(--space-2);
}

.password-input-group input { flex: 1; }

.btn-generate {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.btn-generate:hover { background: var(--border); }

/* ========================================
   Buttons
   ======================================== */
.btn {
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(255, 11, 111, 0.3);
}

.btn:hover { 
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(255, 11, 111, 0.4);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(255, 11, 111, 0.3);
}

.btn:disabled { 
  background: var(--border); 
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.error { color: #d13212; font-size: 14px; margin-top: 8px; }

.forgot-password { text-align: center; margin-top: var(--space-4); }
.forgot-password a { color: var(--accent); text-decoration: none; font-size: 14px; }
.forgot-password a:hover { text-decoration: underline; }

/* ========================================
   Main Layout
   ======================================== */
.main-container {
  flex: 1;
  display: none;
  overflow: hidden;
}

.main-container.active { display: flex; }

/* ========================================
   Sidebar (stays dark)
   ======================================== */
.sidebar {
  width: 280px;
  background: #021e5f;
  color: white;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0a3a8f;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #0a3a8f;
}

.new-chat-btn {
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(255, 11, 111, 0.3);
}

.new-chat-btn:hover { 
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(255, 11, 111, 0.4);
}

.new-chat-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(255, 11, 111, 0.3);
}

.new-chat-btn svg { width: 18px; height: 18px; fill: currentColor; }

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sessions-list h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: #879596;
  padding: 12px 8px 8px;
  letter-spacing: 0.5px;
}

.session-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.session-item:hover { background: #0a3a8f; }
.session-item.active { background: #0a3a8f; }

.session-item .icon { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.7; }
.session-item .icon svg { width: 100%; height: 100%; fill: currentColor; }
.session-item .content { flex: 1; min-width: 0; }

.session-item .title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.session-item .date { font-size: 11px; color: #879596; }

.session-item .delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: #879596;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.session-item:hover .delete-btn { opacity: 1; }
.session-item .delete-btn:hover { color: #ff6b6b; background: rgba(255,107,107,0.1); }

.session-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}

.session-item:hover .session-actions { opacity: 1; }

.session-item .edit-btn {
  background: none;
  border: none;
  color: #879596;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.session-item .edit-btn svg { fill: currentColor; }
.session-item .edit-btn:hover { color: var(--accent); background: rgba(255,153,0,0.1); }

.title-edit {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.title-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  background: #011845;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: #e0e0e0;
  outline: none;
}

.title-input:focus { border-color: var(--accent-hover); }

.title-edit-actions { display: flex; gap: 4px; }

.title-save, .title-cancel {
  padding: 2px 8px;
  font-size: 12px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.title-save { background: var(--accent); color: #000; }
.title-save:hover { background: var(--accent-hover); }
.title-cancel { background: #0a3a8f; color: #879596; }
.title-cancel:hover { background: #1050b0; color: #e0e0e0; }

.no-sessions {
  text-align: center;
  padding: 24px;
  color: #879596;
  font-size: 14px;
}

/* ========================================
   Chat Area (light theme)
   ======================================== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-light);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 80%;
  padding: 16px;
  border-radius: 12px;
  line-height: 1.5;
}

.message.user {
  background: var(--primary-dark);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  background: var(--bg-card);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.message pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.message pre code { background: none; padding: 0; color: inherit; }

.message code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  color: var(--accent-hover);
}

.message.user code { background: rgba(255,255,255,0.15); color: white; }

.message ul, .message ol { margin: 8px 0; padding-left: 24px; }
.message li { margin: 4px 0; }

.message h1, .message h2, .message h3, .message h4 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  color: var(--primary-dark);
}

.message h1 { font-size: 1.4em; }
.message h2 { font-size: 1.25em; }
.message h3 { font-size: 1.1em; }
.message h4 { font-size: 1em; }
.message p { margin: 8px 0; }

.message blockquote {
  border-left: 4px solid var(--accent-blue);
  margin: 12px 0;
  padding: 8px 16px;
  background: var(--bg-light);
  border-radius: 0 8px 8px 0;
}

.message table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 14px;
}

.message th, .message td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.message th { background: var(--bg-light); font-weight: 600; }
.message hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.message a { color: var(--accent-blue); text-decoration: none; }
.message a:hover { text-decoration: underline; }

/* ========================================
   Input Area
   ======================================== */
.input-area {
  padding: var(--space-4) var(--space-6);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-3);
}

.input-area input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg-card);
  color: var(--text-primary);
}

.input-area input:focus { 
  outline: none; 
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 11, 111, 0.1);
}

.input-area input:disabled { 
  background: var(--bg-light);
  color: var(--text-light);
}

.input-area input::placeholder { color: var(--text-light); }

.input-area button {
  padding: 12px 24px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(255, 11, 111, 0.3);
}

.input-area button:hover { 
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(255, 11, 111, 0.4);
}

.input-area button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(255, 11, 111, 0.3);
}

.input-area button:disabled { 
  background: var(--border); 
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-area button svg { width: 18px; height: 18px; fill: currentColor; }

/* ========================================
   Loading & Welcome
   ======================================== */
.loading {
  display: flex;
  gap: 4px;
  padding: 8px;
}

.loading span {
  width: 8px;
  height: 8px;
  background: var(--text-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading span:nth-child(1) { animation-delay: -0.32s; }
.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.welcome-message {
  background: linear-gradient(135deg, #fff 0%, var(--bg-light) 100%);
  border: 1px solid var(--border);
}

.welcome-message h3 {
  color: var(--primary-dark);
  margin-bottom: 12px;
  font-size: 18px;
}

.welcome-message ul { color: var(--text-secondary); }

/* ========================================
   Error Banner & Context Indicator
   ======================================== */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4);
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  gap: var(--space-3);
}

.error-banner.visible { display: flex; }

.error-banner button {
  background: var(--error);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.error-banner button:hover { 
  background: #b91c1c;
  transform: translateY(-1px);
}

/* ========================================
   Modals
   ======================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 { 
  font-size: 18px; 
  color: var(--primary);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  line-height: 1;
}

.modal-close:hover { 
  color: var(--primary);
  background: var(--bg-light);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

/* ========================================
   Confirm Modal
   ======================================== */
.confirm-modal {
  max-width: 420px;
  width: 90%;
}

.confirm-modal .modal-body {
  text-align: center;
  padding: var(--space-8) var(--space-6);
}

.confirm-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.confirm-modal-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.confirm-modal-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--error); }
.confirm-modal-icon.info { background: rgba(59, 130, 246, 0.1); color: #2563eb; }

.confirm-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.confirm-modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

.confirm-modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.confirm-modal-actions .btn { width: auto; min-width: 100px; }

.confirm-modal-actions .btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: none;
}

.confirm-modal-actions .btn-secondary:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.confirm-modal-actions .btn-danger {
  background: linear-gradient(180deg, var(--error) 0%, #dc2626 100%);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.confirm-modal-actions .btn-danger:hover {
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
}

/* ========================================
   User Table
   ======================================== */
.user-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.user-table th, .user-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.user-table th {
  background: var(--bg-light);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.user-table td { font-size: 14px; color: var(--text-primary); }
.user-table tbody tr { transition: background 0.2s ease; }
.user-table tbody tr:hover { background: var(--bg-light); }
.user-table tbody tr:last-child td { border-bottom: none; }

/* ========================================
   Badges
   ======================================== */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.role-badge.admin { 
  background: linear-gradient(180deg, rgba(255, 11, 111, 0.15) 0%, rgba(212, 0, 90, 0.15) 100%);
  color: var(--accent-hover);
  border: 1px solid rgba(255, 11, 111, 0.3);
}

.role-badge.user { 
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-badge.confirmed { 
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.confirmed::before { background: var(--success); }

.status-badge.force_change_password { 
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.force_change_password::before { background: var(--warning); }

/* ========================================
   Action Buttons
   ======================================== */
.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  margin-right: var(--space-1);
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.action-btn:hover { 
  background: var(--bg-light);
  border-color: var(--text-light);
  transform: translateY(-1px);
}

.action-btn:active { transform: translateY(0); }

.action-btn.danger { 
  color: var(--error); 
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.action-btn.danger:hover { 
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
}

/* ========================================
   Create User Form & Tabs
   ======================================== */
.create-user-form {
  display: grid;
  gap: var(--space-5);
  max-width: 400px;
}

.create-user-form .form-group { margin-bottom: 0; }

.create-user-form select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  background: var(--bg-card);
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  color: var(--text-primary);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.create-user-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 11, 111, 0.1);
}

.create-user-form .btn { margin-top: var(--space-2); }

.tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-2);
}

.tab-btn {
  padding: var(--space-3) var(--space-5);
  border: none;
  background: transparent;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-light);
}

.tab-btn.active { 
  color: var(--accent);
  background: transparent;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: calc(-1 * var(--space-2) - 1px);
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 2px 2px 0 0;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.loading-users {
  text-align: center;
  padding: var(--space-10);
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-users::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-4);
}

@keyframes spin { to { transform: rotate(360deg); } }

.no-users {
  text-align: center;
  padding: var(--space-10);
  color: var(--text-secondary);
}

.no-users-icon { font-size: 48px; margin-bottom: var(--space-4); opacity: 0.5; }
.no-users-text { font-size: 14px; }

/* ========================================
   User Menu
   ======================================== */
.user-menu {
  position: relative;
  margin-left: auto;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.user-menu-trigger:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

.user-menu-trigger.active {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.5);
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.user-email-text {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-arrow {
  width: 16px;
  height: 16px;
  fill: currentColor;
  transition: transform 0.2s ease;
}

.user-menu-trigger.active .user-menu-arrow { transform: rotate(180deg); }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  z-index: 1000;
  display: none;
  overflow: hidden;
  border: 1px solid var(--border);
}

.user-menu-dropdown.open { display: block; }

.user-menu-profile {
  padding: var(--space-4);
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

.user-menu-profile-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: 14px;
  color: var(--text-primary);
}

.user-menu-profile-item:first-child { padding-top: 0; }
.user-menu-profile-item:last-child { padding-bottom: 0; }

.user-menu-profile-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }

.user-menu-profile-label {
  color: var(--text-secondary);
  font-size: 12px;
  margin-right: var(--space-1);
}

.user-menu-options { padding: var(--space-2) 0; }

.user-menu-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s ease;
  text-align: left;
}

.user-menu-option:hover { background: var(--bg-light); }

.user-menu-option svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  opacity: 0.7;
  flex-shrink: 0;
}

.user-menu-option.danger { color: var(--error); }
.user-menu-option.danger:hover { background: #fef2f2; }

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}

/* ========================================
   MFA Challenge (Login - Cognito Hosted UI)
   ======================================== */
.mfa-challenge-form { display: none; }
.mfa-challenge-form.active { display: block; }

.mfa-challenge-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-4);
  text-align: center;
}

.mfa-challenge-message {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

.mfa-challenge-input-group { margin-bottom: var(--space-4); }

.mfa-challenge-input-group label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.mfa-challenge-input-group input {
  width: 100%;
  text-align: center;
  font-size: 24px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  letter-spacing: 8px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mfa-challenge-input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 11, 111, 0.1);
}

.mfa-challenge-input-group input::placeholder {
  color: var(--text-light);
  letter-spacing: 4px;
}

.mfa-challenge-error {
  color: var(--error);
  font-size: 14px;
  text-align: center;
  margin-top: var(--space-2);
  min-height: 20px;
}

.mfa-challenge-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.mfa-challenge-actions .btn-back {
  flex: 1;
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mfa-challenge-actions .btn-back:hover { background: var(--border); }
.mfa-challenge-actions .btn { flex: 1; }

.login-box #loginForm.hidden { display: none; }
.login-box h2:first-of-type { display: block; }
.login-box.mfa-active > h2:first-of-type { display: none; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 900px) {
  .login-wrapper {
    flex-direction: column;
    gap: var(--space-8);
  }
  
  .login-hero {
    text-align: center;
    max-width: 100%;
  }
  
  .login-hero-title { font-size: 2rem; }
  
  .login-hero-features {
    display: inline-block;
    text-align: left;
  }
}

@media (max-width: 768px) {
  .sidebar { 
    position: absolute;
    left: -280px;
    height: calc(100vh - 72px);
    top: 72px;
    z-index: 100;
    transition: left 0.3s;
  }
  
  .sidebar.open { left: 0; }
  
  .menu-toggle {
    display: block;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
  }
  
  .menu-toggle svg { width: 24px; height: 24px; fill: currentColor; }
  .connection-status span:not(.dot) { display: none; }
  .user-email-text { display: none; }
  
  .user-menu-trigger {
    padding: 8px 10px;
    min-height: 44px;
    min-width: 44px;
  }
  
  .user-avatar { width: 32px; height: 32px; }
  
  .user-menu-dropdown {
    right: -8px;
    min-width: 240px;
    max-width: calc(100vw - 16px);
  }
  
  .user-menu-item {
    min-height: 44px;
    padding: 12px 16px;
  }
}

@media (min-width: 769px) {
  .menu-toggle { display: none; }
}

@media (max-width: 480px) {
  .login-container { padding: var(--space-4); }
  .login-box { padding: var(--space-6); }
  .login-hero-title { font-size: 1.75rem; }
  .login-hero-subtitle { font-size: 1rem; }
  .login-hero-features li { font-size: 1rem; }
  
  .mfa-challenge-input-group input {
    font-size: 20px;
    letter-spacing: 6px;
  }
  
  .mfa-challenge-actions { flex-direction: column-reverse; }
  
  .mfa-challenge-actions .btn,
  .mfa-challenge-actions .btn-back { width: 100%; }
}

/* ========================================
   Action Buttons Layout
   ======================================== */
.action-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.action-btn.icon-btn {
  padding: var(--space-2);
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn.icon-btn svg { width: 16px; height: 16px; }

/* ========================================
   Centered Form (Create User)
   ======================================== */
.create-user-form.centered-form {
  max-width: 400px;
  margin: 0 auto;
}

.create-user-form.centered-form .form-group { text-align: left; }
.create-user-form.centered-form .btn { width: 100%; }
