/* global.css — layout/reset + komponen dasar (sesuai UI Contract) */

/* --- Reset --- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: var(--text);
}

/* --- Layout shell --- */
.app-shell{ display:flex; min-height:100vh; }

.app-sidebar{
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform .2s ease, width .2s ease;
}

.app-main{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Background mengikuti contoh: merah di bagian atas lalu turun ke abu */
  background: linear-gradient(180deg, var(--brand-primary) 0, var(--brand-primary) 160px, #f3f4f6 160px);
}

/* --- Sidebar header --- */
.sidebar-header{
  padding: 14px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.brand-pill{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 12px 14px;
  border-radius: 999px;
  text-decoration:none;
  background: var(--brand-primary);
  color: #fff;
  font-weight: 800;
  letter-spacing: .2px;
}
.brand-pill-logo{
  display:block;
  max-height: 22px;
  max-width: 170px;
  object-fit: contain;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.12));
}
.brand-name{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.sidebar-sub{
  display:flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}
.brand-logo{
  width: 42px; height: 42px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  object-fit: cover;
}
.sidebar-subtext{ min-width:0; }
.sub-strong{ font-weight: 700; font-size: 13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.help{ color: #6b7280; font-size: 12px; }


/* --- Sidebar nav --- */
.sidebar-nav{ padding: 10px 12px 14px; display:grid; gap: 6px; }
.nav-section{
  margin-top: 10px;
  font-size: 11px;
  color: #6b7280;
  letter-spacing: .12em;
  font-weight: 700;
}
.nav-item{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 10px 10px;
  border-radius: 12px;
  text-decoration:none;
  color: inherit;
  border: 1px solid transparent;
}
.nav-item:hover{
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.06);
}
.nav-item.active{
  background: rgba(176,0,0,0.08);
  border-color: rgba(176,0,0,0.18);
}
.nav-ico{ width: 22px; display:inline-flex; justify-content:center; }
.nav-label{ min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.nav-subwrap{
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 8px;
  background: #fff;
}
.nav-subtitle{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 8px 8px 6px;
  font-weight: 700;
  color: #111827;
}
.nav-sub{
  display:flex;
  align-items:center;
  position: relative;
  padding: 9px 10px;
  margin-left: 28px;
  border-radius: 12px;
  text-decoration:none;
  color: #111827;
  border: 1px solid transparent;
}
.nav-sub::before{
  content: "•";
  display: inline-block;
  width: 14px;
  text-align: center;
  margin-right: 6px;
  color: rgba(176,0,0,0.75);
  font-size: 16px;
  line-height: 1;
}
.nav-sub:hover{
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.06);
}
.nav-sub.active{
  background: rgba(176,0,0,0.08);
  border-color: rgba(176,0,0,0.18);
}
.nav-sep{ height: 1px; background: rgba(0,0,0,0.06); margin: 8px 0; }

/* --- Topbar --- */
.app-topbar{
  position: sticky;
  top: 0;
  z-index: 30;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--topbar-bg);
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.topbar-left{ display:flex; align-items:center; gap: 10px; min-width:0; }
.topbar-title{
  color: #fff;
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right{ display:flex; align-items:center; gap: 10px; flex-wrap: wrap; justify-content:flex-end; }
.topbar-time{
  color: rgba(255,255,255,0.9);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
}
.user-pill{
  color: #111827;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
}

/* Buttons */
.icon-btn{
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.btn{
  border: 1px solid rgba(0,0,0,0.10);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary{
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.btn-ghost{
  background: rgba(255,255,255,0.95);
  border-color: rgba(255,255,255,0.35);
  color: #111827;
  font-weight: 800;
}

/* Content */
.app-content{ padding: 12px; min-width:0; 
  flex: 1;
}
.app-breadcrumb{
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-breadcrumb a{ color: rgba(255,255,255,0.95); text-decoration: none; }
.app-breadcrumb a:hover{ text-decoration: underline; }

.page-inner{
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 18px;
  padding: 14px;
  min-width:0;
  box-shadow: 0 14px 40px rgba(0,0,0,0.08);
}
.page-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.page-head h1{ margin:0; font-size: 18px; }
.page-actions{ display:flex; gap: 8px; flex-wrap: wrap; align-items:center; }
.page-body{ min-width:0; }

/* Footer */
.app-footer{
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid rgba(0,0,0,0.08);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}


/* Cards, tables, forms */
.card{
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}
.card-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:10px; }
.card-title{ font-weight: 800; }

.table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table{ width:100%; border-collapse: collapse; min-width: 520px; }
.table th, .table td{ border-bottom: 1px solid rgba(0,0,0,0.08); text-align:left; padding: 10px 8px; font-size: 14px; }
.table th{ font-size: 12px; color: #6b7280; font-weight: 800; }

.form{ display:grid; gap: 10px; }
.form-grid{ display:grid; gap:10px; }
.grid-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field{ display:grid; gap: 6px; min-width:0; }
.field span{ font-size: 12px; color: #6b7280; font-weight: 700; }
.field input{
  width:100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  outline: none;
}
.field input:focus{
  border-color: rgba(176,0,0,0.45);
  box-shadow: 0 0 0 3px rgba(176,0,0,0.12);
}

.filter-bar{
  border: 1px dashed rgba(0,0,0,0.14);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafafa;
}

/* Alerts */
.alert{
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.10);
  margin-bottom: 10px;
}
.alert-danger{ background: #fff5f5; border-color: #fed7d7; color: #9b2c2c; }
.alert-ok{ background: #f0fff4; border-color: #c6f6d5; color: #22543d; }

/* Badge */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(0,0,0,0.08);
}
.badge-ok{ background: #f0fff4; color: #22543d; border-color:#c6f6d5; }
.badge-muted{ background:#f3f4f6; color:#374151; }


/* --- Auth layout --- */
.auth-shell{
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(180deg, var(--brand-primary) 0, var(--brand-primary) 220px, #f3f4f6 220px);
}
.auth-card{
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.12);
}
.auth-brand{
  display:flex;
  gap: 10px;
  align-items:center;
  margin-bottom: 12px;
}
.auth-brand-name{ font-weight: 900; }
.auth-brand-sub{ font-size: 12px; color: #6b7280; }

/* Match Corel sample: centered logo + title */
.auth-logo-wrap{
  width: 84px;
  height: 84px;
  margin: 4px auto 10px;
  border-radius: 999px;
  border: 3px solid rgba(0,0,0,0.10);
  display: grid;
  place-items: center;
  background: #fff;
}
.auth-logo{ width: 56px; height: 56px; object-fit: contain; }

.auth-brand-name{
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  margin: 2px 0 2px;
}
.auth-brand-sub{
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.auth-body{ margin-top: 10px; }
.auth-footer{
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
}

.auth-form{ display:flex; flex-direction: column; gap: 12px; }
.input-group{ position: relative; display:block; }
.input-group input{
  width: 100%;
  height: 44px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 12px;
  padding: 0 44px 0 44px;
  outline: none;
  background: #fff;
}
.input-group input:focus{
  border-color: rgba(0,0,0,0.22);
  box-shadow: 0 0 0 3px rgba(176,0,0,0.10);
}
.input-icon{
  position:absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(0,0,0,0.45);
  pointer-events: none;
}
.input-action{
  position:absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(0,0,0,0.45);
  cursor: pointer;
}
.input-action:hover{ background: rgba(0,0,0,0.05); }

.btn-block{ width: 100%; }
.btn-primary{
  background: var(--brand-primary);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 14px;
  font-weight: 900;
}
.btn-primary:hover{ filter: brightness(0.95); }

.help{ font-size: 12px; color: var(--muted); margin: 0; }
.center{ text-align: center; }

/* Branding preview */
.branding-preview{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.preview-box{
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 10px;
  background: #fff;
}

/* --- Mobile off-canvas sidebar --- */
.backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 50;
}

/* Desktop collapse */
.app-sidebar[data-state="collapsed"]{ width: 78px; }
.app-sidebar[data-state="collapsed"] .brand-name,
.app-sidebar[data-state="collapsed"] .sidebar-subtext,
.app-sidebar[data-state="collapsed"] .nav-section,
.app-sidebar[data-state="collapsed"] .nav-label{ display:none; }
.app-sidebar[data-state="collapsed"] .brand-pill{ justify-content:center; padding: 10px; gap: 8px; }
.app-sidebar[data-state="collapsed"] .brand-pill-logo{ max-width: 28px; }
.app-sidebar[data-state="collapsed"] .nav-subwrap{ padding: 8px 6px; }
.app-sidebar[data-state="collapsed"] .nav-subtitle{ justify-content:center; }
.app-sidebar[data-state="collapsed"] .nav-sub{ margin-left: 0; justify-content:center; }

/* Responsive */
@media (max-width: 860px){
  .app-main{ background: linear-gradient(180deg, var(--brand-primary) 0, var(--brand-primary) 160px, #f3f4f6 160px); }
  .app-sidebar{
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    z-index: 60;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  }
  .app-sidebar[data-open="1"]{ transform: translateX(0); }
  .app-footer{
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid rgba(0,0,0,0.08);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}

  .app-breadcrumb{ color: rgba(255,255,255,0.95); }
}

@media (max-width: 720px){
  .grid-2, .grid-3{ grid-template-columns: 1fr; }
  .branding-preview{ grid-template-columns: 1fr; }
  .table{ min-width: 420px; }
}

@media (max-width: 360px){
  .app-content{ padding: 10px; }
  .page-inner{ padding: 12px; }
  .btn{ padding: 10px 10px; }
}


/* --- Sidebar brand header controls --- */
.brand-toggle{
  width: 34px; height: 34px;
  border: 0;
  border-radius: 12px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.brand-link{
  color:#fff;
  text-decoration:none;
  display:flex;
  align-items:center;
  min-width:0;
}
