/* =====================================================================
   Kambana OS - shared components for apps.
   Use these classes in app markup so every app feels like one system.

   Buttons     .btn  .btn-primary  .btn-danger  .btn-sm   .icon-btn (.big)
   Inputs      .input  .select  .textarea  .switch>input+span  .range
   Chips       .chip (.on)        Segmented   .seg > button (.on)
   Layout      .app-split > .app-side + .app-main      .toolbar  .toolbar-spacer
   Sidebar     .side-group-label  .side-item (.on)
   Content     .card  .row  .list  .list-row  .badge  .muted  .kbd  .empty-state
   ===================================================================== */

/* scrollbars inside windows */
.win ::-webkit-scrollbar, .panel ::-webkit-scrollbar, .sp-results::-webkit-scrollbar { width: 10px; height: 10px; }
.win ::-webkit-scrollbar-thumb, .panel ::-webkit-scrollbar-thumb, .sp-results::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.win ::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); }
.win ::-webkit-scrollbar-track { background: transparent; }
.win * { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* buttons */
.btn {
  height: 32px; padding: 0 14px; border-radius: var(--r-ctl); border: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--tile); color: var(--text); box-shadow: inset 0 0 0 1px var(--line);
  transition: background .12s, filter .12s, transform .08s;
}
.btn:hover { background: var(--tile-hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: #e5484d; color: #fff; box-shadow: none; }
.btn-danger:hover { background: #e5484d; filter: brightness(1.08); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn .ic { display: inline; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 0; background: none; color: var(--text);
  display: inline-grid; place-items: center; padding: 0; flex: 0 0 auto; transition: background .12s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { background: var(--press); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.on { background: var(--tile-hover); color: var(--accent); }
.icon-btn.big { width: 40px; height: 40px; border-radius: 50%; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font-size: inherit; }
.link:hover { text-decoration: underline; }

/* inputs */
.input, .select, .textarea {
  height: 34px; padding: 0 12px; border-radius: var(--r-ctl); border: 0; outline: none;
  background: var(--surface-2); color: var(--text); font-size: 13.5px;
  box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { padding-right: 30px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field > span:first-child, .search-field > .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; display: grid; z-index: 1; }
.search-field .input { padding-left: 32px; width: 100%; }

/* switch */
.switch { position: relative; display: inline-block; width: 42px; height: 25px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2); transition: background .18s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--accent); box-shadow: none; }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%)); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); cursor: pointer; }
.range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }

/* chips + segmented */
.chip { height: 28px; padding: 0 12px; border-radius: 14px; border: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; background: var(--tile); color: var(--text-2); white-space: nowrap; transition: background .12s, color .12s; }
.chip:hover { background: var(--tile-hover); color: var(--text); }
.chip.on, .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.chip .ic { display: inline; }
.seg { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--tile); gap: 2px; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 8px; background: none; font-size: 12.5px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
[data-theme="dark"] .seg button.on { background: var(--surface-3); }

/* app layout: sidebar + main */
.app-split { display: flex; flex: 1; min-height: 0; }
.app-side {
  width: 220px; flex: 0 0 auto; overflow-y: auto; padding: 10px 8px;
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1px;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.side-group-label { font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 12px 10px 4px; }
.side-group-label:first-child { padding-top: 4px; }
.side-item {
  height: 32px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; background: none; border-radius: 8px;
  color: var(--text); font-size: 13px; font-weight: 500; text-align: left; width: 100%; min-width: 0;
}
.side-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .ic { color: var(--accent); }
.side-item:hover { background: var(--hover); }
.side-item.on { background: var(--tile-hover); font-weight: 600; }
.side-item .count { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* toolbar row (inside app-main or window body) */
.toolbar { height: 48px; flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.toolbar-spacer { flex: 1; }
.toolbar h2 { margin: 0 6px; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* content */
.card { background: var(--surface-2); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.row { display: flex; align-items: center; gap: 10px; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 48px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--tile); color: var(--text-2); white-space: nowrap; }
.badge .ic { display: inline; }
.badge.accent { background: rgba(var(--accent-rgb), .18); color: var(--accent); }
.badge.android { background: rgba(34, 165, 101, .16); color: #22a565; }
.badge.windows { background: rgba(47, 124, 246, .16); color: #4b8ff7; }
.badge.linux { background: rgba(231, 164, 0, .18); color: #d29500; }
.badge.web { background: rgba(124, 108, 255, .18); color: #8f82ff; }
.muted { color: var(--text-2); }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--tile); box-shadow: inset 0 -1px 0 var(--line-2); }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px; text-align: center; color: var(--text-2); }
.empty-state h3 { margin: 6px 0 0; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0; max-width: 340px; font-size: 13px; }
.scroll { overflow: auto; min-height: 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); border-radius: 2px; transition: width .2s; }
/* an empty state always spans the whole area, even inside a grid */
.empty-state { grid-column: 1 / -1; min-width: 0; width: 100%; }
