/* ============================================================
   Work Desktop — style.css
   ============================================================ */

:root {
  --bg1: #12151c;
  --bg2: #0a0c10;
  --stroke: rgba(255,255,255,.10);
  --stroke-hi: rgba(255,255,255,.22);
  --shadow: 0 24px 48px rgba(0,0,0,.6);
  --shadow2: 0 8px 20px rgba(0,0,0,.4);
  --radius: 16px;
  --pad: 10px;
  --gap: 10px;
  --icon: 62px;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
  --accent: #4f8fff;
  --accent2: #7c5cff;
  --green: #22e87a;
  --amber: #ffba2e;
  --red: #ff4d4d;
}

html, body {
  height: 100%; margin: 0;
  font-family: var(--font);
  color: #dde3ef;
  background:
    radial-gradient(ellipse 1400px 700px at 20% 0%, #1c2a4a 0%, transparent 65%),
    radial-gradient(ellipse 900px 600px at 90% 20%, #1a1f38 0%, transparent 60%),
    linear-gradient(160deg, #13161e 0%, var(--bg2) 100%);
  overflow: hidden;
}
* { box-sizing: border-box; }

/* Grain overlay */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: .45;
}

/* ---- TOPBAR ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(10,12,16,.75);
  border-bottom: 1px solid rgba(255,255,255,.07);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-brand {
  font-weight: 900; font-size: 14px; letter-spacing: .5px;
  color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.topbar-brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.6;transform:scale(.85)} }

.topbar-clock {
  font-family: var(--mono);
  font-size: 13px; opacity: .6;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

.tag {
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  padding: 4px 9px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  white-space: nowrap;
}
.tag.saving { color: var(--amber); border-color: rgba(255,186,46,.25); background: rgba(255,186,46,.08); }
.tag.saved  { color: var(--green); border-color: rgba(34,232,122,.22);  background: rgba(34,232,122,.07); }
.tag.error  { color: var(--red);   border-color: rgba(255,77,77,.22);   background: rgba(255,77,77,.07); }

.btn-top {
  height: 34px; min-width: 34px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07);
  color: #dde3ef; cursor: pointer; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; font-family: var(--font);
  padding: 0 10px; transition: all .15s;
  user-select: none; touch-action: manipulation;
}
.btn-top:hover  { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.22); }
.btn-top:active { transform: scale(.96); }
.btn-top.on     { background: rgba(79,143,255,.18); border-color: rgba(79,143,255,.4); color: var(--accent); }

/* ---- LAYOUT ---- */
.wrap {
  position: fixed; inset: 52px 0 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}
.launcher { max-width: 1200px; margin: 0 auto; width: 100%; }
.main-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 10px; min-height: 0;
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.left-col  { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.right-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- PANEL ---- */
.win {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: linear-gradient(175deg, rgba(255,255,255,.07) 0%, rgba(255,255,255,.025) 100%);
  box-shadow: var(--shadow2), inset 0 1px 0 rgba(255,255,255,.08);
  overflow: hidden; min-height: 0;
  transition: box-shadow .2s, transform .2s;
}
.win.drag-over { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.win.collapsed .content { height: 0; overflow: hidden; padding: 0; }
.win.collapsed .collapse-btn { transform: rotate(-90deg); }

/* ---- TITLEBAR ---- */
.titlebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 10px;
  font-weight: 800; font-size: 12px; letter-spacing: .4px;
  text-shadow: 0 1px 0 rgba(0,0,0,.5);
  border-bottom: 1px solid rgba(0,0,0,.3);
  user-select: none; cursor: default;
}
.titlebar .t-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.titlebar .t-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.badge {
  width: 16px; height: 16px; border-radius: 5px; flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 2px 8px rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.15);
}
.title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.win-drag-handle {
  width: 16px; height: 16px; display: flex; flex-direction: column;
  justify-content: center; gap: 3px; cursor: grab; opacity: .4;
  transition: opacity .15s; flex: 0 0 auto;
}
.win-drag-handle:hover { opacity: .9; }
.win-drag-handle span { display: block; height: 1.5px; background: currentColor; border-radius: 2px; }

.icon-btn {
  width: 24px; height: 24px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
  display: grid; place-items: center;
  cursor: pointer; font-size: 12px;
  transition: all .15s; color: inherit; opacity: .8;
}
.icon-btn:hover  { opacity: 1; border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.10); }
.icon-btn.hidden { display: none; }
.collapse-btn    { transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .15s; }

/* ---- CONTENT ---- */
.content {
  padding: var(--pad); overflow: auto;
  transition: height .25s cubic-bezier(.4,0,.2,1);
}

/* ---- APP GRID ---- */
.icons { display: grid; gap: var(--gap); align-items: start; }
.icons.dock {
  grid-auto-flow: column;
  grid-auto-columns: minmax(80px, 1fr);
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin;
}

/* ---- APP TILE ---- */
.app {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 7px;
  padding: 10px 8px 9px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10);
  text-decoration: none; color: inherit;
  min-height: calc(var(--icon) + 38px);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none; cursor: pointer;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), border-color .15s, box-shadow .15s, background .15s;
  will-change: transform;
}
.app::after {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle at 50% 0%, rgba(255,255,255,.10), transparent 65%);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.app:hover {
  transform: translateY(-3px) scale(1.03);
  border-color: rgba(255,255,255,.24);
  box-shadow: 0 12px 28px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.18);
}
.app:hover::after { opacity: 1; }
.app:active { transform: scale(.96) translateY(0); }

/* Ripple */
.app .ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.3);
  transform: scale(0); animation: ripple-anim .5s linear forwards;
  pointer-events: none;
}
@keyframes ripple-anim { to { transform: scale(4); opacity: 0; } }

.app .ico {
  position: relative;
  width: var(--icon); height: var(--icon); border-radius: 15px;
  display: grid; place-items: center;
  font-weight: 900; font-size: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.20), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 8px 20px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.35);
  overflow: hidden;
  transition: box-shadow .15s;
}
.app:hover .ico { box-shadow: 0 12px 28px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.5); }
.app img { width: 100%; height: 100%; object-fit: cover; display: block; }

.app .lbl {
  font-size: 11px; font-weight: 600; text-align: center;
  line-height: 1.2; opacity: .9; word-break: break-word; letter-spacing: .1px;
}

/* Overlay badge */
.app[data-overlay="true"] .ico::after {
  content: '⧉';
  position: absolute; bottom: -2px; right: -2px;
  font-size: 11px; background: var(--accent2);
  border-radius: 5px; padding: 1px 3px; line-height: 1; color: #fff;
}

/* Edit mode */
.edit-mode .app { cursor: grab; animation: wiggle .35s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-1deg); } to { transform: rotate(1deg); } }
.edit-mode .app:hover { animation: none; transform: scale(1.05); cursor: grab; }
.edit-mode .app:active { cursor: grabbing; animation: none; }

.app .edit-overlay {
  position: absolute; inset: 0; border-radius: inherit;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; background: rgba(0,0,0,.6); backdrop-filter: blur(2px);
}
.edit-mode .app:hover .edit-overlay { display: flex; }

.edit-overlay-btn {
  font-size: 10px; font-weight: 700; padding: 4px 10px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.12); cursor: pointer; color: #fff;
  transition: background .15s;
}
.edit-overlay-btn:hover     { background: rgba(255,255,255,.22); }
.edit-overlay-btn.del       { background: rgba(255,60,60,.2); border-color: rgba(255,60,60,.3); }
.edit-overlay-btn.del:hover { background: rgba(255,60,60,.4); }

.app .drag-handle {
  position: absolute; top: 6px; left: 6px;
  width: 18px; height: 18px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.35);
  display: none; place-items: center;
  font-size: 11px; cursor: grab; opacity: .8;
}
.edit-mode .app .drag-handle { display: grid; }

/* Drop placeholder */
.drop-placeholder {
  border-radius: 14px;
  border: 2px dashed rgba(79,143,255,.4);
  background: rgba(79,143,255,.05);
  min-height: calc(var(--icon) + 38px);
  animation: placeholder-pulse .8s ease-in-out infinite alternate;
}
@keyframes placeholder-pulse { from{opacity:.5} to{opacity:1} }

/* ---- THEMES ---- */
.theme-general  .titlebar { background: linear-gradient(180deg, #3f5a8a, #243655); }
.theme-general  .badge    { background: linear-gradient(180deg, #4f8fff, #2555cc); }
.theme-security .titlebar { background: linear-gradient(180deg, #2a71ff, #0d3fb6); }
.theme-security .badge    { background: linear-gradient(180deg, #ffcb3a, #b87400); }
.theme-parking  .titlebar { background: linear-gradient(180deg, #1aaa56, #0a5c2d); }
.theme-parking  .badge    { background: linear-gradient(180deg, #22e87a, #0a8b3e); }
.theme-admin    .titlebar { background: linear-gradient(180deg, #6644cc, #3d2299); }
.theme-admin    .badge    { background: linear-gradient(180deg, #aa88ff, #7744cc); }
.theme-personal .titlebar { background: linear-gradient(180deg, #cc3366, #881133); }
.theme-personal .badge    { background: linear-gradient(180deg, #ff6699, #cc2255); }
.theme-main     .titlebar { background: linear-gradient(180deg, #2a3040, #1a2030); }
.theme-main     .badge    { background: linear-gradient(180deg, #8899cc, #4455aa); }
.theme-tools    .titlebar { background: linear-gradient(180deg, #2a3a50, #1a2535); }
.theme-tools    .badge    { background: linear-gradient(180deg, #55aacc, #2277aa); }

/* ---- MODAL ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.65);
  display: none; place-items: center; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-back.show { display: grid; }
.modal {
  width: min(680px, 96vw);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(16,18,26,.94);
  box-shadow: 0 32px 64px rgba(0,0,0,.7);
  overflow: hidden;
  animation: modal-in .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modal-in { from { transform: scale(.9) translateY(12px); opacity: 0; } }
.modal .mbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 900; font-size: 13px;
}
.modal .mcontent {
  padding: 12px 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; font-weight: 600; opacity: .9; letter-spacing: .2px;
}
.field input, .field select, .field textarea {
  height: 34px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.4); color: #dde3ef;
  padding: 0 10px; outline: none;
  font-size: 12px; font-family: var(--font);
  transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: rgba(79,143,255,.5); }
.field textarea { height: 60px; resize: vertical; padding: 8px 10px; }
.modal .mactions {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.08);
}

.btn {
  height: 34px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08); color: #dde3ef;
  padding: 0 14px; font-weight: 700; cursor: pointer;
  user-select: none; touch-action: manipulation;
  font-size: 12px; font-family: var(--font);
  transition: all .15s;
}
.btn:hover           { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.22); }
.btn.primary         { background: rgba(79,143,255,.25); border-color: rgba(79,143,255,.45); color: #88aaff; }
.btn.primary:hover   { background: rgba(79,143,255,.4); }
.btn.secondary       { background: rgba(0,0,0,.35); }
.btn.danger          { background: rgba(255,60,60,.12); border-color: rgba(255,60,60,.3); color: var(--red); }
.btn.danger:hover    { background: rgba(255,60,60,.25); }
.btn:active          { transform: scale(.97); }

/* ---- OVERLAY ---- */
.overlay-back {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,.75);
  display: none; flex-direction: column;
  backdrop-filter: blur(6px);
}
.overlay-back.show { display: flex; }
.overlay-topbar {
  height: 44px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: rgba(12,14,20,.9);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.overlay-title {
  font-weight: 700; font-size: 13px; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.overlay-url {
  font-size: 11px; opacity: .5; font-family: var(--mono); flex: 2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.overlay-frame { flex: 1; border: none; background: #fff; }
.overlay-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  position: absolute; inset: 44px 0 0;
  background: rgba(10,12,16,.95);
  font-size: 13px; opacity: .6; pointer-events: none;
}
.overlay-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- NOTEPAD ---- */
.notepad-wrap { display: flex; flex-direction: column; gap: 8px; }
.np-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
}
.np-group {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}
.np-toolbar label { font-size: 11px; opacity: .7; font-weight: 600; }
.np-toolbar input[type="color"]  { width: 28px; height: 22px; border: 0; background: transparent; padding: 0; cursor: pointer; }
.np-toolbar input[type="range"]  { width: 80px; accent-color: var(--accent); }
.np-toolbar input[type="number"],
.np-toolbar input[type="text"] {
  height: 26px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35); color: #dde3ef;
  padding: 0 8px; outline: none;
  font-size: 12px; font-family: var(--font);
}
.canvas-shell {
  border-radius: 12px; border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.20); overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
canvas {
  display: block; width: 100%;
  height: clamp(200px, 28vh, 380px);
  touch-action: none; cursor: crosshair;
}
.muted { opacity: .55; font-size: 11px; font-family: var(--mono); }

/* ---- STATUS / TOOLS PANEL ---- */
.status-panel { padding: 4px; }
.status-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
  font-size: 12px; opacity: .7;
  transition: background .15s;
}
.status-row:hover { background: rgba(255,255,255,.04); opacity: 1; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex: 0 0 auto; background: var(--green);
}

/* ---- SEARCH ---- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 36px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.3);
  transition: border-color .15s;
}
.search-bar:focus-within { border-color: rgba(79,143,255,.4); }
.search-bar input {
  background: none; border: none; outline: none;
  color: #dde3ef; font-size: 13px; font-family: var(--font); flex: 1;
}
.search-bar .search-icon { opacity: .4; font-size: 14px; }

/* ---- NOTIFICATIONS ---- */
.notif-tray {
  position: fixed; bottom: 16px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.notif {
  max-width: 300px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(18,22,32,.95);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  font-size: 12px; line-height: 1.4;
  animation: notif-in .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
}
.notif.success { border-color: rgba(34,232,122,.3); }
.notif.error   { border-color: rgba(255,77,77,.3); }
@keyframes notif-in  { from { transform: translateX(20px) scale(.9); opacity: 0; } }
@keyframes notif-out { to   { transform: translateX(20px) scale(.9); opacity: 0; } }

/* ---- RESPONSIVE ---- */
@media (max-width: 920px) {
  body { overflow: auto; }
  .wrap { position: relative; inset: auto; padding-top: 8px; overflow: visible; }
  .main-grid { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}
