/* ══════════════════════════════════════════════════
   KARETA.KZ — Mobile Web App Layer
══════════════════════════════════════════════════ */

:root {
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --bnav-bar: 60px;
  --bnav-h: calc(var(--bnav-bar) + var(--safe-b));
  --tap: 44px;
  --r: 12px;
}

* { -webkit-tap-highlight-color: transparent; }
input, select, textarea { touch-action: manipulation; }

/* ══════ BOTTOM NAV ══════ */
@media (max-width: 900px) {
  :root { --bottom-nav-h: var(--bnav-h); }

  #bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
    background: rgba(13,13,15,.95);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border-top: 1px solid rgba(255,255,255,.07);
    box-shadow: 0 -4px 30px rgba(0,0,0,.5);
    padding-bottom: var(--safe-b);
    transform: translateZ(0);
  }
  .bnav-inner {
    height: var(--bnav-bar); display: flex; align-items: center;
    width: 100%; padding: 0 6px; gap: 2px;
  }
  .bnav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; padding: 6px 4px 7px;
    min-height: var(--bnav-bar);
    border-radius: 10px;
    color: rgba(140,140,150,.65);
    cursor: pointer; position: relative;
    transition: color .15s ease;
    -webkit-user-select: none; user-select: none;
  }
  .bnav-item:active {
    background: rgba(255,255,255,.07);
    transform: scale(.92);
    transition: transform .08s ease;
  }
  .bnav-item.active { color: var(--orange); }
  .bnav-item.active .bnav-icon-wrap {
    background: rgba(255,107,0,.15);
    border-radius: 9px;
  }
  .bnav-item.active .bnav-icon-wrap::after { display: none; }
  .bnav-icon-wrap {
    width: 40px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9px; position: relative;
    transition: background .15s ease;
  }
  .bnav-icon {
    font-size: 20px; line-height: 1;
    transition: transform .22s cubic-bezier(.34,1.56,.64,1);
  }
  .bnav-item.active .bnav-icon { transform: scale(1.18) translateY(-1px); }
  .bnav-label {
    font-size: 9.5px; font-weight: 700;
    letter-spacing: .3px; line-height: 1; text-align: center;
  }
  .bnav-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--orange); color: #fff;
    font-size: 8px; font-weight: 800; border-radius: 99px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(13,13,15,.95); line-height: 1;
  }
  #app { padding-bottom: var(--bnav-h) !important; }
  footer { display: none; }
}

/* ══════ TOP NAV ══════ */
@media (max-width: 900px) {
  :root { --nav-h: 54px; }
  .nav-phone { display: none; }
  .nav-logo-text { font-size: 16px; }
  .nav-logo-sub  { font-size: 8px; }
  .nav-avatar { width: 34px; height: 34px; font-size: 14px; }
  .nav-avatar:active { transform: scale(.9); transition: transform .1s; }
  .burger {
    display: flex; width: var(--tap); height: var(--tap);
    border-radius: 10px; padding: 10px; margin-right: -6px;
  }
  .burger:active { background: rgba(255,255,255,.08); }
}

/* ══════ DRAWER — bottom sheet ══════ */
@media (max-width: 900px) {
  #drawer-overlay {
    display: none; position: fixed; inset: 0;
    z-index: 798; background: rgba(0,0,0,.6);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .3s ease;
  }
  #drawer-overlay.vis { display: block; opacity: 1; }

  #drawer {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%;
    max-height: 82dvh;
    border-radius: 20px 20px 0 0;
    border-right: none;
    border-top: 1px solid rgba(255,255,255,.09);
    transform: translateY(100%);
    transition: transform .32s cubic-bezier(.16,1,.3,1);
    overflow-y: auto; overflow-x: hidden;
    padding-bottom: calc(var(--safe-b) + 16px);
    z-index: 800;
  }
  #drawer.open { transform: translateY(0); }

  /* Ручка */
  .drawer-handle {
    width: 38px; height: 4px;
    background: rgba(255,255,255,.18);
    border-radius: 99px;
    margin: 14px auto 6px;
  }

  .drawer-link {
    min-height: 52px; padding: 0 22px;
    font-size: 15px; display: flex; align-items: center; gap: 14px;
  }
  .drawer-link:active { background: rgba(255,255,255,.055); }
  .dl-icon { font-size: 18px; width: 26px; text-align: center; flex-shrink: 0; }
  .drawer-role-footer { padding: 14px 20px; }
  .drf-av  { width: 38px; height: 38px; font-size: 15px; }
  .drf-btn { min-height: var(--tap); padding: 8px 16px; }
  .drawer-footer { padding: 14px 22px 20px; }
  .drawer-phone  { font-size: 20px; }
}

/* ══════ КНОПКИ ══════ */
@media (max-width: 900px) {
  .btn-primary:hover,
  .btn-outline:hover { transform: none !important; box-shadow: none !important; }
  .card:hover        { transform: none !important; box-shadow: none !important; border-color: var(--line) !important; }

  .btn  { touch-action: manipulation; border-radius: var(--r); }
  .btn:active  { opacity: .78; transform: scale(.96) !important; transition: .09s ease; }
  .card:active { transform: scale(.98) !important; transition: .09s ease; }

  .hero-btns { flex-direction: column; gap: 10px; width: 100%; }
  .hero-btns .btn {
    width: 100%; justify-content: center;
    min-height: 50px; font-size: 14px; padding: 14px 20px;
  }
  .act-btn    { min-height: 36px; padding: 6px 14px; border-radius: 8px; }
  .logout-btn { min-height: 36px; }
  .sched-btn  { min-height: 38px; padding: 8px 16px; border-radius: 8px; }

  /* micro-press на карточках */
  .st-card:active, .rv-card:active, .hv-card:active { transform: scale(.97) !important; transition: .08s ease !important; }
  .hist-item:active, .notif-item:active { opacity: .7; transition: opacity .08s; }
}

/* ══════ ФОРМЫ / inputs ══════ */
@media (max-width: 900px) {
  /* 16px — iOS не масштабирует */
  input:not([type=checkbox]):not([type=radio]), select, textarea {
    font-size: 16px !important;
    border-radius: var(--r);
    min-height: var(--tap);
  }
  textarea { min-height: 88px; }

  .otp-box   { width: 60px !important; height: 64px !important; font-size: 26px !important; border-radius: 14px !important; }
  .otp-row   { gap: 10px; }

  /* Auth как bottom sheet disabled: centered modal retained */
  /* #auth-overlay { align-items: flex-end !important; } */
  .auth-modal {
    border-radius: 22px 22px 0 0 !important; border: none !important;
    border-top: 1px solid rgba(255,255,255,.09) !important;
    max-height: 92dvh; overflow-y: auto;
    padding: 20px 20px calc(var(--safe-b) + 20px) !important;
    width: 100% !important; max-width: 100% !important;
  }
  .auth-btn { min-height: 52px; border-radius: var(--r); font-size: 15px; }
  .auth-btn:active { opacity: .78; transform: scale(.97); transition: .08s ease; }
  .pf-input { border-radius: var(--r); }
  .pf-save  { min-height: 50px; width: 100%; justify-content: center; }
}

/* ══════ КАБИНЕТ ══════ */
@media (max-width: 900px) {
  .cab-profile-row { padding: 20px 16px 0; gap: 12px; flex-wrap: wrap; }
  .cab-avatar { width: 54px; height: 54px; font-size: 21px; flex-shrink: 0; }

  .cab-tabs {
    display: flex; overflow-x: auto; scrollbar-width: none;
    padding: 0 8px; border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }
  .cab-tabs::-webkit-scrollbar { display: none; }
  .cab-tab {
    min-height: 46px; padding: 0 16px;
    white-space: nowrap; flex-shrink: 0; font-size: 13px;
  }
  .cab-tab:active { opacity: .7; }

  .hist-item { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
  .hist-price { align-self: flex-start; }
  .notif-item { padding: 14px 14px; }
  .profile-form { padding: 20px 16px; }
  .pf-group { margin-bottom: 16px; }
}

/* ══════ BOOKING ══════ */
@media (max-width: 900px) {
  .booking-layout { grid-template-columns: 1fr; }
  .booking-summary { display: none; }
  .bform-card { padding: 20px 16px; border-radius: 14px; }
  .bform-row  { grid-template-columns: 1fr; gap: 12px; }

  .service-chips { gap: 8px; }
  .svc-chip {
    flex: 1; min-width: calc(50% - 4px);
    min-height: 46px; justify-content: center;
    border-radius: 10px; font-size: 13px;
  }
  .svc-chip:active { transform: scale(.95); opacity: .8; transition: .08s; }

  /* Даты — горизонтальный скролл */
  .date-grid {
    overflow-x: auto;
    gap: 8px;
    scrollbar-width: none;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .date-grid::-webkit-scrollbar { display: none; }
  .date-btn {
    flex-shrink: 0; min-width: 58px; min-height: 58px;
    border-radius: 12px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 1px;
  }
  .date-btn:active { transform: scale(.92); transition: .08s; }

  .time-grid { grid-template-columns: repeat(4,1fr); gap: 8px; }
  .time-btn  { min-height: var(--tap); border-radius: 10px; font-size: 14px; }
  .time-btn:active { transform: scale(.92); transition: .08s; }

  .booking-steps { padding: 16px 16px 12px; gap: 0; }
  .bstep-num  { width: 22px; height: 22px; font-size: 9px; }
  .bstep-label { font-size: 10px; }
  .bstep-line  { min-width: 14px; }

  .bform-nav { flex-direction: row; gap: 10px; margin-top: 20px; }
  .bform-nav .btn { flex: 1; justify-content: center; min-height: 50px; }
}

/* ══════ CHAT ══════ */
@media (max-width: 900px) {
  /* Chat и Notifs панели — bottom sheet, управляется JS */
  .chat-input { font-size: 16px !important; }
  .qr-btn:active { opacity: .7; }
}

/* ══════ ADMIN ══════ */
@media (max-width: 900px) {
  .admin-layout { flex-direction: column; min-height: auto; }
  .admin-sidebar {
    position: sticky; top: var(--nav-h); z-index: 50;
    width: 100%; height: auto; flex-direction: row;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    padding: 6px 8px; border-right: none;
    border-bottom: 1px solid var(--line); gap: 4px;
    display: flex; -webkit-overflow-scrolling: touch;
  }
  .admin-sidebar::-webkit-scrollbar { display: none; }
  .admin-sidebar > div:last-child { display: none; }
  .admin-nav-label { display: none; }
  .admin-nav-item {
    flex-direction: column; gap: 3px; padding: 7px 10px;
    border-left: none !important; border-bottom: 2.5px solid transparent;
    border-radius: 8px; white-space: nowrap; font-size: 10px;
    min-width: var(--tap); min-height: var(--tap);
    justify-content: center; flex-shrink: 0;
  }
  .admin-nav-item.active {
    border-bottom-color: var(--orange); background: var(--orange-dim);
    color: var(--orange); border-left-color: transparent !important;
  }
  .admin-nav-item:active { background: rgba(255,255,255,.06); }
  .admin-nav-icon { font-size: 18px; }
  .admin-content  { padding: 16px; }
  .admin-stats-grid    { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .admin-quick-actions { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .admin-filters   { flex-wrap: wrap; gap: 6px; }
  .admin-filter-btn { min-height: 36px; padding: 6px 12px; }
  .admin-search { width: 100%; margin-left: 0; font-size: 16px !important; }
}

/* ══════ MASTER ══════ */
@media (max-width: 900px) {
  .mast-stats { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .mast-stat  { padding: 12px 10px; }
  .mast-stat-num { font-size: 18px; }
  .sched-slot { grid-template-columns: 52px 1fr; grid-template-rows: auto auto; gap: 6px 12px; padding: 12px 14px; }
  .sched-btn  { grid-column: 2; align-self: start; }
}

/* ══════ OWNER ══════ */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .kpi-card { padding: 14px 14px; }
  .kpi-num  { font-size: 20px; }
  .owner-tabs { padding: 0 6px; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .owner-tabs::-webkit-scrollbar { display: none; }
  .owner-tab  { min-height: 44px; padding: 0 14px; flex-shrink: 0; white-space: nowrap; font-size: 11px; }
  .owner-tab:active { opacity: .7; }
  .staff-tbl th, .staff-tbl td { padding: 10px 12px; font-size: 12px; }
  .bar-label { min-width: 100px; font-size: 12px; }
  .perm-tbl th, .perm-tbl td { padding: 8px 8px; font-size: 11px; }
}

/* ══════ HERO / СЕКЦИИ ══════ */
@media (max-width: 560px) {
  section    { padding: 48px 0; }
  .container { padding: 0 16px; }
  .hero-title { font-size: clamp(34px,9vw,46px) !important; }
  .hero-desc  { font-size: 14px; }
  .hero-stats {
    display: grid; grid-template-columns: repeat(4,1fr); gap: 0;
    border: 1px solid var(--line); border-radius: 12px;
    overflow: hidden; background: var(--surface);
  }
  .hero-stats > div {
    padding: 12px 6px; text-align: center;
    border-right: 1px solid var(--line);
  }
  .hero-stats > div:last-child { border-right: none; }
  .stat-num { font-size: 16px; }
  .stat-lbl { font-size: 9px; }
  .st-grid  { grid-template-columns: 1fr 1fr; gap: 10px; }
  .st-card  { padding: 14px 12px; }
  .st-emoji { font-size: 22px; }
  .cta-t     { font-size: 22px; }
  .cta-phone { font-size: 24px; }
  .cta-meta  { flex-direction: column; gap: 5px; font-size: 12px; }
}

/* ══════ PWA standalone ══════ */
@media (display-mode: standalone) {
  #nav { padding-top: var(--safe-t); height: calc(var(--nav-h) + var(--safe-t)); }
  #app { padding-top: calc(var(--nav-h) + var(--safe-t)) !important; }
}

/* ══════ Landscape phone ══════ */
@media (max-width: 900px) and (orientation: landscape) {
  :root  { --bnav-bar: 50px; }
  .bnav-icon  { font-size: 18px; }
  .bnav-label { font-size: 9px;  }
  section { padding: 32px 0; }
}


@media (max-width: 900px) {
  #notifs-fab {
    right: 14px;
    bottom: calc(var(--bottom-nav-h) + 12px);
    width: 56px;
    height: 56px;
  }
}
