/* ReplyOne Design System v8.2.8_design_system_mobile_fix
   Scope: public site, admin panel, client cabinet, install/auth pages.
   No backend, DB, bot, payment, auth logic changes.
   Sections:
   1. Tokens/base
   2. Layout
   3. Components
   4. Tables/forms
   5. Public/auth/install
   6. Mobile
   7. RTL
*/

/* 1. Tokens/base */
:root{
  --ds-bg:#f4f8ff;
  --ds-bg-soft:#eef5ff;
  --ds-surface:#ffffff;
  --ds-surface-soft:#f8fbff;
  --ds-line:#dce8f7;
  --ds-line-strong:#c6d8f1;
  --ds-text:#0f172a;
  --ds-muted:#64748b;
  --ds-muted-2:#8190a7;
  --ds-primary:#2563eb;
  --ds-primary-2:#7c3aed;
  --ds-primary-soft:#e8f1ff;
  --ds-success:#16a34a;
  --ds-success-soft:#dcfce7;
  --ds-warning:#d97706;
  --ds-warning-soft:#fef3c7;
  --ds-danger:#dc2626;
  --ds-danger-soft:#fee2e2;
  --ds-info:#0284c7;
  --ds-info-soft:#e0f2fe;
  --ds-radius-sm:14px;
  --ds-radius:18px;
  --ds-radius-lg:24px;
  --ds-shadow-sm:0 8px 22px rgba(15,23,42,.045);
  --ds-shadow:0 16px 42px rgba(15,23,42,.07);
  --ds-shadow-lg:0 28px 80px rgba(15,23,42,.13);
  --ds-sidebar:260px;
  --ds-page-max:1840px;
}

html,body{
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
}

body.admin-bg,
body.replyone-admin-shell,
body.replyone-client-adminlike,
body.page-bg,
body.landing-modern-page{
  color:var(--ds-text);
  background:
    radial-gradient(circle at 12% 8%,rgba(37,99,235,.10),transparent 32%),
    radial-gradient(circle at 88% 5%,rgba(124,58,237,.10),transparent 34%),
    linear-gradient(135deg,#eef6ff 0%,#f8fbff 48%,#f4f0ff 100%);
}

/* 2. Layout */
.replyone-admin-shell .app-layout{
  display:grid;
  grid-template-columns:var(--ds-sidebar) minmax(0,1fr);
  align-items:start;
  min-height:100dvh;
  width:100vw;
  margin:0;
}

.replyone-admin-shell .ro-sidebar{
  width:var(--ds-sidebar);
  min-width:var(--ds-sidebar);
  height:100dvh;
  min-height:100dvh;
  position:sticky;
  top:0;
  padding:18px 14px;
  overflow-y:auto;
  overflow-x:hidden;
  background:rgba(255,255,255,.86);
  border-inline-end:1px solid rgba(220,232,247,.78);
  backdrop-filter:blur(18px);
}

.replyone-admin-shell .ro-main{
  width:100%;
  min-width:0;
  max-width:none;
  margin:0;
  padding:26px 32px 34px;
  overflow-x:hidden;
}

.replyone-admin-shell .ro-page,
.replyone-admin-shell .ro-topbar,
.replyone-admin-shell .footer-note{
  width:100%;
  max-width:var(--ds-page-max);
  margin-inline:0;
}

.replyone-admin-shell .ro-page{
  display:flex;
  flex-direction:column;
  gap:18px;
}

.replyone-admin-shell .ro-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  margin-bottom:18px;
  padding:14px 16px;
  border:1px solid rgba(220,232,247,.78);
  border-radius:26px;
  background:rgba(255,255,255,.86);
  backdrop-filter:blur(18px);
  box-shadow:0 10px 30px rgba(15,23,42,.045);
}

/* 3. Components */
.card,
.rc-card,
.replyone-admin-shell .card,
.replyone-client-adminlike .card{
  background:rgba(255,255,255,.96);
  border:1px solid var(--ds-line);
  border-radius:var(--ds-radius-lg);
  box-shadow:var(--ds-shadow-sm);
}

.card h3,.rc-card h3{
  color:var(--ds-text);
  letter-spacing:-.02em;
}

.small,.hint{
  color:var(--ds-muted);
  line-height:1.55;
}

.btn,
button.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border-radius:var(--ds-radius-sm);
  border:1px solid transparent;
  font-weight:900;
  line-height:1.2;
  text-decoration:none;
  cursor:pointer;
}

.btn-primary{
  color:#fff;
  background:linear-gradient(135deg,var(--ds-primary),var(--ds-primary-2));
  box-shadow:0 12px 28px rgba(37,99,235,.22);
}

.btn-outline{
  color:var(--ds-text);
  background:#fff;
  border-color:var(--ds-line);
}

.pill,.badge,.status-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:24px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:950;
  line-height:1;
  font-style:normal;
  border:1px solid transparent;
}

.pill-ok,.status-active,.status-answered{background:var(--ds-success-soft);color:#166534}
.pill-blue,.status-new{background:var(--ds-info-soft);color:#0369a1}
.pill-warn,.status-in_work,.status-pending{background:var(--ds-warning-soft);color:#92400e}
.status-closed,.status-disabled{background:#f1f5f9;color:#475569}
.status-error,.status-blocked{background:var(--ds-danger-soft);color:#991b1b}

.alert{
  border-radius:var(--ds-radius);
  padding:14px 16px;
  border:1px solid var(--ds-line);
}
.alert-ok{background:#ecfdf5;border-color:#86efac;color:#166534}
.alert-danger{background:#fef2f2;border-color:#fecaca;color:#991b1b}
.alert-warn{background:#fffbeb;border-color:#fde68a;color:#92400e}

/* 4. Tables/forms */
.table-wrap{
  width:100%;
  max-width:100%;
  overflow-x:auto;
  border:1px solid var(--ds-line);
  border-radius:var(--ds-radius);
  background:#fff;
}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

.table th{
  padding:12px 14px;
  color:#475569;
  background:#f8fbff;
  font-size:12px;
  font-weight:950;
  text-align:start;
  text-transform:uppercase;
  letter-spacing:.04em;
  border-bottom:1px solid var(--ds-line);
}

.table td{
  padding:12px 14px;
  color:var(--ds-text);
  border-bottom:1px solid #edf3fb;
  vertical-align:middle;
}

.input,.select,.textarea,
input[type="text"],input[type="email"],input[type="password"],input[type="number"],input[type="url"],select,textarea{
  width:100%;
  max-width:100%;
  border:1px solid var(--ds-line-strong);
  border-radius:var(--ds-radius-sm);
  background:#fff;
  color:var(--ds-text);
  padding:12px 14px;
  font-size:15px;
  outline:none;
  transition:.16s ease;
}

.select,select{min-height:46px}
.textarea,textarea{min-height:120px;resize:vertical}

.input:focus,.select:focus,.textarea:focus,
input:focus,select:focus,textarea:focus{
  border-color:#93c5fd;
  box-shadow:0 0 0 4px rgba(37,99,235,.12);
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
}
.form-group{min-width:0;margin-bottom:16px}
.form-group.full,.full{grid-column:1 / -1}

/* 5. Public/auth/install */
.landing-modern-page .modern-shell,
.landing-modern-page .login-shell,
.page-bg .install-shell,
.page-bg .card{
  width:min(1180px,calc(100vw - 28px));
  margin-inline:auto;
}

.landing-modern-page .auth-card,
.landing-modern-page .landing-auth-card,
.login-shell .login-card,
.page-bg .card{
  border:1px solid var(--ds-line);
  border-radius:28px;
  background:rgba(255,255,255,.94);
  box-shadow:var(--ds-shadow);
}

.landing-modern-page .input-with-icon{
  position:relative;
}

.landing-modern-page .input-with-icon .field-icon{
  position:absolute;
  top:43px;
  inset-inline-start:14px;
  width:24px;
  height:24px;
  z-index:2;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
  opacity:.72;
}

.landing-modern-page .input-with-icon .input{
  padding-inline-start:48px;
  padding-inline-end:44px;
}

/* 6. Mobile hard reset */
@media(max-width:1050px){
  html,body{
    min-height:auto;
  }

  body.replyone-admin-shell .app-layout{
    display:block;
    width:100%;
    min-height:auto;
  }

  body.replyone-admin-shell .ro-main{
    display:block;
    width:100%;
    max-width:none;
    min-height:0;
    padding:12px 12px 24px;
  }

  body.replyone-admin-shell .ro-topbar{
    margin-top:0;
    margin-bottom:12px;
    padding:12px;
    border-radius:18px;
  }

  body.replyone-admin-shell .ro-page{
    margin-top:0;
    padding-top:0;
    gap:12px;
  }

  body.replyone-admin-shell .ro-sidebar{
    position:fixed;
    top:0;
    bottom:0;
    inset-inline-start:0;
    z-index:8999;
    width:min(320px,88vw);
    min-width:0;
    height:100dvh;
    min-height:100dvh;
    max-height:100dvh;
    overflow-y:auto;
    transform:translateX(-110%);
    transition:transform .22s ease;
    box-shadow:0 30px 90px rgba(15,23,42,.25);
  }

  body.admin-sidebar-open .ro-sidebar{
    transform:translateX(0);
  }

  .ro-sidebar-close,
  .ro-menu-toggle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }

  .kpi-grid,.ro-kpi-grid,.stats-grid,.content-grid,.dashboard-standard-grid,
  .helpdesk-standard-grid,.admin-support-grid{
    grid-template-columns:1fr;
  }

  .table{
    min-width:720px;
  }
}

@media(max-width:760px){
  body.replyone-admin-shell .ro-main{
    padding:10px 10px 20px;
  }

  body.replyone-admin-shell .ro-topbar{
    flex-direction:column;
    align-items:stretch;
    gap:10px;
  }

  body.replyone-admin-shell .ro-topbar-left{
    width:100%;
    align-items:center;
  }

  body.replyone-admin-shell .ro-page-title h1{
    font-size:21px;
  }

  body.replyone-admin-shell .ro-page-title p{
    font-size:12px;
    margin-top:3px;
    line-height:1.35;
  }

  body.replyone-admin-shell .ro-top-actions{
    width:100%;
    justify-content:flex-start;
    gap:8px;
  }

  .card,.rc-card{
    padding:14px;
    border-radius:18px;
  }

  .form-grid{
    grid-template-columns:1fr;
  }

  .btn{
    white-space:normal;
  }
}

/* 7. RTL */
html.rtl,
body.rtl{
  direction:rtl;
}

.rtl .ro-sidebar,
.rtl .rc-sidebar{
  border-inline-end:0;
  border-inline-start:1px solid rgba(220,232,247,.78);
}

@media(max-width:1050px){
  body.rtl.replyone-admin-shell .ro-sidebar{
    inset-inline-start:auto;
    inset-inline-end:0;
    transform:translateX(110%);
  }

  body.rtl.admin-sidebar-open .ro-sidebar{
    transform:translateX(0);
  }

  .rtl .landing-modern-page .input-with-icon .field-icon,
  body.rtl .input-with-icon .field-icon{
    inset-inline-start:auto;
    inset-inline-end:14px;
  }

  .rtl .landing-modern-page .input-with-icon .input,
  body.rtl .input-with-icon .input{
    padding-inline-start:44px;
    padding-inline-end:48px;
  }
}


/* v8.2.8_design_system_cleanup — final safety layer
   Purpose: normalize UI without changing backend logic.
*/

/* Empty states */
.empty-state,
.rc-empty-state{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:170px;
  padding:28px 18px;
  text-align:center;
  border:1px dashed var(--ds-line-strong);
  border-radius:var(--ds-radius-lg);
  background:linear-gradient(135deg,#ffffff,#f8fbff);
  color:var(--ds-muted);
}
.empty-state .icon,
.rc-empty-state .icon{
  width:52px;
  height:52px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:18px;
  background:var(--ds-primary-soft);
  color:var(--ds-primary);
  font-size:24px;
}
.empty-state strong,
.rc-empty-state strong{
  color:var(--ds-text);
  font-size:17px;
}

/* Normalize action button groups */
.action-buttons,
.actions,
.ro-row-actions,
.rc-actions-row,
.client-bot-actions-row{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.action-buttons form,
.actions form,
.ro-row-actions form,
.rc-actions-row form{
  margin:0;
}

/* Keep global page horizontal scroll disabled; table wrappers handle scroll */
body.replyone-admin-shell,
body.replyone-client-adminlike,
body.landing-modern-page,
body.page-bg{
  overflow-x:hidden;
}

.table-wrap,
.rc-table-wrap{
  -webkit-overflow-scrolling:touch;
}

/* Mobile tables: only inner scroll, never page scroll */
@media(max-width:760px){
  .table-wrap,
  .rc-table-wrap{
    overflow-x:auto;
    margin-inline:0;
  }
  .table-wrap .table,
  .rc-table-wrap .table{
    min-width:640px;
  }
}

/* Hebrew / RTL strengthening */
html.rtl .table th,
html.rtl .table td,
body.rtl .table th,
body.rtl .table td{
  text-align:right;
}

html.rtl .section-head,
body.rtl .section-head,
html.rtl .rc-section-head,
body.rtl .rc-section-head{
  text-align:right;
}

@media(max-width:1050px){
  body.rtl.replyone-client-adminlike .rc-sidebar{
    inset-inline-start:auto;
    inset-inline-end:0;
    transform:translateX(110%);
  }
  body.rtl.replyone-client-adminlike.client-sidebar-open .rc-sidebar,
  body.rtl.client-sidebar-open .rc-sidebar{
    transform:translateX(0);
  }
}


/* v8.2.8.1 Client grid sizing safety */
body.replyone-client-adminlike .rc-layout,
body.replyone-client-adminlike .rc-main,
body.replyone-client-adminlike .rc-page,
body.replyone-client-adminlike .rc-page > *,
body.replyone-client-adminlike .rc-card,
body.replyone-client-adminlike .card{
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}

body.replyone-client-adminlike .rc-kpi-grid{
  grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));
}

body.replyone-client-adminlike .rc-plan-grid,
body.replyone-client-adminlike .client-plan-cards,
body.replyone-client-adminlike .client-plan-grid{
  grid-template-columns:repeat(auto-fit,minmax(min(260px,100%),1fr));
}


/* =========================================================
   v8.2.10 Mobile RTL Polish
   Scope: visual/mobile/RTL only.
   Backend/payment/Telegram/auth/database logic unchanged.
   ========================================================= */

/* mobile base */
html,
body{
  max-width:100%;
}

body.replyone-admin-shell,
body.replyone-client-adminlike,
body.landing-modern-page,
body.page-bg{
  min-width:0;
  max-width:100%;
}

body.replyone-admin-shell *,
body.replyone-client-adminlike *,
body.landing-modern-page *,
body.page-bg *{
  box-sizing:border-box;
}

body.replyone-admin-shell .app-layout,
body.replyone-admin-shell .main,
body.replyone-admin-shell .page,
body.replyone-admin-shell .content,
body.replyone-admin-shell .card,
body.replyone-admin-shell .grid,
body.replyone-admin-shell .table-wrap,
body.replyone-admin-shell .modal-card,
body.landing-modern-page .auth-card,
body.landing-modern-page .landing-card,
body.page-bg .install-card,
body.page-bg .card,
body.page-bg form,
body.page-bg .form-grid{
  min-width:0;
  max-width:100%;
}

/* mobile public/login/register/install */
@media(max-width:760px){
  body.landing-modern-page,
  body.page-bg{
    padding:10px;
    overflow-x:hidden;
  }

  body.landing-modern-page .landing-shell,
  body.landing-modern-page .auth-shell,
  body.landing-modern-page .hero,
  body.landing-modern-page .auth-card,
  body.page-bg .install-wrap,
  body.page-bg .install-card,
  body.page-bg .card{
    width:100%;
    max-width:100%;
    margin-inline:auto;
  }

  body.landing-modern-page .auth-card,
  body.page-bg .install-card,
  body.page-bg .card{
    padding:16px;
    border-radius:20px;
  }

  body.landing-modern-page input,
  body.landing-modern-page select,
  body.landing-modern-page textarea,
  body.page-bg input,
  body.page-bg select,
  body.page-bg textarea{
    width:100%;
    min-width:0;
    max-width:100%;
    min-height:44px;
  }

  body.landing-modern-page .btn,
  body.page-bg .btn,
  body.page-bg button{
    width:100%;
    max-width:100%;
    min-height:44px;
  }
}

/* mobile admin */
@media(max-width:1050px){
  body.replyone-admin-shell{
    overflow-x:hidden;
  }

  body.replyone-admin-shell .app-layout{
    display:block;
    width:100%;
    min-width:0;
  }

  body.replyone-admin-shell .main{
    width:100%;
    max-width:100%;
    min-width:0;
    padding:10px;
    margin:0;
  }

  body.replyone-admin-shell .topbar,
  body.replyone-admin-shell .page-head,
  body.replyone-admin-shell .section-head{
    width:100%;
    max-width:100%;
    min-width:0;
    margin-top:0;
    flex-wrap:wrap;
  }

  body.replyone-admin-shell .grid,
  body.replyone-admin-shell .kpi-grid,
  body.replyone-admin-shell .stats-grid,
  body.replyone-admin-shell .content-grid,
  body.replyone-admin-shell .form-grid{
    grid-template-columns:1fr;
    width:100%;
    max-width:100%;
  }

  body.replyone-admin-shell .card{
    width:100%;
    max-width:100%;
    min-width:0;
  }

  body.replyone-admin-shell .table-wrap{
    width:100%;
    max-width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }

  body.replyone-admin-shell table{
    min-width:680px;
  }

  body.replyone-admin-shell .actions,
  body.replyone-admin-shell .action-buttons,
  body.replyone-admin-shell .table-actions{
    flex-wrap:wrap;
  }
}

@media(max-width:420px){
  body.replyone-admin-shell .main{
    padding:8px;
  }

  body.replyone-admin-shell .card{
    padding:12px;
    border-radius:18px;
  }

  body.replyone-admin-shell .btn,
  body.replyone-admin-shell button{
    max-width:100%;
  }
}

/* RTL base */
html.rtl,
body.rtl{
  direction:rtl;
}

html.rtl body,
body.rtl{
  text-align:right;
}

html.rtl input,
html.rtl select,
html.rtl textarea,
body.rtl input,
body.rtl select,
body.rtl textarea{
  text-align:right;
}

body.rtl .table th,
body.rtl .table td,
body.rtl table th,
body.rtl table td{
  text-align:right;
}

/* RTL admin/public/install */
body.rtl.replyone-admin-shell .topbar,
body.rtl.replyone-admin-shell .page-head,
body.rtl.replyone-admin-shell .section-head,
body.rtl.landing-modern-page .auth-card,
body.rtl.page-bg .install-card{
  direction:rtl;
}

@media(max-width:1050px){
  body.rtl.replyone-admin-shell .sidebar{
    inset-inline-start:auto;
    inset-inline-end:0;
  }
}

/* modals mobile/RTL */
@media(max-width:760px){
  .modal-card{
    width:calc(100vw - 20px);
    max-width:calc(100vw - 20px);
    max-height:calc(100dvh - 20px);
    overflow:auto;
    margin:10px;
  }
}

body.rtl .modal-card,
html.rtl .modal-card{
  direction:rtl;
  text-align:right;
}
