/* /opt/skynet-portal/app/static/css/components.css */
/* v0.1.0 — UI-компоненты SKYNET PORTAL (glassmorphism, премиум) */
/* 30.05.2026: кнопки, поля, карточки, чипы, бейджи, таблицы, модалки, тосты */

/* =====================================================================
   1. КНОПКИ
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: var(--border-thin) solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Основная (акцентный градиент) --- */
.btn-primary {
  background: var(--gradient-accent);
  color: var(--text-on-accent);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--gradient-accent-hover);
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* --- Вторичная (стекло) --- */
.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
}

/* --- Призрачная (только текст) --- */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* --- Контурная (рамка-акцент) --- */
.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--border-accent);
}
.btn-outline:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* --- Семантические --- */
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-warning { background: var(--warning); color: #1a1408; }
.btn-warning:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* --- Размеры --- */
.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: var(--fs-base); }
.btn-block { display: flex; width: 100%; }

/* --- Иконочная кнопка (квадрат) --- */
.btn-icon {
  padding: var(--sp-2);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
}
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn-icon.btn-lg { width: 48px; height: 48px; }

/* Эффект блика при наведении на primary */
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
}
.btn-primary:hover::after {
  transform: translateX(100%);
}

/* =====================================================================
   2. ПОЛЯ ВВОДА
   ===================================================================== */
.input,
.textarea,
.select {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--bg-input);
  border: var(--border-base) solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-surface);
}

.input:disabled,
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: var(--lh-snug);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-10);
  cursor: pointer;
}

/* --- Поле с иконкой --- */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input-icon {
  position: absolute;
  left: var(--sp-4);
  display: flex;
  align-items: center;
  pointer-events: none;
  color: var(--text-muted);
}
.input-group .input-icon svg {
  width: 18px;
  height: 18px;
}
.input-group .input {
  padding-left: calc(var(--sp-4) + 26px);
}
.input-group:focus-within .input-icon {
  color: var(--accent);
}

/* --- Лейбл поля --- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.field-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.field-error {
  font-size: var(--fs-xs);
  color: var(--danger-text);
}
.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select {
  border-color: var(--danger);
}
.field.has-error .input:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* =====================================================================
   3. КАРТОЧКИ (glassmorphism)
   ===================================================================== */
.card {
  background: var(--bg-surface);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.card-glass {
  background: color-mix(in srgb, var(--bg-surface) 65%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: var(--border-thin) solid var(--border-subtle);
}
.card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.card-title svg { width: 20px; height: 20px; color: var(--accent); }
.card-body { padding: var(--sp-6); }
.card-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: var(--border-thin) solid var(--border-subtle);
  background: var(--bg-surface-2);
}

/* Карточка с акцентной полосой сверху (как на твоих скринах) */
.card-accent-top {
  position: relative;
}
.card-accent-top::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-glow);
}

/* =====================================================================
   4. СТАТ-КАРТОЧКА (метрика с иконкой — как дашборд SMS-CENTRE)
   ===================================================================== */
.stat-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--bg-surface);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
}
.stat-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.success { background: var(--success-soft); color: var(--success-text); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning-text); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger-text); }
.stat-icon.info { background: var(--info-soft); color: var(--info-text); }
.stat-content { display: flex; flex-direction: column; gap: 2px; }
.stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* =====================================================================
   5. ЧИПЫ / БЕЙДЖИ (статусы)
   ===================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }

.badge-accent { background: var(--accent-soft); color: var(--accent-hover); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-neutral { background: var(--bg-surface-3); color: var(--text-secondary); }

/* Бейдж с точкой-индикатором (online/offline) */
.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

/* Пульсирующая точка (live-индикатор) */
.dot-pulse {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--success);
}
.dot-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--success);
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
  75%, 100% { transform: scale(2.5); opacity: 0; }
}

/* =====================================================================
   6. ПЕРЕКЛЮЧАТЕЛЬ (toggle switch)
   ===================================================================== */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--bg-surface-3);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
}
.switch input:checked + .switch-slider {
  background: var(--gradient-accent);
  border-color: transparent;
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* =====================================================================
   7. ТАБЛИЦЫ (премиум, для списков абонентов/платежей)
   ===================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: var(--border-thin) solid var(--border-default);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table thead th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg-surface-2);
  border-bottom: var(--border-thin) solid var(--border-default);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--sp-4);
  color: var(--text-secondary);
  border-bottom: var(--border-thin) solid var(--border-subtle);
}
.table tbody tr {
  transition: background var(--transition-fast);
}
.table tbody tr:hover {
  background: var(--bg-hover);
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table .num {
  text-align: right;
  color: var(--text-primary);
}

/* =====================================================================
   8. МОДАЛЬНЫЕ ОКНА
   ===================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in var(--transition-base);
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  animation: scale-in var(--transition-spring);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: var(--border-thin) solid var(--border-subtle);
}
.modal-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.modal-body { padding: var(--sp-6); }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: var(--border-thin) solid var(--border-subtle);
}

/* =====================================================================
   9. ТОСТЫ (уведомления)
   ===================================================================== */
.toast-container {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-elevated);
  border: var(--border-thin) solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slide-in-right var(--transition-slow);
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 18px; height: 18px; }
.toast.success .toast-icon { color: var(--success-text); }
.toast.warning .toast-icon { color: var(--warning-text); }
.toast.danger .toast-icon { color: var(--danger-text); }
.toast-content { flex: 1; }
.toast-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-primary); }
.toast-message { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }

/* =====================================================================
   10. ЛОАДЕРЫ
   ===================================================================== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }

/* Скелетон (заглушка при загрузке) */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-2) 0%,
    var(--bg-surface-3) 50%,
    var(--bg-surface-2) 100%
  );
  background-size: 2000px 100%;
  animation: shimmer 2s linear infinite;
  border-radius: var(--radius-sm);
}

/* =====================================================================
   11. РАЗДЕЛИТЕЛИ И ПРОЧЕЕ
   ===================================================================== */
.divider {
  height: var(--border-thin);
  background: var(--border-subtle);
  border: none;
  margin: var(--sp-4) 0;
}
.divider-vertical {
  width: var(--border-thin);
  background: var(--border-subtle);
  align-self: stretch;
}

/* Аватар */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
  color: #fff;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
