/* ==========================================================================
   Apple Design System for ТН-ГРУПП Survey 360
   Clean, Lightweight, Glassmorphism, Premium SF Pro Aesthetics
   ========================================================================== */

:root {
  --apple-bg: #f5f5f7;
  --apple-card: #ffffff;
  --apple-text-primary: #1d1d1f;
  --apple-text-secondary: #86868b;
  --apple-text-tertiary: #6e6e73;
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-light: rgba(0, 113, 227, 0.06);
  --apple-green: #34c759;
  --apple-green-bg: #f0fdf4;
  --apple-red: #ff3b30;
  --apple-red-bg: #fff1f2;
  --apple-orange: #ff9500;
  --apple-border: rgba(0, 0, 0, 0.08);
  --apple-border-light: rgba(0, 0, 0, 0.04);
  --apple-input-bg: #f5f5f7;
  --apple-input-focus-bg: #ffffff;
  
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 980px;

  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-elevated: 0 12px 32px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--apple-bg);
  color: var(--apple-text-primary);
  line-height: 1.47059;
  font-weight: 400;
  letter-spacing: -0.022em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Glassmorphism Navigation Bar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--apple-border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--apple-text-primary);
  letter-spacing: -0.015em;
}

.brand-title span.brand-bold {
  font-weight: 700;
  color: var(--apple-blue);
}

.brand-title span.brand-dot {
  color: var(--apple-text-secondary);
  margin: 0 6px;
  font-weight: 300;
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--apple-text-secondary);
}

.user-nav span {
  font-weight: 500;
  color: var(--apple-text-primary);
}

.brand-logo-link {
  transition: opacity 0.2s ease;
}

.brand-logo-link:hover {
  opacity: 0.8;
}

.nav-link-survey {
  color: var(--apple-text-primary);
  font-weight: 600;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.nav-link-survey:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--apple-blue);
}

.nav-link-admin {
  color: var(--apple-blue);
  font-weight: 600;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--apple-blue-light);
  transition: all 0.2s ease;
}

.nav-link-admin:hover {
  background: rgba(0, 113, 227, 0.12);
}

.btn-logout {
  background: rgba(0, 0, 0, 0.05);
  color: var(--apple-text-primary);
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(0, 0, 0, 0.1);
}

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

/* Apple Squircle Card */
.card {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  box-shadow: var(--shadow-subtle);
  border: 1px solid var(--apple-border-light);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Thin Apple Progress Bar */
.survey-progress-wrapper {
  margin-bottom: 24px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--apple-text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}

.progress-bar-bg {
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--apple-blue);
  border-radius: var(--radius-pill);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Typography & Form Controls */
h1, h2, h3 {
  letter-spacing: -0.025em;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--apple-text-primary);
  margin-bottom: 6px;
}

.section-description {
  font-size: 14px;
  color: var(--apple-text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.step-indicator-text {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--apple-blue);
  margin-bottom: 8px;
}

/* Apple Form Fields */
.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--apple-text-primary);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background-color: var(--apple-input-bg);
  color: var(--apple-text-primary);
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

.form-control:focus {
  background-color: var(--apple-input-focus-bg);
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 110px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2086868b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

/* Apple Radio and Checkbox Group */
.options-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--apple-input-bg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.option-item:hover {
  background: #e8e8ed;
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid #b0b0b5;
  border-radius: 50%;
  margin-right: 12px;
  outline: none;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  background: white;
}

.option-item input[type="checkbox"] {
  border-radius: 5px;
}

.option-item input[type="radio"]:checked,
.option-item input[type="checkbox"]:checked {
  background-color: var(--apple-blue);
  border-color: var(--apple-blue);
}

.option-item input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

.option-item input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 0px;
  left: 3px;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.option-item span {
  font-size: 14.5px;
  color: var(--apple-text-primary);
  font-weight: 450;
}

/* Explanation and Example Box (Apple Style Info Card) */
.question-explanation-box {
  background: var(--apple-blue-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 14px 0 24px 0;
  border: 1px solid rgba(0, 113, 227, 0.1);
}

.explanation-text {
  font-size: 13.5px;
  color: var(--apple-blue);
  line-height: 1.45;
  margin-bottom: 6px;
  font-weight: 500;
}

.example-text {
  font-size: 13px;
  color: var(--apple-text-secondary);
  background: rgba(255, 255, 255, 0.85);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  line-height: 1.4;
  margin-top: 6px;
}

/* Buttons System */
.btn-primary {
  background: var(--apple-blue);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.btn-primary:hover {
  background: var(--apple-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.35);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #e8e8ed;
  color: var(--apple-text-primary);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #dcdce0;
}

.btn-secondary:active {
  transform: scale(0.98);
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--apple-border-light);
}

/* Scale System */
.scale-group {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.scale-item {
  flex: 1;
  min-width: 44px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--apple-input-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--apple-text-primary);
  transition: all 0.2s ease;
  user-select: none;
}

.scale-item:hover, .scale-item.selected {
  background: var(--apple-blue);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Anonymous subtle indicator */
.anon-subtle-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--apple-text-secondary);
  background: rgba(0, 0, 0, 0.03);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}

/* Auth / Login Page */
.login-box {
  max-width: 400px;
  margin: 60px auto;
  text-align: center;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--apple-text-primary);
  margin-bottom: 8px;
}

.login-header p {
  font-size: 14px;
  color: var(--apple-text-secondary);
  margin-bottom: 28px;
}

/* Admin Dashboard Table (macOS System Settings Style) */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--apple-card);
  border: 1px solid var(--apple-border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-subtle);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--apple-text-primary);
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 12.5px;
  color: var(--apple-text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.data-table th, .data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--apple-border-light);
  font-size: 13.5px;
}

.data-table th {
  background: var(--apple-bg);
  font-weight: 600;
  color: var(--apple-text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.015);
}

/* Alert Boxes */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 20px;
  line-height: 1.4;
}

.alert-error {
  background: var(--apple-red-bg);
  color: var(--apple-red);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.alert-success {
  background: var(--apple-green-bg);
  color: #15803d;
  border: 1px solid rgba(52, 199, 89, 0.2);
}

/* Responsive */
@media (max-width: 640px) {
  .card {
    padding: 24px 20px;
    border-radius: var(--radius-md);
  }
  .app-header {
    padding: 12px 16px;
  }
  .main-content {
    margin: 20px auto;
  }
}

.menu-item-opt {
  transition: background 0.15s ease, transform 0.1s ease;
}

.menu-item-opt:hover {
  background: rgba(0, 113, 227, 0.08);
}

/* Character Quota Counter */
.char-quota-counter {
  font-size: 12px;
  color: var(--apple-text-secondary);
  text-align: right;
  margin-top: 4px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.char-quota-counter.quota-warning {
  color: var(--apple-orange);
  font-weight: 600;
}

.char-quota-counter.quota-exceeded {
  color: var(--apple-red);
  font-weight: 700;
}

