/* ============================================
   AdministrationBots — Apple Premium Design System
   iOS / macOS unified UI/UX
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Colors - MacOS / iOS Dark Theme basis */
  --bg-primary: #000000;
  --bg-secondary: #121212;
  --surface-primary: rgba(28, 28, 30, 0.7);
  --surface-secondary: rgba(44, 44, 46, 0.7);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.3);

  /* Accents */
  --accent-blue: #0A84FF;
  --accent-blue-active: #409CFF;
  --success: #32D74B;
  --danger: #FF453A;
  --warning: #FF9F0A;
  --gold: #FFD60A;

  /* Vibrancy */
  --vibrancy: blur(40px) saturate(200%);
  --vibrancy-heavy: blur(60px) saturate(220%);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.05);
  /* Apple spring feel */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --speed-fast: 150ms;
  --speed-base: 250ms;
  --speed-slow: 400ms;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Base interactive elements */
button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

/* ---------- Screens & Transitions ---------- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100dvh;
  padding-bottom: 40px;
  /* Safe area padding */
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px);
  transition: opacity var(--speed-base) var(--ease),
    transform var(--speed-base) var(--ease),
    visibility var(--speed-base);
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  z-index: 10;
  position: relative;
  /* Take up normal flow */
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  margin-top: 32px;
}

/* ---------- Header (Navigation) ---------- */
.ios-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface-primary);
  backdrop-filter: var(--vibrancy);
  -webkit-backdrop-filter: var(--vibrancy);
  border-bottom: 0.5px solid var(--border-subtle);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
}

/* Added safe-area padding for top notch on iOS devices */
@supports (padding-top: env(safe-area-inset-top)) {
  .ios-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  flex: 1;
}

.header-right {
  justify-content: flex-end;
  gap: 12px;
}

.header-center {
  text-align: center;
  flex: 2;
  font-weight: 600;
  font-size: 17px;
}

/* Back button in header */
.header-back-btn {
  color: var(--accent-blue);
  background: transparent;
  border: none;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity var(--speed-fast);
}

.header-back-btn:active {
  opacity: 0.6;
}

.header-back-btn::before {
  content: "‹";
  font-size: 26px;
  line-height: 1;
  font-weight: 400;
  position: relative;
  top: -1px;
}

/* ---------- Login Screen ---------- */
#login-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, rgba(10, 132, 255, 0.15), transparent 40%),
    radial-gradient(circle at bottom left, rgba(50, 215, 75, 0.1), transparent 40%);
}

.login-box {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo .icon {
  font-size: 54px;
  margin-bottom: 16px;
  display: inline-block;
  background: linear-gradient(135deg, #0A84FF, #5E5CE6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 12px rgba(10, 132, 255, 0.3));
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 8px;
}

.login-form-group {
  margin-bottom: 16px;
}

/* Common wrapper for inputs that looks like iOS grouped table */
.ios-input-group {
  background: var(--surface-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 0.5px solid var(--border-subtle);
  margin-bottom: 24px;
}

.ios-input-group input,
.ios-input-group select,
.ios-input-group textarea {
  width: 100%;
  background: transparent;
  border: none;
  padding: 16px;
  font-size: 17px;
  outline: none;
  color: var(--text-primary);
}

.ios-input-group input::placeholder,
.ios-input-group textarea::placeholder {
  color: var(--text-tertiary);
}

/* Separator between inputs in grouped style */
.ios-input-group .divider {
  height: 0.5px;
  background: var(--border-subtle);
  margin-left: 16px;
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  min-height: 20px;
  margin-bottom: 16px;
  font-weight: 500;
}

/* ---------- Forms & Inputs Standard ---------- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
  margin-left: 16px;
  letter-spacing: 0.02em;
}

/* Independent modern input */
.form-input {
  width: 100%;
  background: var(--surface-primary);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 17px;
  transition: border-color var(--speed-fast), background var(--speed-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-blue);
  background: var(--surface-secondary);
}

/* Segmented Control iOS Style */
.segmented-control {
  display: flex;
  background: var(--surface-secondary);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin: 16px 0 24px;
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control label {
  flex: 1;
  text-align: center;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--speed-fast);
}

.segmented-control input[type="radio"]:not(:checked)+label {
  color: var(--text-secondary);
}

.segmented-control input[type="radio"]:checked+label {
  background: rgba(255, 255, 255, 0.15);
  /* Gives that slider look */
  box-shadow: var(--shadow-sm);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 17px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--speed-fast);
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

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

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

.btn-primary:active {
  background: var(--accent-blue-active);
}

.btn-ghost {
  background: transparent;
  color: var(--accent-blue);
}

.btn-ghost:hover {
  background: rgba(10, 132, 255, 0.1);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

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

.btn-danger-filled {
  background: var(--danger);
  color: white;
}

.btn-success-filled {
  background: var(--success);
  color: white;
}

/* Loading spinner */
.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn.loading .spinner {
  display: block;
}

.btn.loading .btn-text {
  display: none;
}

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

/* ---------- Main Container ---------- */
.main-content {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Top Stats Card / Hero area */
.hero-card {
  background: var(--surface-primary);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 24px;
  border: 0.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.hero-stat-value {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.hero-stat-label {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------- Bot Cards (List) ---------- */
.bot-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bot-card {
  background: var(--surface-primary);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background var(--speed-fast) var(--ease), transform var(--speed-fast) var(--spring);
}

.bot-card:active {
  background: var(--surface-secondary);
  transform: scale(0.98);
}

.bot-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.bot-avatar {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}

/* Avatars Gradients */
.gradient-1 {
  background: linear-gradient(135deg, #0A84FF, #5E5CE6);
}

.gradient-2 {
  background: linear-gradient(135deg, #FF2D55, #FF375F);
}

.gradient-3 {
  background: linear-gradient(135deg, #32D74B, #30D158);
}

.gradient-4 {
  background: linear-gradient(135deg, #FF9F0A, #FF3B30);
}

.gradient-5 {
  background: linear-gradient(135deg, #64D2FF, #0A84FF);
}

.bot-name {
  font-weight: 600;
  font-size: 17px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

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

.bot-status-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-green {
  background: rgba(50, 215, 75, 0.15);
  color: var(--success);
}

.badge-red {
  background: rgba(255, 69, 58, 0.15);
  color: var(--danger);
}

.badge-blue {
  background: rgba(10, 132, 255, 0.15);
  color: var(--accent-blue);
}

.badge-gold {
  background: rgba(255, 214, 10, 0.15);
  color: var(--gold);
}

/* Chevron for list items (iOS style) */
.bot-card-chevron {
  color: var(--text-tertiary);
  font-size: 20px;
  margin-left: 12px;
  font-weight: 400;
}

/* Empty View */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  font-size: 54px;
  margin-bottom: 20px;
  color: var(--text-tertiary);
}

.empty-state h4 {
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Stats Grid for details ---------- */
.details-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.details-stat-card {
  background: var(--surface-primary);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
}

.details-stat-card.clickable {
  cursor: pointer;
  transition: transform var(--speed-fast), background var(--speed-fast);
}

.details-stat-card.clickable:active {
  transform: scale(0.95);
  background: var(--surface-secondary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Bot Settings Form / iOS Cards ---------- */
.ios-card {
  background: var(--surface-primary);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-subtle);
  padding: 20px;
  margin-bottom: 24px;
}

/* Custom file upload styling */
.photo-upload-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Data Tables ---------- */
.users-table-container {
  background: var(--surface-primary);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-subtle);
  overflow: hidden;
  margin-top: 16px;
}

.users-table-container table {
  width: 100%;
  border-collapse: collapse;
}

.users-table-container th {
  padding: 12px 16px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 0.5px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
}

.users-table-container td {
  padding: 16px;
  font-size: 15px;
  border-bottom: 0.5px solid var(--border-subtle);
  color: var(--text-primary);
}

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

/* ---------- Modals (Action Sheets) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: var(--vibrancy);
  -webkit-backdrop-filter: var(--vibrancy);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  /* Bottom sheet by default */
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity var(--speed-base);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--surface-secondary);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--speed-base) var(--spring);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 5px;
  background: var(--text-tertiary);
  border-radius: 3px;
  margin: 0 auto 24px;
}

.modal-content h3 {
  font-size: 22px;
  margin-bottom: 24px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.modal-actions .btn {
  flex: 1;
}

/* Modals on Desktop - center alert style */
@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }

  .modal-content {
    border-radius: var(--radius-xl);
    transform: scale(0.95);
    opacity: 0;
  }

  .modal-overlay.active .modal-content {
    transform: scale(1);
    opacity: 1;
  }

  .modal-handle {
    display: none;
    /* Hide drag handle on desktop */
  }
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  background: rgba(30, 30, 30, 0.9);
  backdrop-filter: var(--vibrancy);
  -webkit-backdrop-filter: var(--vibrancy);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastSlideDown var(--speed-base) var(--spring) forwards;
  max-width: 340px;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.toast.success::before {
  background: var(--success);
}

.toast.error::before {
  background: var(--danger);
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}