/* ==========================================================================
   ТСМС PRO DESIGN SYSTEM — NEXT-GEN SAAS AESTHETICS (LINEAR / STRIPE / DUB)
   ========================================================================== */

:root {
  /* Surface & Background Palette */
  --bg-app: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-input: #FFFFFF;
  --bg-input-focus: #FFFFFF;
  
  /* Borders */
  --border-subtle: #E2E8F0;
  --border-card: #E2E8F0;
  --border-card-hover: #CBD5E1;
  --border-focus: #0284C7;
  --border-divider: #F1F5F9;
  
  /* Brand Accents */
  --primary: #0284C7;
  --primary-bright: #0284C7;
  --primary-hover: #0369A1;
  --primary-light: rgba(2, 132, 199, 0.08);
  --primary-glow: rgba(2, 132, 199, 0.25);
  
  --telegram-blue: #0284C7;
  --telegram-dark: #0070BA;
  
  --success: #059669;
  --success-light: #ECFDF5;
  --success-border: #A7F3D0;
  
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --warning-border: #FDE68A;
  
  --danger: #E11D48;
  --danger-light: #FFF1F2;
  --danger-border: #FECDD3;
  
  --purple: #7C3AED;
  --purple-light: #F5F3FF;
  
  /* Typography Colors (High-Contrast & Clean) */
  --text-pure: #0F172A;
  --text-main: #1E293B;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-dim: #94A3B8;
  
  /* Geometry & Shadows */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;
  
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 8px 24px -2px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 15% 0%, rgba(2, 132, 199, 0.04) 0px, transparent 50%),
    radial-gradient(at 85% 100%, rgba(5, 150, 105, 0.03) 0px, transparent 50%),
    linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
  background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* Top Navigation Bar */
.top-navbar {
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-card);
  box-shadow: var(--shadow-xs);
}

.top-navbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #0284C7 0%, #2563EB 50%, #7C3AED 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
  color: white;
  font-size: 16px;
}

.logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-pure);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(2, 132, 199, 0.08);
  color: var(--primary-bright);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(2, 132, 199, 0.2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-menu.horizontal-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-item, .nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap;
  background: transparent;
}

.nav-item:hover, .nav-tab-btn:hover {
  color: var(--text-pure);
  background: rgba(255, 255, 255, 0.6);
}

.nav-item.active, .nav-tab-btn.active {
  color: var(--primary-bright) !important;
  background: #FFFFFF !important;
  border-color: rgba(2, 132, 199, 0.15) !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05) !important;
}

.nav-item i, .nav-tab-btn i {
  font-size: 14px;
  opacity: 0.9;
}

.nav-item.active i, .nav-tab-btn.active i {
  opacity: 1;
}

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

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 24px 28px 48px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Modern Card Architecture */
.glass-card,
.tg-card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
}

.glass-card:hover,
.tg-card:hover {
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-pure);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}

.card-title i {
  font-size: 15px;
  color: var(--primary-bright);
}

/* Top Metrics Grid (4 KPI Cards) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 992px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  position: relative;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  will-change: box-shadow, border-color;
}

.metric-card:hover {
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-hover);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.metric-title {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.badge-live {
  background: var(--primary-light);
  color: var(--primary-bright);
  border: 1px solid rgba(2, 132, 199, 0.2);
}

.badge-trend {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warn {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-purple {
  background: var(--purple-light);
  color: var(--purple);
  border: 1px solid #DDD6FE;
}

.metric-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-pure);
  font-family: var(--font-mono);
  letter-spacing: -0.04em;
  margin-bottom: 4px;
  line-height: 1.1;
}

.metric-footer {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  user-select: none;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--text-main);
  border-color: var(--border-card);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-card-hover);
  color: var(--text-pure);
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
  border-color: var(--success);
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  background: #047857;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.25);
}

.btn-danger:hover {
  background: #BE123C;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: var(--radius-xs);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
}

/* Inputs & Form Controls */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.input-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-field,
input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: var(--text-pure);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.search-input,
input.search-input {
  padding-left: 36px !important;
}

.input-field:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light), inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Filter Chips Grid */
.filter-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
  width: fit-content;
  flex-wrap: wrap;
}

.filter-btn,
.bot-filter-btn,
.persona-filter-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-btn:hover,
.bot-filter-btn:hover,
.persona-filter-btn:hover {
  color: var(--text-pure);
  background: rgba(255, 255, 255, 0.7);
}

.filter-btn.active,
.bot-filter-btn.active,
.persona-filter-btn.active {
  background: #FFFFFF !important;
  color: var(--primary-bright) !important;
  border-color: rgba(2, 132, 199, 0.2) !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
  font-weight: 700 !important;
}

/* Tables */
.data-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--bg-subtle);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 11.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-card);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-divider);
  color: var(--text-main);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #F8FAFC;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.connecting-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

.connecting-overlay.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-pure);
}

.modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: calc(90vh - 130px);
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-divider);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-subtle);
  flex-shrink: 0;
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

/* ==========================================================================
   LIVE CHAT & TELEGRAM UI STYLES
   ========================================================================== */
.chat-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 125px);
  min-height: 580px;
  max-height: calc(100vh - 120px);
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.08);
}

@media (max-width: 960px) {
  .chat-layout {
    grid-template-columns: 280px 1fr;
  }
}

@media (max-width: 768px) {
  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }
}

.chat-sidebar {
  border-right: 1px solid var(--border-divider);
  display: flex;
  flex-direction: column;
  background: #F8FAFC;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#chats-sidebar-list {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.chat-messages-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #F1F5F9;
  overflow: hidden;
  position: relative;
}

#active-chat-messages {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

.chat-bubble-bot {
  background: #0284C7;
  color: #FFFFFF;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 75%;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.18);
}

.chat-bubble-user {
  background: #FFFFFF;
  color: var(--text-pure);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 75%;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

/* ==========================================================================
   INTERACTIVE CALENDAR STYLES
   ========================================================================== */
.cal-day-cell {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.cal-day-cell:hover {
  transform: translateY(-1px);
}

.cal-day-cell:active {
  transform: scale(0.98);
}

/* ==========================================================================
   TERMINAL CONSOLE CUSTOM STYLES (MATCHING SAAS THEME)
   ========================================================================== */
#terminal-cmd-input {
  background: #F8FAFC !important;
  border: 1px solid #E2E8F0 !important;
  border-radius: 12px !important;
  color: #0F172A !important;
  font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
  font-size: 12px !important;
  padding: 8px 14px !important;
  outline: none !important;
  caret-color: #0284C7 !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#terminal-cmd-input:focus {
  background: #FFFFFF !important;
  border-color: #0284C7 !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15) !important;
  outline: none !important;
}

#terminal-cmd-input::placeholder {
  color: #94A3B8 !important;
}



