/* ==========================================
   FragH2 Web Dashboard - H2-AI Brand Styles
   ========================================== */

:root {
  /* Brand Colors */
  --primary: #6366f1;
  --primary-hover: #5457e5;
  --secondary: #8b5cf6;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* Neutrals (Light Mode) */
  --bg-primary: #ffffff;
  --bg-secondary: #F3F4F6;
  --bg-tertiary: #E5E7EB;
  --bg-sidebar: #f9fafb;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;

  /* Chat specific */
  --msg-user-bg: var(--gradient);
  --msg-user-text: #ffffff;
  --msg-ai-bg: #F3F4F6;
  --msg-ai-text: #1F2937;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);

  /* Misc */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-width: 280px;
  --transition: 0.2s ease;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1F2937;
  --bg-tertiary: #374151;
  --bg-sidebar: #0f172a;
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-muted: #6B7280;
  --border: #374151;
  --msg-ai-bg: #1F2937;
  --msg-ai-text: #F9FAFB;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
}

/* ==========================================
   Reset & Base
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.page {
  display: none;
  height: 100%;
}
.page.active {
  display: flex;
}

/* ==========================================
   LOGIN PAGE
   ========================================== */
#login-page {
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 180px;
  height: auto;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
}

.login-form {
  background: var(--bg-primary);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}

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

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

.error-message {
  background: #FEF2F2;
  color: #DC2626;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid #FECACA;
}

[data-theme="dark"] .error-message {
  background: #450a0a;
  border-color: #7f1d1d;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

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

.login-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-footer strong {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================
   CHAT PAGE LAYOUT
   ========================================== */
#chat-page {
  flex-direction: row;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport for mobile */
  overflow: hidden;
  background: var(--bg-secondary);
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.sidebar-logo {
  height: 32px;
  width: auto;
  margin-right: auto;
}

.btn-new-chat {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.btn-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

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

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px;
}

.session-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  margin-bottom: 3px;
  position: relative;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}

.session-item .session-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item .session-delete {
  opacity: 0;
  position: absolute;
  right: 6px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

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

.session-item .session-delete:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
}

.session-item:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.session-item.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 500;
  border-color: var(--primary);
}

/* Telegram Sync Session */
.session-item.telegram-sync {
  border-left: 3px solid #0088cc;
  background: rgba(0, 136, 204, 0.08);
}

.session-item.telegram-sync:hover {
  background: rgba(0, 136, 204, 0.12);
}

.session-item.telegram-sync.active {
  background: rgba(0, 136, 204, 0.15);
  border-color: #0088cc;
}

.btn-lists {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-lists:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background var(--transition), color var(--transition);
}

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

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ==========================================
   CHAT MAIN
   ========================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-primary);
}

.chat-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-title h2 {
  font-size: 16px;
  font-weight: 600;
}

.mobile-only {
  display: none;
}

/* ==========================================
   MESSAGES
   ========================================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Welcome Message */
.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
}

.welcome-icon {
  margin-bottom: 20px;
  opacity: 0.9;
}

.welcome-message h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome-message p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 24px;
}

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion-chip {
  padding: 10px 18px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.suggestion-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

/* Message Bubbles */
.message-row {
  display: flex;
  gap: 12px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.ai-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.ai-avatar svg {
  width: 20px;
  height: 20px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.6;
  font-size: 15px;
  max-width: calc(100% - 56px);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-row.ai .message-bubble {
  background: var(--msg-ai-bg);
  color: var(--msg-ai-text);
  border-top-left-radius: 4px;
}

.message-row.user .message-bubble {
  background: var(--gradient);
  color: var(--msg-user-text);
  border-top-right-radius: 4px;
}

/* Markdown inside AI messages */
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  margin-top: 16px;
  margin-bottom: 8px;
}

.message-bubble h1:first-child, .message-bubble h2:first-child, .message-bubble h3:first-child {
  margin-top: 0;
}

.message-bubble p {
  margin-bottom: 8px;
}

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

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

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble code {
  background: rgba(0,0,0,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

[data-theme="dark"] .message-bubble code {
  background: rgba(255,255,255,0.1);
}

.message-bubble pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
}

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

.message-bubble a {
  color: var(--primary);
  text-decoration: underline;
}

.message-row.user .message-bubble a {
  color: #c7d2fe;
}

.message-bubble blockquote {
  border-left: 3px solid var(--primary);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-secondary);
}

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

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

.message-bubble th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 8px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.ai-avatar-small {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-avatar-small svg {
  width: 16px;
  height: 16px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--msg-ai-bg);
  border-radius: 12px;
}

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

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

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

/* ==========================================
   INPUT AREA
   ========================================== */
.chat-input-container {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
}

/* Attachment Preview */
.attachment-preview {
  max-width: 800px;
  margin: 0 auto 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attachment-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.attachment-item span {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-remove-attachment {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-remove-attachment:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

/* Attach Button */
.btn-attach {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-attach:hover {
  background: var(--bg-tertiary);
  color: var(--primary);
}

.chat-input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#chat-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 150px;
  padding: 4px 0;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.input-hint {
  max-width: 800px;
  margin: 6px auto 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================
   SCROLLBAR
   ========================================== */
.chat-messages::-webkit-scrollbar,
.sidebar-sessions::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.sidebar-sessions::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.sidebar-sessions::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sidebar-sessions::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================
   RESPONSIVE (Mobile)
   ========================================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: flex;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-input-container {
    padding: 12px 16px;
  }

  .message-row {
    max-width: 100%;
  }

  .welcome-suggestions {
    flex-direction: column;
  }

  .suggestion-chip {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .message-bubble {
    max-width: calc(100% - 48px);
    font-size: 14px;
  }

  .ai-avatar, .user-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }
}

/* Session delete button */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.session-delete {
  display: none;
  background: none;
  border: none;
  color: #9CA3AF;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}
.session-delete:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
}
.session-item:hover .session-delete {
  display: block;
}

/* ==========================================
   CHROME-STYLE TAB GROUPS
   ========================================== */

/* Group colors */
:root {
  --group-gray: #6B7280;
  --group-blue: #3B82F6;
  --group-red: #EF4444;
  --group-yellow: #F59E0B;
  --group-green: #10B981;
  --group-pink: #EC4899;
  --group-purple: #8B5CF6;
  --group-cyan: #06B6D4;
}

/* Group wrapper (for drag support) */
.group-wrapper {
  margin-bottom: 4px;
}

.group-wrapper.collapsed .group-sessions {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* Group label (matching session-item style) */
.group-label {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin: 0 0 3px 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  gap: 6px;
  transition: all 0.15s;
  position: relative;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}

.group-label::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.group-label.color-gray { border-left: 3px solid #6B7280; background: rgba(107, 114, 128, 0.12); }
.group-label.color-gray::before { background: #6B7280; }
.group-label.color-blue { border-left: 3px solid #3B82F6; background: rgba(59, 130, 246, 0.12); }
.group-label.color-blue::before { background: #3B82F6; }
.group-label.color-red { border-left: 3px solid #EF4444; background: rgba(239, 68, 68, 0.12); }
.group-label.color-red::before { background: #EF4444; }
.group-label.color-yellow { border-left: 3px solid #F59E0B; background: rgba(245, 158, 11, 0.12); }
.group-label.color-yellow::before { background: #F59E0B; }
.group-label.color-green { border-left: 3px solid #10B981; background: rgba(16, 185, 129, 0.12); }
.group-label.color-green::before { background: #10B981; }
.group-label.color-pink { border-left: 3px solid #EC4899; background: rgba(236, 72, 153, 0.12); }
.group-label.color-pink::before { background: #EC4899; }
.group-label.color-purple { border-left: 3px solid #8B5CF6; background: rgba(139, 92, 246, 0.12); }
.group-label.color-purple::before { background: #8B5CF6; }
.group-label.color-cyan { border-left: 3px solid #06B6D4; background: rgba(6, 182, 212, 0.12); }
.group-label.color-cyan::before { background: #06B6D4; }

.group-label:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.group-label .group-toggle {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s;
}

.group-label.collapsed .group-toggle {
  transform: rotate(-90deg);
}

.group-label .group-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-label .group-count {
  font-size: 10px;
  opacity: 0.8;
}

/* Grouped sessions container */
.group-sessions {
  margin: 0;
  padding-left: 16px;
  transition: max-height 0.2s ease, opacity 0.2s ease;
  overflow: hidden;
}

/* Group sessions inherit styling from parent */

/* Collapsed state handled by .group-wrapper.collapsed */

.group-sessions .session-item {
  margin-left: 4px;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 1001;
  display: none;
  padding: 4px 0;
}

.context-menu.show {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  gap: 10px;
  color: var(--text-primary);
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: var(--bg-tertiary);
}

.context-menu-item.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

.context-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
}

.context-arrow {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
}

.context-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.context-submenu {
  display: none;
  padding-left: 20px;
}

.context-menu-item[data-action="add-to-group"]:hover + .context-submenu,
.context-submenu:hover {
  display: block;
}

.context-submenu .context-menu-item {
  padding: 6px 12px;
}

/* Color dots in submenu */
.context-menu-item .group-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Modal for new group */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1002;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 320px;
  box-shadow: var(--shadow-xl);
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
}

.modal-content input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Color picker */
.color-picker {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.15s;
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-secondary {
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

/* Sortable states */
.sortable-ghost {
  opacity: 0.4;
  background: var(--bg-tertiary) !important;
}

.sortable-drag {
  background: var(--bg-primary) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  border-radius: var(--radius-sm);
}

.sortable-chosen {
  background: var(--bg-tertiary);
}
