:root {
  --bg-dark: #0b0f19;
  --card-bg: rgba(22, 30, 49, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --primary-accent: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --online-color: #10b981;
  --offline-color: #ef4444;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.background-glow {
  position: absolute;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary-accent) 0%, transparent 70%);
  opacity: 0.12;
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
}

.logo-text {
  font-weight: 700;
  font-size: 1.3rem;
  color: #fff;
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.lang-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

.container {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

/* КАРТОЧКИ (Glassmorphism) */
.auth-card, .card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.auth-card {
  max-width: 450px;
  margin: 4rem auto;
}

h2, h3 {
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* КНОПКИ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
}

.btn-primary {
  background: var(--primary-accent);
  color: #fff;
}

.btn-primary:hover {
  background: #4f46e5;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.auth-toggle {
  text-align: center;
  margin-top: 1.5rem;
}

.auth-toggle a {
  color: var(--primary-accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

/* КАБИНЕТ ПОЛЬЗОВАТЕЛЯ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr 2fr;
  }
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.token-display-wrapper {
  display: flex;
  gap: 0.5rem;
}

.token-display-wrapper input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.8rem;
  border-radius: 8px;
  font-family: monospace;
  font-size: 1rem;
  text-align: center;
  letter-spacing: 1px;
}

/* ТАБЛИЦА УСТРОЙСТВ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.devices-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.devices-table th,
.devices-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.devices-table th {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
}

.devices-table td {
  font-size: 0.95rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
}

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

.status-online {
  color: var(--online-color);
}

.status-online::before {
  background-color: var(--online-color);
  box-shadow: 0 0 8px var(--online-color);
}

.status-offline {
  color: var(--text-secondary);
}

.status-offline::before {
  background-color: var(--offline-color);
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem 0;
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

/* --- НОВЫЕ СТИЛИ ДЛЯ ВЕБ-ПОДКЛЮЧЕНИЯ И СЕССИЙ --- */

.remote-card .connection-box {
  display: flex;
  gap: 0.5rem;
}

.remote-card .connection-box input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.8rem;
  border-radius: 8px;
  font-family: monospace;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 1px;
  outline: none;
}

.remote-card .connection-box input:focus {
  border-color: var(--primary-accent);
}

.session-status-info {
  margin-top: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border-color);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ЭКРАН АКТИВНОЙ СЕССИИ (ПОВЕРХ ВСЕГО) */
.session-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #060910;
  display: flex;
  flex-direction: column;
  z-index: 9999;
}

/* Плавающий Тулбар */
.session-toolbar {
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(12px);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  z-index: 10000;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.app-dot {
  width: 8px;
  height: 8px;
  background-color: var(--offline-color);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--offline-color);
  animation: pulse 1.5s infinite;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s;
}

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

.toolbar-btn .badge {
  position: absolute;
  top: 0px;
  right: 0px;
  background: var(--offline-color);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  border-radius: 10px;
  font-weight: bold;
}

/* Основной макет сессии */
.session-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.video-container-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.video-stream-mock {
  width: 100%;
  height: 100%;
}

.video-placeholder-text {
  text-align: center;
  color: #9ca3af;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.loader-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--primary-accent);
  border-radius: 50%;
  margin: 0 auto 1.5rem auto;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

/* Виртуальный Курсор */
.virtual-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 10100;
  transition: left 0.1s ease-out, top 0.1s ease-out;
}

.cursor-dot {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 10px #ef4444;
  border: 1px solid #fff;
}

.cursor-label {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Боковая Панель (Чат/Файлы) */
.session-side-panel {
  width: 320px;
  background: #111827;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10050;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #1f2937;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  text-align: center;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: #fff;
  border-bottom: 2px solid var(--primary-accent);
  background: rgba(255, 255, 255, 0.02);
}

.tab-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem;
}

/* Чат */
.chat-messages-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-messages-list::-webkit-scrollbar,
.shared-files-list::-webkit-scrollbar {
  width: 4px;
}

.chat-messages-list::-webkit-scrollbar-thumb,
.shared-files-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.system-msg {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  align-self: center;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-bubble.sent {
  background: var(--primary-accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-bubble.received {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-send-box {
  display: flex;
  gap: 0.5rem;
}

.chat-send-box input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  outline: none;
  font-size: 0.85rem;
}

.chat-send-box input:focus {
  border-color: var(--primary-accent);
}

/* Передача файлов */
.file-drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(0, 0, 0, 0.15);
  margin-bottom: 1.25rem;
}

.file-drop-zone:hover {
  border-color: var(--primary-accent);
  background: rgba(99, 102, 241, 0.03);
}

.file-drop-zone p {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.shared-files-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shared-files-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-empty-state {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 2rem;
}

.file-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.file-info {
  flex: 1;
  overflow: hidden;
}

.file-name {
  font-size: 0.8rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.file-meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.file-download-link {
  color: var(--online-color);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
}

.file-download-link:hover {
  text-decoration: underline;
}

/* Модалки */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10100;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.info-table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
}

/* АДАПТИВНОСТЬ ДЛЯ ТЕЛЕФОНОВ */
@media (max-width: 768px) {
  header {
    padding: 1rem 1.25rem;
  }
  
  .container {
    padding: 1.5rem 1rem;
  }

  .auth-card, .card {
    padding: 1.5rem;
  }

  /* Разворачиваем дашборд в один столбец */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  /* Боковая шторка на весь экран для чата/файлов на мобильных */
  .session-side-panel {
    position: fixed;
    top: 73px;
    right: 0;
    width: 100vw;
    height: calc(100vh - 73px);
    border-left: none;
    transform: translateX(100%);
  }

  .session-side-panel.active {
    transform: translateX(0);
  }

  .session-toolbar {
    padding: 0.6rem 1rem;
  }

  .toolbar-brand {
    font-size: 0.85rem;
  }
}
