/* =========================================================
   Arcendium Native-App UX Patch
   - mobile responsive dashboard
   - premium SVG light/dark toggle
   - black-tinted logo on light mode
   - blur loader + logo + loading bar
========================================================= */

:root{
  --arc-accent:#00d4a9;
  --arc-accent-2:#00b894;
  --arc-danger:#ef4444;
  --arc-bg:#f6f9fc;
  --arc-surface:#ffffff;
  --arc-surface-2:#eef4f8;
  --arc-text:#0f172a;
  --arc-muted:#64748b;
  --arc-border:rgba(15,23,42,.12);
  --arc-shadow:0 20px 60px rgba(15,23,42,.12);
}

html[data-theme="light"]{
  color-scheme:light;
  --bg:#f6f9fc;
  --bg2:#ffffff;
  --bg3:#eef4f8;
  --bg4:#e8f0f7;
  --text:#0f172a;
  --text2:#475569;
  --text3:#64748b;
  --border:rgba(15,23,42,.10);
  --border2:rgba(15,23,42,.16);
  --card-shadow:0 20px 60px rgba(15,23,42,.10);
}

html[data-theme="dark"]{
  color-scheme:dark;
  --bg:#07101a;
  --bg2:#0b1520;
  --bg3:#111c2a;
  --bg4:#172032;
  --text:#f0f4ff;
  --text2:#a8b3c7;
  --text3:#6b7890;
  --border:rgba(255,255,255,.08);
  --border2:rgba(255,255,255,.14);
  --card-shadow:0 20px 60px rgba(0,0,0,.40);
}

html,body{
  background:var(--bg)!important;
  color:var(--text)!important;
}

body{
  overflow-x:hidden;
}

/* logo visibility */
html[data-theme="light"] .logo-img,
html[data-theme="light"] .nav-logo-img,
html[data-theme="light"] .sidebar-logo-img,
html[data-theme="light"] .lo-logo,
html[data-theme="light"] img[src*="arcendium-logo-white"]{
  filter:brightness(0) saturate(100%) opacity(.92)!important;
}

html[data-theme="dark"] .logo-img,
html[data-theme="dark"] .nav-logo-img,
html[data-theme="dark"] .sidebar-logo-img,
html[data-theme="dark"] .lo-logo{
  filter:none!important;
}

/* premium SVG theme button */
.arc-theme-toggle,
.theme-toggle,
.auth-theme-toggle{
  width:44px!important;
  height:44px!important;
  min-width:44px!important;
  border-radius:999px!important;
  border:1px solid var(--border2)!important;
  background:
    radial-gradient(circle at 30% 20%, rgba(0,212,170,.16), transparent 32%),
    var(--bg2)!important;
  color:var(--text)!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  box-shadow:0 14px 35px rgba(15,23,42,.10)!important;
  cursor:pointer!important;
  padding:0!important;
  transition:transform .18s ease, border-color .18s ease, box-shadow .18s ease!important;
}

.arc-theme-toggle:hover,
.theme-toggle:hover,
.auth-theme-toggle:hover{
  transform:translateY(-1px);
  border-color:rgba(0,212,170,.55)!important;
  box-shadow:0 18px 45px rgba(0,212,170,.16)!important;
}

.arc-theme-toggle svg,
.theme-toggle svg,
.auth-theme-toggle svg{
  width:21px;
  height:21px;
}

html[data-theme="light"] .arc-theme-toggle .arc-moon,
html[data-theme="light"] .theme-toggle .arc-moon,
html[data-theme="light"] .auth-theme-toggle .arc-moon{
  display:none;
}

html[data-theme="dark"] .arc-theme-toggle .arc-sun,
html[data-theme="dark"] .theme-toggle .arc-sun,
html[data-theme="dark"] .auth-theme-toggle .arc-sun{
  display:none;
}

/* native app loader */
#arc-native-loader{
  position:fixed;
  inset:0;
  z-index:999999;
  display:none;
  align-items:center;
  justify-content:center;
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
  background:rgba(246,249,252,.58);
}

html[data-theme="dark"] #arc-native-loader{
  background:rgba(7,16,26,.58);
}

#arc-native-loader.is-active{
  display:flex;
}

.arc-loader-inner{
  width:min(340px,78vw);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:20px;
  background:transparent!important;
}

.arc-loader-logo{
  width:92px;
  height:auto;
  object-fit:contain;
}

html[data-theme="light"] .arc-loader-logo{
  filter:brightness(0) saturate(100%) opacity(.92);
}

.arc-loader-bar{
  width:100%;
  height:5px;
  border-radius:999px;
  overflow:hidden;
  background:rgba(100,116,139,.18);
  position:relative;
}

.arc-loader-bar::before{
  content:"";
  position:absolute;
  inset:0;
  width:42%;
  border-radius:999px;
  background:linear-gradient(90deg, transparent, var(--arc-accent), transparent);
  animation:arcLoadMove 1.05s ease-in-out infinite;
}

@keyframes arcLoadMove{
  0%{transform:translateX(-120%)}
  100%{transform:translateX(260%)}
}

/* mobile sidebar/dashboard fix */
.arc-mobile-menu{
  display:none;
  width:42px;
  height:42px;
  border-radius:14px;
  border:1px solid var(--border2);
  background:var(--bg2);
  color:var(--text);
  align-items:center;
  justify-content:center;
  cursor:pointer;
}

.arc-mobile-menu svg{
  width:22px;
  height:22px;
}

.arc-sidebar-backdrop{
  display:none;
}

@media(max-width:900px){
  body{
    min-width:0!important;
  }

  .arc-mobile-menu{
    display:inline-flex!important;
  }

  .dashboard-layout,
  .app-layout,
  .app-shell,
  .dashboard-shell{
    display:block!important;
    width:100%!important;
    min-width:0!important;
  }

  .sidebar,
  .dashboard-sidebar,
  aside.sidebar,
  .app-sidebar{
    position:fixed!important;
    top:0!important;
    left:0!important;
    bottom:0!important;
    width:min(310px,86vw)!important;
    max-width:86vw!important;
    height:100vh!important;
    z-index:99990!important;
    transform:translateX(-105%)!important;
    transition:transform .24s ease!important;
    overflow-y:auto!important;
    background:var(--bg2)!important;
    box-shadow:24px 0 60px rgba(15,23,42,.22)!important;
  }

  body.arc-sidebar-open .sidebar,
  body.arc-sidebar-open .dashboard-sidebar,
  body.arc-sidebar-open aside.sidebar,
  body.arc-sidebar-open .app-sidebar{
    transform:translateX(0)!important;
  }

  body.arc-sidebar-open .arc-sidebar-backdrop{
    display:block!important;
    position:fixed;
    inset:0;
    z-index:99980;
    background:rgba(15,23,42,.34);
    backdrop-filter:blur(5px);
    -webkit-backdrop-filter:blur(5px);
  }

  .main-content,
  .dashboard-main,
  main,
  .page-content,
  .content{
    width:100%!important;
    max-width:100%!important;
    margin-left:0!important;
    padding:16px 12px!important;
    overflow-x:hidden!important;
  }

  .topbar,
  .dashboard-topbar,
  .nav,
  header{
    width:100%!important;
    max-width:100%!important;
    position:sticky;
    top:0;
    z-index:200;
  }

  .topbar,
  .dashboard-topbar{
    display:flex!important;
    align-items:center!important;
    gap:10px!important;
    padding:12px!important;
    overflow-x:auto!important;
  }

  .topbar-actions,
  .nav-actions,
  .header-actions{
    display:flex!important;
    align-items:center!important;
    gap:8px!important;
    flex-wrap:nowrap!important;
  }

  .stats-grid,
  .dashboard-grid,
  .cards-grid,
  .marketplace-grid,
  .admin-grid,
  .analytics-grid,
  .settings-grid,
  .form-grid,
  .grid{
    grid-template-columns:1fr!important;
  }

  .card,
  .stat-card,
  .dashboard-card,
  .panel,
  .table-card{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
  }

  .table-responsive,
  .table-wrap,
  .data-table-wrap,
  .admin-table-wrap,
  .positions-table-wrap{
    width:100%!important;
    max-width:100%!important;
    overflow-x:auto!important;
    -webkit-overflow-scrolling:touch!important;
  }

  table{
    min-width:760px;
  }

  .actions,
  .card-actions,
  .form-actions,
  .button-row{
    display:flex!important;
    flex-wrap:wrap!important;
    gap:8px!important;
  }

  input,
  select,
  textarea,
  button{
    max-width:100%!important;
  }

  .landing-hero,
  .hero,
  .hero-grid{
    grid-template-columns:1fr!important;
    padding-left:16px!important;
    padding-right:16px!important;
  }

  .hero-title,
  h1{
    font-size:clamp(2rem,9vw,3rem)!important;
    line-height:1.05!important;
  }
}

/* smoother premium loader timing/feel */
#arc-native-loader{
  opacity:0;
  pointer-events:none;
  transition:opacity .28s ease;
}
#arc-native-loader.is-active{
  opacity:1;
  pointer-events:auto;
}
.arc-loader-logo{
  animation:arcLogoFloat 1.15s ease-in-out infinite alternate;
}
.arc-loader-bar::before{
  animation:arcLoadMove 1.15s ease-in-out infinite;
}
@keyframes arcLogoFloat{
  from{transform:translateY(0) scale(1)}
  to{transform:translateY(-4px) scale(1.025)}
}

/* Medium-screen responsive hardening for tablets and small laptops */
@media(max-width:1180px){
  body:not(.landing-page){min-width:0!important;overflow-x:hidden!important;}

  body:not(.landing-page) .app-layout,
  body:not(.landing-page) .dashboard-layout,
  body:not(.landing-page) .app-shell,
  body:not(.landing-page) .dashboard-shell{
    display:block!important;
    width:100%!important;
    min-width:0!important;
  }

  body:not(.landing-page) .main-content,
  body:not(.landing-page) .dashboard-main,
  body:not(.landing-page) main,
  body:not(.landing-page) .content{
    width:100%!important;
    max-width:100%!important;
    margin-left:0!important;
    min-width:0!important;
  }

  body:not(.landing-page) .page-content{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    padding:18px!important;
    overflow-x:hidden!important;
  }

  body:not(.landing-page) .topbar,
  body:not(.landing-page) .dashboard-topbar{
    width:100%!important;
    max-width:100%!important;
    padding:12px 14px!important;
    gap:10px!important;
  }

  body:not(.landing-page) .topbar-left,
  body:not(.landing-page) .topbar-right{
    min-width:0!important;
  }

  body:not(.landing-page) .page-title{
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
    max-width:52vw!important;
  }

  body:not(.landing-page) .card,
  body:not(.landing-page) .stat-card,
  body:not(.landing-page) .dashboard-card,
  body:not(.landing-page) .panel,
  body:not(.landing-page) .table-card,
  body:not(.landing-page) .modal{
    max-width:100%!important;
    min-width:0!important;
  }

  body:not(.landing-page) .table-wrap,
  body:not(.landing-page) .table-responsive,
  body:not(.landing-page) .data-table-wrap,
  body:not(.landing-page) .admin-table-wrap{
    width:100%!important;
    max-width:100%!important;
    overflow-x:auto!important;
    -webkit-overflow-scrolling:touch!important;
  }

  body:not(.landing-page) table{min-width:760px;}

  body:not(.landing-page) .card-header,
  body:not(.landing-page) .filter-bar,
  body:not(.landing-page) .modal-footer{
    flex-wrap:wrap!important;
    gap:10px!important;
  }

  body:not(.landing-page) .form-row-3{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  body:not(.landing-page) .form-row-2{grid-template-columns:repeat(2,minmax(0,1fr))!important;}

  body:not(.landing-page) [style*="grid-template-columns:2fr 1fr"],
  body:not(.landing-page) [style*="grid-template-columns: 2fr 1fr"]{
    grid-template-columns:1fr!important;
  }
}

@media(min-width:769px) and (max-width:1180px){
  body:not(.landing-page) .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  body:not(.landing-page) .master-cards-grid{grid-template-columns:repeat(2,minmax(260px,1fr))!important;}
}

@media(max-width:680px){
  body:not(.landing-page) .stats-grid,
  body:not(.landing-page) .master-cards-grid,
  body:not(.landing-page) .form-row-2,
  body:not(.landing-page) .form-row-3{
    grid-template-columns:1fr!important;
  }
  body:not(.landing-page) .page-content{padding:14px 10px!important;}
  body:not(.landing-page) .modal-footer .btn{width:100%;justify-content:center;}
}
