/* ==========================================================================
   CMG Auto Calculator - Mobile PWA Styles
   ========================================================================== */

:root {
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-sub: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --primary: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-gradient: linear-gradient(135deg, #1e40af, #2563eb);
  --success: #15803d;
  --success-bg: #f0fdf4;
  --accent: #d97706;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-bottom-bar: 0 -4px 12px rgba(0, 0, 0, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg-body: #090d16;
  --bg-card: #131b2e;
  --bg-card-sub: #1a243b;
  --bg-input: #101726;
  --border-color: #243049;
  --border-focus: #60a5fa;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #3b82f6;
  --primary-light: #1e293b;
  --primary-gradient: linear-gradient(135deg, #2563eb, #3b82f6);
  --success: #22c55e;
  --success-bg: #052e16;
  --accent: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-bottom-bar: 0 -4px 16px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(100px + var(--safe-bottom));
  transition: background-color 0.25s ease, color 0.25s ease;
}

.app-wrapper {
  max-width: 580px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 20px;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Language switch */
.lang-switcher {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* Theme toggle */
.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Cards */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Segmented Control (Auction, Port) - Высокий контраст */
.segmented-control {
  display: flex;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 6px;
  margin-bottom: 14px;
}

.segmented-option {
  flex: 1;
  text-align: center;
  cursor: pointer;
}

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

.segmented-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.segmented-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 2px;
  transition: color 0.2s ease;
}

/* Активное состояние в светлой теме */
.segmented-option input[type="radio"]:checked + .segmented-label {
  background: #ffffff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.12);
}

.segmented-option input[type="radio"]:checked + .segmented-label .segmented-sub {
  color: #2563eb;
}

/* Активное состояние в тёмной теме - четкий яркий контраст */
[data-theme="dark"] .segmented-control {
  background: #0d1424;
  border-color: #1e293b;
}

[data-theme="dark"] .segmented-label {
  color: #94a3b8;
}

[data-theme="dark"] .segmented-label .segmented-sub {
  color: #64748b;
}

[data-theme="dark"] .segmented-option input[type="radio"]:checked + .segmented-label {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.45);
}

[data-theme="dark"] .segmented-option input[type="radio"]:checked + .segmented-label .segmented-sub {
  color: #e0f2fe;
  font-weight: 500;
}

/* Контрастные кнопки языков в темной теме */
[data-theme="dark"] .lang-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.5);
}

/* Контрастные тоглы переключателей */
[data-theme="dark"] input:checked + .slider {
  background-color: #2563eb;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

/* Form Elements */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

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

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix,
.input-suffix {
  position: absolute;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  pointer-events: none;
}

.input-prefix { left: 14px; }
.input-suffix { right: 14px; }

.form-input,
.form-select {
  width: 100%;
  height: 46px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  color: var(--text-main);
  padding: 0 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.form-input.has-prefix { padding-left: 32px; }
.form-input.has-suffix { padding-right: 32px; }

.form-input:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Checkbox and Toggle Row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.toggle-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.toggle-info {
  flex: 1;
  padding-right: 12px;
}

.toggle-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.toggle-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Custom switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-color);
  transition: 0.25s;
  border-radius: var(--radius-full);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

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

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

/* Notice box */
.info-box {
  background: var(--bg-card-sub);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Sticky Bottom Bar */
.sticky-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  box-shadow: var(--shadow-bottom-bar);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  z-index: 50;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.bottom-bar-inner {
  max-width: 580px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.price-summary {
  display: flex;
  flex-direction: column;
}

.price-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.price-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.price-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.actions-group {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

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

.btn-outline {
  background: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-outline:active {
  background: var(--border-color);
}

/* Modal Window */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card-sub);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-group {
  margin-bottom: 18px;
}

.detail-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
}

.detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.detail-label {
  color: var(--text-muted);
}

.detail-val {
  font-weight: 600;
  color: var(--text-main);
}

.detail-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  border-top: 2px solid var(--border-color);
  margin-top: 8px;
}

.modal-footer {
  padding: 16px 20px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}

.contact-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card-sub);
  text-decoration: none;
  color: var(--text-main);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.contact-card:hover, .contact-card:active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.contact-card svg {
  width: 28px;
  height: 28px;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-content {
    border-radius: 20px;
    max-height: 80vh;
  }
}


.brand-logo-img {
  height: 38px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
}

[data-theme="dark"] .brand-logo-img {
  filter: drop-shadow(0 0 8px rgba(220, 38, 38, 0.4)) brightness(1.08);
}


.brand-header-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dragon-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
}

.brand-text-col {
  display: flex;
  flex-direction: column;
}

.brand-main-title {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.brand-main-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

[data-theme="dark"] .brand-dragon-icon {
  filter: drop-shadow(0 0 8px rgba(220, 38, 38, 0.5)) brightness(1.1);
}


/* Contact Cards Redesign */
.contact-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card-sub);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-card:active {
  transform: scale(0.97);
}

.contact-icon-badge {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.contact-icon-badge svg {
  width: 24px;
  height: 24px;
}

.tg-badge {
  background: rgba(34, 158, 217, 0.12);
  color: #229ed9;
  border: 1px solid rgba(34, 158, 217, 0.25);
}

.phone-badge {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

[data-theme="dark"] .tg-badge {
  background: rgba(34, 158, 217, 0.2);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 14px rgba(34, 158, 217, 0.2);
}

[data-theme="dark"] .phone-badge {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.2);
}

.contact-card-val {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.2px;
  word-break: break-all;
}

.contact-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
