/* ==========================================
   WAITERPRO CALCULATOR V4 - SIMPLIFIED
   ========================================== */

:root {
  /* iOS Dark Colors */
  --bg: #000000;
  --surface-1: #1C1C1E;
  --surface-2: #2C2C2E;
  --surface-3: #3A3A3C;
  
  --text-primary: #F2F2F7;
  --text-secondary: #AEAEB2;
  --text-tertiary: #8E8E93;
  
  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --accent-subtle: rgba(10, 132, 255, 0.15);
  
  --success: #32D74B;
  --border: rgba(255, 255, 255, 0.12);
  --divider: rgba(255, 255, 255, 0.08);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --font-base: 15px;
  --font-sm: 13px;
  --font-lg: 17px;
}

[data-theme="light"] {
  --bg: #F2F2F7;
  --surface-1: #FFFFFF;
  --surface-2: #F9F9F9;
  --surface-3: #E5E5EA;
  
  --text-primary: #000000;
  --text-secondary: #3C3C43;
  --text-tertiary: #8E8E93;
  
  --accent: #007AFF;
  --accent-hover: #0051D5;
  --accent-subtle: rgba(0, 122, 255, 0.1);
  
  --border: rgba(0, 0, 0, 0.12);
  --divider: rgba(0, 0, 0, 0.08);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: var(--font-base);
  line-height: 1.6;
  background: var(--bg);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: #FFF;
}

.brand-title {
  font-weight: 700;
  font-size: var(--font-lg);
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* === TABS === */
.tabs {
  display: flex;
  gap: 8px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-md);
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--surface-3);
}

.tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.3);
}

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

@media (max-width: 640px) {
  .tab-label {
    display: none;
  }
  .tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

/* Theme Toggle */
.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.theme-toggle:hover {
  background: var(--surface-3);
}

.theme-toggle svg {
  color: var(--text-primary);
  transition: opacity 0.3s ease;
  position: absolute;
}

.sun-icon { opacity: 0; }
.moon-icon { opacity: 1; }

[data-theme="light"] .sun-icon { opacity: 1; }
[data-theme="light"] .moon-icon { opacity: 0; }

/* === TAB CONTENT === */
.content {
  margin-top: 20px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

/* === WIZARD === */
.wizard-container {
  max-width: 900px;
  margin: 0 auto;
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.wizard-step {
  animation: slideIn 0.4s ease;
}

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

.wizard-title {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 32px;
  color: var(--text-primary);
}

.wizard-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.wizard-option {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.wizard-option:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.wizard-option.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.1);
}

.wizard-option-icon {
  font-size: 56px;
}

.wizard-option-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.wizard-option-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.wizard-goals {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.wizard-goal {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.wizard-goal:hover {
  border-color: var(--accent);
}

.wizard-goal input {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

.wizard-goal-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.wizard-goal-icon {
  font-size: 36px;
}

.wizard-goal-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.wizard-goal-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.wizard-result {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.wizard-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.wizard-result-item:last-child {
  border-bottom: none;
}

.wizard-result-name {
  font-weight: 600;
  color: var(--text-primary);
}

.wizard-result-price {
  color: var(--text-secondary);
}

.wizard-apply-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wizard-apply-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.3);
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.wizard-btn {
  flex: 1;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.wizard-btn-back {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.wizard-btn-next {
  background: var(--accent);
  color: white;
}

.wizard-btn:hover {
  transform: translateY(-1px);
}

/* === CALCULATOR === */
.calculator-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
}

@media (max-width: 1024px) {
  .calculator-layout {
    grid-template-columns: 1fr;
  }
  
  /* На мобилке корзина внизу, но не fixed */
  .cart-section {
    order: 2;
  }
  
  .modules-section {
    order: 1;
  }
  
  .cart {
    position: relative;
    top: auto;
    margin-top: 20px;
  }
}

/* Licenses Control */
.licenses-control {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.license-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.license-label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.license-input-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.license-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.license-btn:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}

.license-btn:active {
  transform: scale(0.95);
}

.license-input-group input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-lg);
  font-weight: 600;
  text-align: center;
  outline: none;
}

/* Hide number input arrows */
.license-input-group input::-webkit-inner-spin-button,
.license-input-group input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.license-input-group input[type="number"] {
  -moz-appearance: textfield;
}

.license-input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
}

/* Modules Table */
.modules-section {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.table-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.table-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.module-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.module-row::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.module-row:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}

.module-row.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.1);
}

.module-row.active::before {
  opacity: 0.05;
}

.module-info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.module-name {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  transition: color 0.2s ease;
}

.module-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

.module-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.module-tag {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: all 0.2s ease;
}

.module-row:hover .module-tag {
  background: var(--accent);
  color: white;
}

.module-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  position: relative;
  z-index: 1;
  min-width: 100px;
  text-align: right;
  transition: all 0.3s ease;
}

.module-row.active .module-price {
  transform: scale(1.1);
}

.module-row.required {
  opacity: 0.85;
  cursor: not-allowed !important;
  background: var(--surface-2);
}

.module-row.required:hover {
  transform: none !important;
  border-color: var(--border) !important;
}

.required-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 8px;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Cart */
.cart {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 20px;
}

.cart-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.cart-item {
  margin-bottom: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.cart-item-name {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cart-item-calc {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.cart-multiply,
.cart-equals {
  color: var(--text-tertiary);
  font-size: var(--font-sm);
}

.cart-total {
  color: var(--accent);
  font-weight: 700;
  transition: all 0.3s ease;
}

/* Number animation */
@keyframes numberChange {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); color: var(--success); }
}

.cart-total.animating {
  animation: numberChange 0.6s ease;
}

.cart-divider {
  height: 1px;
  background: var(--divider);
  margin: 20px 0;
}

.cart-period {
  margin-bottom: 16px;
}

.cart-period-label {
  display: block;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cart-period-select {
  width: 100%;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-base);
  cursor: pointer;
  outline: none;
}

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

.cart-discount {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(50, 215, 75, 0.1), rgba(50, 215, 75, 0.05));
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  animation: slideDown 0.4s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.cart-discount-label {
  font-size: var(--font-sm);
  color: var(--success);
  font-weight: 700;
  margin-bottom: 2px;
}

.cart-discount-details {
  font-size: 10px;
  color: var(--success);
  opacity: 0.85;
  line-height: 1.2;
}

.cart-discount-value {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
  flex-shrink: 0;
}

.cart-total-section {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.cart-total-row.cart-total-grand {
  padding-top: 12px;
  border-top: 2px solid var(--accent);
  margin-top: 8px;
}

.cart-total-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 600;
}

.cart-total-grand .cart-total-label {
  font-size: var(--font-lg);
  color: var(--accent);
  font-weight: 700;
}

.cart-total-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.cart-total-number {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.4s ease;
}

.cart-total-grand .cart-total-number {
  font-size: 28px;
  color: var(--accent);
}

.cart-total-number.animating {
  animation: numberChange 0.6s ease;
}

.cart-total-details {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
  text-align: center;
}

.cart-period-text {
  font-size: var(--font-sm);
  opacity: 0.9;
}

.cart-save-btn {
  width: 100%;
  margin-top: 20px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cart-save-btn:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Flying animation for price */
@keyframes flyToCart {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  50% {
    opacity: 0.5;
    transform: translate(100px, -50px) scale(0.5);
  }
  100% {
    opacity: 0;
    transform: translate(200px, -100px) scale(0.2);
  }
}

.price-fly {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  font-size: 24px;
  font-weight: 700;
  color: var(--success);
  animation: flyToCart 0.8s ease-out forwards;
}