/* RPay Mobile 2026 — responsive layer loaded after every legacy stylesheet. */
:root{
  --rpm-safe-top: env(safe-area-inset-top, 0px);
  --rpm-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,body{max-width:100%;overflow-x:hidden!important}
img,svg,canvas{max-width:100%}
.main-container,.main-content,.shell .main,.page-content,.content-wrapper{min-width:0!important}
.chart-card,.activity-card,.table-section,.table-container,.search-section,.profile-card,.document-card,.setting-card,.settings-card,.form-container,.card,.balance-summary{min-width:0!important}

/* Authentication: remove icon overlap and keep the form readable on every viewport. */
body.rpay-auth{min-height:100dvh!important;padding:0!important;display:block!important;overflow-x:hidden!important}
body.rpay-auth .login-container,
body.rpay-auth .register-container{
  position:relative!important;
}
body.rpay-auth .input-group{
  display:grid!important;
  grid-template-columns:46px minmax(0,1fr)!important;
  width:100%!important;
  min-width:0!important;
  align-items:stretch!important;
  position:relative!important;
  border:1px solid var(--rp-line)!important;
  border-radius:12px!important;
  overflow:hidden!important;
  background:var(--rp-surface-2)!important;
  box-shadow:none!important;
}
body.rpay-auth .input-group:focus-within{
  border-color:rgba(90,163,255,.75)!important;
  box-shadow:0 0 0 3px rgba(45,124,255,.12)!important;
}
body.rpay-auth .input-group-text{
  position:static!important;
  inset:auto!important;
  transform:none!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  width:46px!important;
  min-width:46px!important;
  height:48px!important;
  padding:0!important;
  margin:0!important;
  border:0!important;
  border-right:1px solid var(--rp-line)!important;
  border-radius:0!important;
  background:transparent!important;
  color:var(--rp-muted)!important;
  font-size:15px!important;
  pointer-events:none!important;
  z-index:1!important;
}
body.rpay-auth .input-group .form-control{
  grid-column:2!important;
  width:100%!important;
  min-width:0!important;
  height:48px!important;
  min-height:48px!important;
  padding:0 14px!important;
  margin:0!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
  color:var(--rp-text)!important;
  box-shadow:none!important;
  outline:0!important;
  font-size:16px!important;
  line-height:48px!important;
}
body.rpay-auth .input-group .form-control::placeholder{color:var(--rp-muted-2)!important;opacity:1!important}
body.rpay-auth .input-group .form-control:focus{box-shadow:none!important;background:transparent!important}
body.rpay-auth .input-group:has(.password-toggle) .form-control{padding-right:52px!important}
body.rpay-auth .password-toggle{
  position:absolute!important;
  top:2px!important;
  right:2px!important;
  bottom:2px!important;
  transform:none!important;
  width:44px!important;
  height:auto!important;
  padding:0!important;
  border:0!important;
  border-left:1px solid var(--rp-line)!important;
  border-radius:0 10px 10px 0!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  background:var(--rp-surface-2)!important;
  color:var(--rp-muted)!important;
  z-index:3!important;
}
body.rpay-auth .form-label{font-size:13px!important;line-height:1.35!important;margin:0 0 7px!important;color:var(--rp-muted)!important;font-weight:650!important}
body.rpay-auth .form-row{min-width:0!important}
body.rpay-auth .form-row>*{min-width:0!important}
body.rpay-auth .form-check{display:grid!important;grid-template-columns:18px minmax(0,1fr)!important;gap:9px!important;align-items:start!important}
body.rpay-auth .form-check-input{width:18px!important;height:18px!important;margin:2px 0 0!important}
body.rpay-auth .form-check-label{min-width:0!important;line-height:1.5!important}

/* Common mobile drawer. Legacy code uses open, active and show; support all three. */
.sidebar-overlay{
  position:fixed!important;
  inset:0!important;
  z-index:1035!important;
  display:block!important;
  visibility:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
  background:rgba(2,8,18,.64)!important;
  backdrop-filter:blur(4px)!important;
  transition:opacity .2s ease,visibility .2s ease!important;
}
.sidebar-overlay.active,.sidebar-overlay.show{
  visibility:visible!important;
  opacity:1!important;
  pointer-events:auto!important;
}

@media (max-width:1100px){
  /* Sidebars become drawers early enough for tablets and large phones. */
  .dashboard-sidebar,
  .app-container>.sidebar,
  .sidebar#sidebar,
  .shell .side,
  aside.sidebar{
    position:fixed!important;
    top:0!important;
    bottom:0!important;
    left:0!important;
    width:min(86vw,300px)!important;
    max-width:300px!important;
    height:100dvh!important;
    margin:0!important;
    border-radius:0 18px 18px 0!important;
    transform:translate3d(-105%,0,0)!important;
    visibility:hidden!important;
    transition:transform .22s ease,visibility .22s ease!important;
    z-index:1050!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
  }
  .dashboard-sidebar.open,.dashboard-sidebar.active,.dashboard-sidebar.show,
  .app-container>.sidebar.open,.app-container>.sidebar.active,.app-container>.sidebar.show,
  .sidebar#sidebar.open,.sidebar#sidebar.active,.sidebar#sidebar.show,
  .shell .side.open,.shell .side.active,.shell .side.show,
  aside.sidebar.open,aside.sidebar.active,aside.sidebar.show{
    transform:translate3d(0,0,0)!important;
    visibility:visible!important;
  }

  .main-container,.main-content,.shell .main{
    margin-left:0!important;
    width:100%!important;
    max-width:100%!important;
  }

  .mobile-menu-toggle,
  .floating-header-left{
    display:flex!important;
  }

  /* User header */
  .main-container{padding:82px 18px calc(28px + var(--rpm-safe-bottom))!important}
  .floating-header{
    top:calc(10px + var(--rpm-safe-top))!important;
    left:64px!important;
    right:10px!important;
    width:auto!important;
    height:52px!important;
    min-width:0!important;
    padding:5px 6px!important;
    border-radius:13px!important;
    overflow:visible!important;
  }
  .floating-header-left{
    position:fixed!important;
    left:10px!important;
    top:calc(10px + var(--rpm-safe-top))!important;
    z-index:1060!important;
  }
  .floating-header-left .header-btn,#menuToggle{
    display:flex!important;
    width:44px!important;
    min-width:44px!important;
    height:52px!important;
    border-radius:13px!important;
  }
  .floating-header::before{content:"RPay"!important;font-size:12px!important;padding-left:12px!important;white-space:nowrap!important}
  .floating-header::after{left:8px!important}
  .floating-header .header-btn{width:36px!important;min-width:36px!important;height:36px!important}

  /* Admin header/content */
  .main-content,.shell .main{padding:76px 18px 30px!important}
  .mobile-menu-toggle{
    position:fixed!important;
    top:calc(12px + var(--rpm-safe-top))!important;
    left:12px!important;
    z-index:1060!important;
    width:44px!important;
    height:44px!important;
    border-radius:12px!important;
    align-items:center!important;
    justify-content:center!important;
    background:var(--rp-surface)!important;
    border:1px solid var(--rp-line)!important;
    color:var(--rp-text)!important;
    box-shadow:0 10px 26px rgba(0,0,0,.18)!important;
  }
  .page-header{margin:0 0 16px!important;padding:16px!important;border-radius:14px!important}
  .page-header .header-content{display:flex!important;align-items:flex-start!important;gap:12px!important;min-width:0!important}
  .page-header .header-left{min-width:0!important;flex:1!important}
  .page-header .header-text{min-width:0!important}
  .page-header .header-text h1{font-size:20px!important;line-height:1.2!important;overflow-wrap:anywhere!important}
  .page-header .header-text p{font-size:12px!important;line-height:1.45!important}
  .header-actions{flex-wrap:wrap!important;justify-content:flex-end!important}

  /* Grids */
  .stats-grid,.dashboard-stats,.metrics-grid,.cards-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
  .charts-grid,.charts-container,.settings-grid,.document-grid,.form-grid,.content-grid,.reports-grid{grid-template-columns:1fr!important;gap:12px!important}
  .rpay-quick-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}

  /* Prevent flex/grid children from forcing horizontal overflow. */
  .main-container *,.main-content *,.shell .main *{min-width:0}
  .table-container,.table-section,.table-responsive,.transaction-table,.users-table{max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important}
  .table-container table,.table-section table,.table-responsive table,table.table{min-width:720px!important;width:max-content!important;max-width:none!important}
  .chart-card canvas,.chart-container canvas{max-width:100%!important}

  /* Forms/buttons */
  .search-form,.filter-row,.filters,.form-actions{flex-wrap:wrap!important}
  .search-form>*{min-width:0!important}
  input,select,textarea,button{max-width:100%}
}

@media (max-width:900px){
  /* Auth becomes one clean panel instead of a squeezed two-column layout. */
  body.rpay-auth .login-container,
  body.rpay-auth .register-container{
    display:block!important;
    width:100%!important;
    max-width:620px!important;
    min-height:100dvh!important;
    margin:0 auto!important;
    border:0!important;
    border-radius:0!important;
    overflow:visible!important;
    box-shadow:none!important;
    background:var(--rp-bg)!important;
  }
  body.rpay-auth .login-container::before,
  body.rpay-auth .register-container::before,
  body.rpay-auth .login-container::after,
  body.rpay-auth .register-container::after{display:none!important;content:none!important}
  body.rpay-auth .login-card,
  body.rpay-auth .register-card{
    width:100%!important;
    max-width:100%!important;
    min-height:100dvh!important;
    margin:0!important;
    padding:calc(72px + var(--rpm-safe-top)) 24px calc(34px + var(--rpm-safe-bottom))!important;
    border:0!important;
    border-radius:0!important;
    background:var(--rp-bg)!important;
    box-shadow:none!important;
  }
  body.rpay-auth .login-card .card-header,
  body.rpay-auth .register-card .card-header{padding:0 0 24px!important;margin:0!important;overflow:visible!important}
  body.rpay-auth .login-card .card-header .logo,
  body.rpay-auth .register-card .card-header .logo{
    width:126px!important;
    height:38px!important;
    max-width:126px!important;
    margin:0 0 28px!important;
    padding:0!important;
    overflow:visible!important;
  }
  body.rpay-auth .login-card .card-header .logo img,
  body.rpay-auth .register-card .card-header .logo img{
    display:block!important;
    width:126px!important;
    height:38px!important;
    max-width:126px!important;
    max-height:38px!important;
    object-fit:contain!important;
    object-position:left center!important;
  }
  body.rpay-auth.dark-mode .login-card .card-header .logo img,
  body.rpay-auth.dark-mode .register-card .card-header .logo img{filter:brightness(0) invert(1)!important;opacity:.96!important}
  body.rpay-auth .login-card .card-header h2,
  body.rpay-auth .register-card .card-header h2{font-size:30px!important;line-height:1.13!important;margin:0!important}
  body.rpay-auth .login-card .card-header p,
  body.rpay-auth .register-card .card-header p{font-size:14px!important;line-height:1.5!important;margin:8px 0 0!important;max-width:38ch!important}
  body.rpay-auth .form-row{display:grid!important;grid-template-columns:1fr!important;gap:0!important}
  body.rpay-auth .mb-3{margin-bottom:17px!important}
  body.rpay-auth .btn-login,body.rpay-auth .btn-register{height:50px!important;border-radius:12px!important;font-size:14px!important}
  body.rpay-auth .theme-toggle[aria-label="Alternar tema"],
  body.rpay-auth .theme-toggle{
    position:fixed!important;
    top:calc(14px + var(--rpm-safe-top))!important;
    right:14px!important;
    left:auto!important;
    bottom:auto!important;
    width:42px!important;
    height:42px!important;
    border-radius:12px!important;
    z-index:1200!important;
    background:var(--rp-surface-2)!important;
    border:1px solid var(--rp-line)!important;
    color:var(--rp-text)!important;
    box-shadow:none!important;
  }

  /* Backoffice login uses a different internal structure. */
  body>.login-container:has(.login-step){display:block!important;min-height:100dvh!important;padding-top:calc(64px + var(--rpm-safe-top))!important}
  body>.login-container:has(.login-step) .login-header{padding:20px 24px 8px!important;display:block!important}
  body>.login-container:has(.login-step) .login-step{padding:12px 24px 34px!important}
}

@media (max-width:600px){
  .main-container{padding:80px 12px calc(24px + var(--rpm-safe-bottom))!important}
  .main-content,.shell .main{padding:72px 12px calc(26px + var(--rpm-safe-bottom))!important}

  .stats-grid,.dashboard-stats,.metrics-grid,.cards-grid{grid-template-columns:1fr!important}
  .stat-card{min-height:104px!important;padding:14px!important}
  .stat-value{font-size:22px!important}
  .rpay-quick-actions{grid-template-columns:1fr 1fr!important;gap:8px!important;margin-bottom:14px!important}
  .rpay-quick-action{min-height:64px!important;padding:10px!important;border-radius:12px!important}
  .rpay-quick-icon{display:none!important}
  .rpay-quick-action strong{font-size:12px!important}.rpay-quick-action small{font-size:9.5px!important}

  .dashboard-title{margin-bottom:16px!important}.dashboard-title h1{font-size:24px!important}.dashboard-title p{font-size:12px!important;line-height:1.45!important}.dashboard-title::before{font-size:9px!important}
  .page-header{padding:14px!important}.page-header .header-icon{display:none!important}.page-header .header-text h1{font-size:19px!important}
  .header-actions{width:100%!important;margin:8px 0 0!important;justify-content:flex-start!important}.header-actions .header-btn,.header-actions .btn{flex:1 1 auto!important}

  .chart-card,.activity-card,.table-section,.table-container,.search-section,.profile-card,.document-card,.setting-card,.settings-card,.form-container,.card,.balance-summary{border-radius:14px!important}
  .chart-card,.activity-card,.table-section,.search-section,.profile-card,.document-card,.setting-card,.settings-card,.form-container,.balance-summary{padding:14px!important}

  .floating-header{left:62px!important;right:10px!important}
  .floating-header::before,.floating-header::after{display:none!important}
  .floating-header{justify-content:flex-end!important}

  body.rpay-auth .login-card,body.rpay-auth .register-card{padding-left:18px!important;padding-right:18px!important}
  body.rpay-auth .login-card .card-header .logo,body.rpay-auth .register-card .card-header .logo,
  body.rpay-auth .login-card .card-header .logo img,body.rpay-auth .register-card .card-header .logo img{width:112px!important;max-width:112px!important;height:34px!important;max-height:34px!important}
  body.rpay-auth .login-card .card-header h2,body.rpay-auth .register-card .card-header h2{font-size:28px!important}

  .modal-dialog{margin:10px!important;max-width:calc(100vw - 20px)!important}.modal-content{max-height:calc(100dvh - 20px)!important;overflow:auto!important}
}

@media (max-width:380px){
  body.rpay-auth .login-card,body.rpay-auth .register-card{padding-left:14px!important;padding-right:14px!important}
  .main-container,.main-content,.shell .main{padding-left:10px!important;padding-right:10px!important}
  .rpay-quick-actions{grid-template-columns:1fr!important}
}

/* Keep the supplied dark-letter RPay logo legible on dark navigation surfaces. */
html[data-theme-mode="dark"] .dashboard-sidebar .sidebar-header img,
html[data-theme-mode="dark"] .sidebar-logo,
html[data-theme-mode="dark"] .sidebar-brand img{
  filter:brightness(0) invert(1)!important;
  opacity:.96!important;
}
