/* ============================================
   PEPS ADMIN — Mini App Telegram
   Thème sombre, mobile-first, vanilla CSS
   ============================================ */

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

:root {
  --bg-primary: #1a1a2e;
  --bg-surface: #16213e;
  --bg-elevated: #0f3460;
  --accent: #e94560;
  --accent-secondary: #0f9b8e;
  --accent-warning: #f0a500;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0b0;
  --text-disabled: #666680;
  --border: #2a2a4a;
  --success: #2ecc71;
  --error: #e74c3c;
  --shadow: rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --header-height: 52px;
  --tabbar-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* --- Layout --- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.sticky-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 16px;
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-primary));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.sticky-header h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-tab-bar {
  display: flex;
  height: var(--tabbar-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s;
  font-family: var(--font);
}

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

.tab-icon {
  font-size: 20px;
}

/* --- Splash --- */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  gap: 16px;
}

.splash-logo {
  font-size: 64px;
  animation: pulse 1.5s ease-in-out infinite;
}

.splash-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 2px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* --- Cards --- */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.1s;
}

.card:active {
  transform: scale(0.98);
}

.card-title {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-sub {
  font-size: 12px;
  color: var(--accent-secondary);
  margin-top: 4px;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

/* --- Group selector --- */
.group-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.group-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.group-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Member list --- */
.search-bar {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  font-family: var(--font);
}

.search-bar::placeholder {
  color: var(--text-disabled);
}

.search-bar:focus {
  border-color: var(--accent);
}

.member-list {
  list-style: none;
}

.member-row {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  background: var(--bg-surface);
  gap: 12px;
  min-height: 56px;
  cursor: pointer;
  transition: background 0.15s;
}

.member-row:active {
  background: var(--bg-elevated);
}

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-username {
  font-size: 13px;
  color: var(--text-secondary);
}

.member-actions-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-admin { background: var(--accent-secondary); color: #fff; }
.badge-owner { background: var(--accent); color: #fff; }
.badge-restricted { background: var(--accent-warning); color: #000; }
.badge-banned { background: var(--error); color: #fff; }

/* --- Logs --- */
.log-entry {
  padding: 12px;
  border-left: 3px solid var(--border);
  margin-bottom: 8px;
  background: var(--bg-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.log-entry.kick { border-color: var(--accent-warning); }
.log-entry.ban { border-color: var(--error); }
.log-entry.promote { border-color: var(--accent-secondary); }
.log-entry.restrict { border-color: var(--accent-warning); }

.log-time {
  font-size: 12px;
  color: var(--text-disabled);
  margin-bottom: 4px;
}

.log-actor {
  font-weight: 600;
  color: var(--accent);
}

/* --- Settings --- */
.settings-group {
  margin-bottom: 20px;
}

.settings-group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-disabled);
  margin-bottom: 10px;
  padding-left: 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  min-height: 52px;
}

.setting-label {
  font-size: 15px;
  font-weight: 500;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: #fff;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  font-family: var(--font);
  min-height: 44px;
  min-width: 44px;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

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

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  min-height: 36px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  animation: scaleIn 0.2s;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-height) + 16px);
  left: 16px;
  right: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  text-align: center;
  z-index: 200;
  box-shadow: 0 4px 16px var(--shadow);
  animation: slideUp 0.3s;
  border-left: 3px solid var(--accent-secondary);
}

.toast.error {
  border-color: var(--error);
}

.toast.success {
  border-color: var(--success);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-disabled);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 15px;
}

/* --- Skeleton --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Login screen --- */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  text-align: center;
  gap: 20px;
}

.login-screen .splash-logo {
  font-size: 64px;
  animation: none;
}

.login-error {
  color: var(--error);
  font-size: 14px;
  margin-top: 8px;
}

/* --- Select --- */
.select-inline {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}

.select-inline:focus {
  border-color: var(--accent);
}

/* --- Text input in settings --- */
.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 14px;
  margin-top: 8px;
  font-family: var(--font);
  outline: none;
}

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

/* --- Filter bar --- */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}

.filter-chip.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent);
}
