/* public/assets/ui.css */
/* =========================================================
   UI CORE — базовые переменные + типографика + контейнер
   + формы + утилиты + базовые компоненты (btn/card/alerts)
   ========================================================= */

/* =========================================================
   PWA/TWA FIX: стабилизация шрифтов в Android Chrome/WebView
   Включается только если в URL есть ?source=pwa
   ========================================================= */

html.is-pwa{
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 16px !important; /* фикс rem */
}

html.is-pwa body{
  font-size: 1rem;
  line-height: 1.35;
}

@media (max-width: 700px){
  html.is-pwa .page-title{ font-size: 1.35rem !important; }
  html.is-pwa h1{ font-size: 1.5rem !important; }
  html.is-pwa h2{ font-size: 1.25rem !important; }
}

/* --- Theme tokens + UI tokens --- */
:root{
  --theme-color: #0088cc;

  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;

  --radius: 12px;
  --radius-sm: 10px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow-md: 0 10px 30px rgba(0,0,0,.12);

  /* ✅ контейнер “под любые ПК” */
  --container: 1280px;

  /* ✅ адаптивный gutter (под телефоны/планшеты/ПК) */
  --gutter: clamp(12px, 1.6vw, 18px);

  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-inset-left: env(safe-area-inset-left, 0px);
  --safe-area-inset-right: env(safe-area-inset-right, 0px);
  --safe-area-inset-x: max(var(--safe-area-inset-left), var(--safe-area-inset-right));

  /* UI kit tokens (app-like) */
  --ui-bg: var(--bg, #f6f7fb);
  --ui-surface: var(--surface, #ffffff);
  --ui-border: var(--border, rgba(148,163,184,.28));
  --ui-text: var(--text, #0f172a);
  --ui-muted: var(--muted, #6b7280);
  --ui-shadow: 0 10px 26px rgba(2, 6, 23, .06);
  --ui-shadow-sm: 0 6px 16px rgba(2, 6, 23, .06);
  --ui-radius: 16px;
  --ui-radius-sm: 14px;
  --ui-pad: 14px;
  --ui-gap: 12px;
  --ui-primary: var(--theme-color, #0088cc);
}

/* чуть шире на больших мониторах */
@media (min-width: 1600px){
  :root{ --container: 1360px; }
}
@media (min-width: 1920px){
  :root{ --container: 1440px; }
}

/* ===== базовые “железные” фиксы ===== */
html, body{
  width: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* универсально считаем ширины */
*, *::before, *::after{
  box-sizing: border-box;
}

/* медиа никогда не раздувают страницу */
img, video, iframe, canvas{
  max-width: 100%;
}

/* img по умолчанию без “inline-щели” */
img{
  display: block;
  height: auto;
}

body{
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* --- Container --- */
.container{
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;

  padding-top: var(--gutter);
  padding-bottom: var(--gutter);
  padding-left: calc(var(--gutter) + var(--safe-area-inset-x));
  padding-right: calc(var(--gutter) + var(--safe-area-inset-x));
}

/* --- Links --- */
a{
  color: #0055aa;
  text-decoration: none;
}
a:hover{ text-decoration: underline; }

/* --- Focus (не ломаем, используем focus-visible) --- */
:focus-visible{
  outline: 2px solid rgba(0,136,204,.35);
  outline-offset: 2px;
}

/* =========================================================
   Типографика (общая)
   ========================================================= */

.page-title{
  margin: 15px 0 20px;
  padding-bottom: 6px;
  font-size: 1.6rem;
  line-height: 1.15;
  font-weight: 900;
  color: #0f172a;
  border-bottom: 2px solid rgba(229,231,235,.70);
}

.section-title{
  margin: 20px 0 10px;
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 800;
  color: rgba(15,23,42,.92);
}

.text-muted{ color: var(--muted); }
.text-center{ text-align: center; }

.empty{
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 20px;
}

/* =========================================================
   Forms base (общие)
   ========================================================= */

input, select, textarea{
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus{
  border-color: var(--theme-color);
  outline: none;
}

/* ВАЖНО: ширину 100% даём всем формам, кроме формы поиска */
form:not(.search-form) input,
form:not(.search-form) select,
form:not(.search-form) textarea{
  width: 100%;
}

/* =========================================================
   Modal (только в своём контейнере)
   ========================================================= */

.message-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.message-modal.active { display: flex; }

.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  width: 350px;
  max-width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.modal-content h3 {
  margin-top: 0;
  font-size: 1.2rem;
  margin-bottom: 10px;
}
.modal-content textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  font-size: 0.95rem;
  margin-bottom: 10px;
}
.modal-actions { text-align: right; }
.modal-actions button {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  margin-left: 8px;
  cursor: pointer;
}

#sendMsgBtn { background: #007bff; color: #fff; }
#cancelMsgBtn { background: #ddd; }
#sendMsgBtn:hover { background: #0056b3; }

/* =========================================================
   Базовые UI components (ЕДИНСТВЕННЫЙ источник истины)
   ========================================================= */

/* Buttons */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #f3f4f6;
  color: #111827;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s ease, transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  user-select: none;
}

.btn:hover{ filter: brightness(1.03); }
.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: linear-gradient(180deg, var(--theme-color), #006fa8);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 136, 204, 0.20);
}

.btn-success{
  background: #16a34a;
  color: #fff;
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.18);
}

.btn-warning{
  background: #f59e0b;
  color: #111827;
  box-shadow: 0 8px 18px rgba(245, 158, 11, 0.18);
}

.btn-danger{
  background: #dc2626;
  color: #fff;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.18);
}

.btn-secondary{
  background: #eef2f7;
  color: #111827;
  border-color: rgba(15,23,42,.10);
}

.btn-outline{
  background: #fff;
  border-color: #d1d5db;
  color: #111827;
}

.btn-outline-danger{
  background: #fff;
  border-color: #fecaca;
  color: #b91c1c;
}

.btn-sm{
  padding: 8px 12px;
  border-radius: 9px;
  font-size: .92rem;
  font-weight: 800;
}

/* Card */
.card{
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  padding: 14px; /* важно: чтобы не “просели” старые страницы без .card-body */
}

/* если используются секции card-header/card-body — убираем общий padding */
.card:has(> .card-header),
.card:has(> .card-body){
  padding: 0;
  overflow: hidden;
}

.card-header{
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  font-weight: 900;
  color: #111827;
}

.card-body{
  padding: 14px;
}

/* опциональный hover-эффект (не двигаем карточку по умолчанию) */
.card.card-hover:hover{
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}

/* Alerts */
.alert{
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 12px 14px;
  margin: 10px 0;
  font-weight: 600;
}

.alert-info{
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.alert-success{
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}

.alert-danger{
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-warning{
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* Badges */
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 800;
  border: 1px solid transparent;
  line-height: 1.2;
}

.badge-success{ background:#dcfce7; color:#166534; border-color:#bbf7d0; }
.badge-warning{ background:#fef3c7; color:#92400e; border-color:#fde68a; }
.badge-danger{ background:#fee2e2; color:#991b1b; border-color:#fecaca; }
.badge-secondary{ background:#f3f4f6; color:#374151; border-color:#e5e7eb; }

/* =========================================================
   UI KIT (app-like) — дополнительные классы (НЕ конфликтуют)
   ========================================================= */

/* a11y */
.sr-only{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

/* page */
.ui-page{
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 12px;
}
.ui-page-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 480px){
  .ui-page-head{
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

.ui-title{
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 800;
  color: var(--ui-text);
}
.ui-muted{ color: var(--ui-muted); }

/* card */
.ui-card{
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-sm);
}
.ui-card--soft{
  background: rgba(241,245,249,.6);
  border-color: rgba(148,163,184,.22);
  box-shadow: none;
}

/* grid */
.ui-grid{
  display: grid;
  gap: var(--ui-gap);
}

/* separator */
.ui-sep{
  height: 1px;
  background: rgba(148,163,184,.22);
  margin: 14px 0;
  border-radius: 999px;
}

/* alerts */
.ui-alert{
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.22);
  background: rgba(241,245,249,.7);
  color: var(--ui-muted);
  font-weight: 600;
}
.ui-alert--muted{
  background: rgba(241,245,249,.55);
}

/* chips */
.ui-chip{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  white-space: nowrap;
}
.ui-chip--soft{
  border: 1px solid rgba(148,163,184,.22);
  background: rgba(239,246,255,.7);
  color: rgba(29,78,216,.95);
}
.ui-chip--ghost{
  border: 1px solid rgba(148,163,184,.28);
  background: rgba(255,255,255,.88);
  color: rgba(15,23,42,.92);
  backdrop-filter: blur(6px);
}
.ui-chip--btn{
  cursor:pointer;
  text-decoration:none;
}

/* buttons */
.ui-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  text-decoration:none;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  transition: transform .08s ease, filter .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.ui-btn:active{ transform: translateY(1px); }

.ui-btn--sm{
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
}

.ui-btn--icon{
  width: 42px;
  padding: 0;
}
.ui-btn--sm.ui-btn--icon{
  width: 38px;
}

.ui-btn--primary{
  background: linear-gradient(180deg, var(--ui-primary), #006fa8);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0,136,204,.20);
}
.ui-btn--primary:hover{ filter: brightness(1.03); }
.ui-btn--secondary{
  background: #fff;
  border-color: rgba(148,163,184,.35);
  color: rgba(15,23,42,.88);
}
.ui-btn--secondary:hover{ background: rgba(241,245,249,.65); }

.ui-btn--warning{
  background: rgba(255, 251, 235, .95);
  border-color: rgba(245, 158, 11, .40);
  color: rgba(120, 53, 15, .98);
}
.ui-btn--warning:hover{ filter: brightness(0.99); }

.ui-btn.is-disabled{
  opacity: .55;
  pointer-events: none;
}

/* prose (content) */
.ui-prose{
  color: var(--ui-text);
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ui-prose p{ margin: 0 0 12px; }
.ui-prose ul, .ui-prose ol{ padding-left: 18px; margin: 10px 0 14px; }
.ui-prose a{ color: var(--ui-primary); text-decoration: underline; text-underline-offset: 2px; }
.ui-prose img{
  display:block;
  max-width: 100%;
  height: auto;
  width: 100%;
  margin: 0 auto 14px;
  border-radius: 14px;
  box-sizing: border-box;
}

/* =========================================================
   UI KIT — fields/inputs/checkbox/helpers
   ========================================================= */

.ui-field{ display:flex; flex-direction:column; gap:8px; margin-bottom: 12px; }

.ui-label{
  font-weight: 800;
  font-size: 14px;
  color: rgba(15,23,42,.90);
}
.ui-label--sm{
  font-weight: 700;
  font-size: 12px;
  color: rgba(107,114,128,.95);
}

.ui-input{
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.35);
  background: #fff;
  color: rgba(15,23,42,.95);
  font-size: 16px; /* iOS no-zoom */
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

.ui-input--sm{
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 12px;
}

.ui-input:focus{
  border-color: rgba(0,136,204,.55);
  box-shadow: 0 0 0 3px rgba(0,136,204,.12);
}

.ui-textarea{ resize: vertical; min-height: 120px; font-family: inherit; }

.ui-select{ appearance: none; background-image: none; }

.ui-help{
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
}
.ui-help--danger{ color: #ef4444; }

/* checkbox */
.ui-check{
  display:inline-flex;
  align-items:center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-weight: 800;
  color: rgba(15,23,42,.85);
}

.ui-check input{
  position:absolute;
  opacity:0;
  width:1px;
  height:1px;
}

.ui-check-box{
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(148,163,184,.45);
  background: #fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.ui-check input:checked + .ui-check-box{
  background: rgba(0,136,204,.95);
  border-color: rgba(0,136,204,.95);
  box-shadow: 0 0 0 3px rgba(0,136,204,.12);
}
.ui-check input:checked + .ui-check-box::after{
  content: "✓";
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.ui-check-text{
  font-size: 14px;
  font-weight: 800;
  color: rgba(15,23,42,.80);
}

/* alerts additions */
.ui-alert--success{
  border-color: rgba(34,197,94,.25);
  background: rgba(220,252,231,.65);
  color: rgba(22,101,52,.95);
}
.ui-alert--danger{
  border-color: rgba(239,68,68,.25);
  background: rgba(254,226,226,.70);
  color: rgba(153,27,27,.95);
}

/* utility */
.is-hidden{ display:none !important; }

.site-footer{
  margin-top: 28px;
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(229,231,235,.8);
  background: var(--surface, #fff);
}

.site-footer__inner{
  max-width: 980px;
  margin: 0 auto;
  padding: 0 14px;
  box-sizing: border-box;

  display: flex;
  justify-content: center;
  text-align: center;
}

.site-footer__copy{
  margin: 0;
  font-size: 14px;
  color: var(--muted, #6b7280);
  line-height: 1.4;
}

/* =========================================================
   MOBILE SCALE — app-like mobile-first overrides
   ========================================================= */
@media (max-width: 480px){

  /* базовый текст */
  body{
    font-size: 15px;
    line-height: 1.45;
  }

  /* заголовки */
  .page-title{
    font-size: 1.25rem;
    margin: 10px 0 14px;
    padding-bottom: 4px;
  }

  .section-title{
    font-size: 1.05rem;
    margin: 14px 0 8px;
  }

  .ui-title{
    font-size: 1.15rem;
  }

  /* контейнеры */
  .ui-page{
    padding: 12px 10px;
  }

  /* карточки */
  .card,
  .ui-card{
    border-radius: 14px;
  }

  .card-body,
  .ui-card{
    padding: 12px;
  }

  /* кнопки — самое важное */
  .btn{
    padding: 8px 12px;
    font-size: 0.95rem;
  }

  .btn-sm{
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .ui-btn{
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 14px;
  }

  .ui-btn--sm{
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  /* формы */
  input,
  select,
  textarea{
    font-size: 15px;
    padding: 9px 11px;
  }

  .ui-input{
    min-height: 40px;
    padding: 10px 12px;
    font-size: 15px;
  }

  /* prose */
  .ui-prose{
    font-size: 15px;
    line-height: 1.55;
  }
}

@media (max-width: 480px){
  .promo-top,
  .profile-topbar,
  .rides-header{
    margin-bottom: 10px;
  }

  .promo-title{
    font-size: 1.25rem;
  }
}

