/* ==========================================================================
   iOS System Design Tokens & Theme
   ========================================================================== */
:root {
  --ios-bg: #000000;
  --ios-grouped-bg: #000000;
  --ios-card-bg: #1c1c1e;
  --ios-card-hover: #2c2c2e;
  --ios-card-active: #3a3a3c;
  --ios-separator: rgba(255, 255, 255, 0.12);
  --ios-text-primary: #ffffff;
  --ios-text-secondary: #8e8e93;
  --ios-text-tertiary: #636366;
  --ios-blue: #0a84ff;
  --ios-green: #30d158;
  --ios-orange: #ff9f0a;
  --ios-purple: #bf5af2;
  --ios-red: #ff453a;
  --ios-teal: #64d2ff;
  --ios-search-bg: #1c1c1e;
  --ios-radius: 14px;
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ios-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"], :root[data-theme="light"] {
    --ios-bg: #f2f2f7;
    --ios-grouped-bg: #f2f2f7;
    --ios-card-bg: #ffffff;
    --ios-card-hover: #f7f7f9;
    --ios-card-active: #e5e5ea;
    --ios-separator: rgba(60, 60, 67, 0.18);
    --ios-text-primary: #000000;
    --ios-text-secondary: #8e8e93;
    --ios-text-tertiary: #aeaeb2;
    --ios-blue: #007aff;
    --ios-green: #34c759;
    --ios-orange: #ff9500;
    --ios-purple: #af52de;
    --ios-red: #ff3b30;
    --ios-teal: #30b0c7;
    --ios-search-bg: #e3e3e8;
    --ios-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  }
}

:root[data-theme="dark"] {
  --ios-bg: #000000;
  --ios-grouped-bg: #000000;
  --ios-card-bg: #1c1c1e;
  --ios-card-hover: #2c2c2e;
  --ios-card-active: #3a3a3c;
  --ios-separator: rgba(255, 255, 255, 0.12);
  --ios-text-primary: #ffffff;
  --ios-text-secondary: #8e8e93;
  --ios-text-tertiary: #636366;
  --ios-blue: #0a84ff;
  --ios-green: #30d158;
  --ios-orange: #ff9f0a;
  --ios-purple: #bf5af2;
  --ios-red: #ff453a;
  --ios-teal: #64d2ff;
  --ios-search-bg: #1c1c1e;
  --ios-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--ios-font);
  background-color: var(--ios-bg);
  color: var(--ios-text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
  width: 100%;
  max-width: 580px;
}

/* ==========================================================================
   Header & Profile Area (iOS Style)
   ========================================================================== */
.header-area {
  margin-bottom: 20px;
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background-color 0.15s, opacity 0.15s;
}

.nav-btn:hover {
  background-color: rgba(10, 132, 255, 0.12);
}

.page-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--ios-text-secondary);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Search Bar (iOS Inset Style)
   ========================================================================== */
.search-wrapper {
  margin: 16px 0 20px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: var(--ios-text-secondary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--ios-search-bg);
  border: none;
  border-radius: 10px;
  padding: 9px 36px 9px 36px;
  font-size: 16px;
  color: var(--ios-text-primary);
  font-family: inherit;
  outline: none;
  transition: background-color 0.2s;
}

.search-input::placeholder {
  color: var(--ios-text-secondary);
}

.search-input:focus {
  box-shadow: 0 0 0 2px var(--ios-blue);
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ios-text-tertiary);
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--ios-card-bg);
  font-size: 10px;
  cursor: pointer;
}

/* ==========================================================================
   Inset Grouped Section
   ========================================================================== */
.section-header {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: -0.1px;
  color: var(--ios-text-secondary);
  margin: 22px 14px 8px;
}

.grouped-card {
  background: var(--ios-card-bg);
  border-radius: var(--ios-radius);
  overflow: hidden;
  box-shadow: var(--ios-shadow);
}

.card-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background-color 0.15s ease;
  user-select: none;
}

.card-item:hover {
  background-color: var(--ios-card-hover);
}

.card-item:active {
  background-color: var(--ios-card-active);
}

.card-item:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 64px;
  right: 0;
  height: 0.5px;
  background-color: var(--ios-separator);
}

/* ==========================================================================
   Squircle Icons & Content
   ========================================================================== */
.squircle-icon {
  width: 36px;
  height: 36px;
  border-radius: 22.37%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  margin-right: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.squircle-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-title {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-desc {
  font-size: 13px;
  color: var(--ios-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  flex-shrink: 0;
}

/* ==========================================================================
   Badges, Status Dots & Chevrons
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--ios-green);
  box-shadow: 0 0 8px rgba(48, 209, 88, 0.7);
}

.status-dot.offline {
  background-color: var(--ios-red);
}

.status-dot.checking {
  background-color: var(--ios-orange);
  animation: pulse 1.4s infinite ease-in-out;
}

.status-dot.disabled {
  background-color: var(--ios-text-tertiary);
}

.chevron-icon {
  width: 8px;
  height: 14px;
  fill: var(--ios-text-tertiary);
  opacity: 0.6;
}

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

/* ==========================================================================
   iOS Toggle Switch
   ========================================================================== */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(120, 120, 128, 0.32);
  transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  border-radius: 34px;
}

.ios-slider:before {
  position: absolute;
  content: "";
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

input:checked + .ios-slider {
  background-color: var(--ios-green);
}

input:checked + .ios-slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   Modal Dialog (iOS Sheet / Popup)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--ios-card-bg);
  border-radius: 18px;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.3, 1.2, 0.5, 1);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 0.5px solid var(--ios-separator);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  color: var(--ios-text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  background: var(--ios-search-bg);
  border: 1px solid var(--ios-separator);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--ios-text-primary);
  font-family: inherit;
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--ios-blue);
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 14px 20px 20px;
}

.btn-primary {
  flex: 1;
  background: var(--ios-blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-secondary {
  flex: 1;
  background: rgba(120, 120, 128, 0.2);
  color: var(--ios-text-primary);
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.btn-danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--ios-red);
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer-info {
  text-align: center;
  margin-top: 36px;
  font-size: 12px;
  color: var(--ios-text-tertiary);
  line-height: 1.6;
}

.footer-info a {
  color: var(--ios-blue);
  text-decoration: none;
}
