/* ==========================================================================
   IAA OS — Desktop Environment
   ========================================================================== */

#desktop {
  position: fixed;
  inset: 0;
  display: none;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(74, 143, 224, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(94, 199, 232, 0.04) 0%, transparent 50%),
    linear-gradient(135deg, #060c18 0%, #0a1220 50%, #060c18 100%);
  overflow: hidden;
}

#desktop.active { display: block; animation: desktopFade 0.5s ease; }

@keyframes desktopFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Desktop background grid */
.desktop-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(74, 143, 224, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 143, 224, 0.025) 1px, transparent 1px);
  background-size: 80px 80px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 90%);
}

.desktop-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 500px;
  opacity: 0.06;
  pointer-events: none;
}

.desktop-watermark svg,
.desktop-watermark img {
  display: block;
  width: 500px;
  height: 500px;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   Top status bar
   ========================================================================== */
.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.95) 0%, rgba(10, 18, 32, 0.85) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 1000;
  gap: 20px;
}

.status-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(196, 47, 61, 0.15);
  border: 1px solid rgba(196, 47, 61, 0.35);
  color: var(--classified-red);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 2px;
}

.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--classified-red);
  border-radius: 50%;
  animation: redBlink 1.5s ease-in-out infinite;
}

.status-bar .sep {
  color: var(--text-dim);
}

.status-bar-center {
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 3px;
}

.status-bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-clock {
  font-variant-numeric: tabular-nums;
  color: var(--accent-cyan);
}

.status-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 3px 10px;
  transition: background 0.2s;
}

.status-agent:hover { background: var(--bg-hover); }

.status-agent-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
}

/* Service toggle button */
.service-toggle {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 3px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  text-transform: uppercase;
}

.service-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.service-toggle.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--status-low);
  color: var(--status-low);
}

.service-toggle.active:hover {
  background: rgba(34, 197, 94, 0.25);
}

.service-toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.2s;
}

.service-toggle.active .service-toggle-dot {
  background: var(--status-low);
  box-shadow: 0 0 8px var(--status-low);
  animation: serviceDotPulse 2s ease-in-out infinite;
}

@keyframes serviceDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.service-toggle-time {
  font-variant-numeric: tabular-nums;
  color: var(--accent-cyan);
  font-weight: 600;
  display: none;
}

.service-toggle.active .service-toggle-time {
  display: inline;
}

/* ==========================================================================
   Desktop icons
   ========================================================================== */
.desktop-icons {
  position: absolute;
  top: 60px;
  left: 24px;
  bottom: 60px;
  width: 360px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  gap: 14px 8px;
  padding: 10px;
  align-content: start;
}

.desktop-icon {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
  opacity: 0;
  animation: iconFadeIn 0.4s var(--ease-snap) forwards;
}

.desktop-icon:nth-child(1) { animation-delay: 0.05s; }
.desktop-icon:nth-child(2) { animation-delay: 0.10s; }
.desktop-icon:nth-child(3) { animation-delay: 0.15s; }
.desktop-icon:nth-child(4) { animation-delay: 0.20s; }
.desktop-icon:nth-child(5) { animation-delay: 0.25s; }
.desktop-icon:nth-child(6) { animation-delay: 0.30s; }
.desktop-icon:nth-child(7) { animation-delay: 0.35s; }
.desktop-icon:nth-child(8) { animation-delay: 0.40s; }
.desktop-icon:nth-child(9) { animation-delay: 0.45s; }
.desktop-icon:nth-child(10) { animation-delay: 0.50s; }
.desktop-icon:nth-child(11) { animation-delay: 0.55s; }
.desktop-icon:nth-child(12) { animation-delay: 0.60s; }

@keyframes iconFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.desktop-icon:hover {
  background: rgba(74, 143, 224, 0.1);
}

.desktop-icon:hover .desktop-icon-img {
  transform: translateY(-2px);
  filter: drop-shadow(0 4px 8px rgba(74, 143, 224, 0.4));
}

.desktop-icon-img {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border-default);
  border-radius: 8px;
  transition: transform 0.2s, filter 0.2s;
}

.desktop-icon-img svg {
  width: 26px;
  height: 26px;
  stroke: var(--accent-cyan);
  fill: none;
  stroke-width: 1.5;
}

.desktop-icon-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-align: center;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Admin icon — distinctive gold styling */
.desktop-icon.admin-icon .desktop-icon-img {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
  border-color: rgba(212, 175, 55, 0.6);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.2);
}

.desktop-icon.admin-icon .desktop-icon-img svg {
  stroke: var(--accent-gold, #d4af37);
}

.desktop-icon.admin-icon:hover .desktop-icon-img {
  filter: drop-shadow(0 4px 12px rgba(212, 175, 55, 0.5));
}

.desktop-icon.admin-icon .desktop-icon-label {
  color: var(--accent-gold, #d4af37);
  font-weight: 700;
}

/* Responsive: smaller screens get 2 columns */
@media (max-width: 1100px) {
  .desktop-icons {
    width: 260px;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .desktop-icons {
    width: 130px;
    grid-template-columns: 1fr;
    left: 12px;
  }
}

/* ==========================================================================
   Taskbar (bottom dock)
   ========================================================================== */
.taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: linear-gradient(180deg, rgba(15, 27, 48, 0.92) 0%, rgba(10, 18, 32, 0.98) 100%);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  z-index: 900;
}

.taskbar-start {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 4px;
  height: 32px;
  cursor: pointer;
  border-right: 1px solid var(--border-subtle);
  padding-right: 16px;
  margin-right: 8px;
}

.taskbar-start-logo {
  display: block;
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.taskbar-start-text {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.taskbar-items {
  display: flex;
  gap: 4px;
  flex: 1;
}

.taskbar-item {
  height: 30px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 140px;
  max-width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.taskbar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.taskbar-item.active {
  background: rgba(74, 143, 224, 0.15);
  border-bottom-color: var(--accent-blue);
  color: var(--text-primary);
}

.taskbar-item svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

/* ==========================================================================
   Windows
   ========================================================================== */
.window {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(74, 143, 224, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  min-width: 400px;
  min-height: 300px;
  animation: windowOpen 0.22s var(--ease-snap);
  transform-origin: center;
}

.window.closing {
  animation: windowClose 0.18s var(--ease-smooth) forwards;
}

.window.minimizing {
  animation: windowMinimize 0.25s var(--ease-smooth) forwards;
}

@keyframes windowOpen {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes windowClose {
  to { opacity: 0; transform: scale(0.94); }
}

@keyframes windowMinimize {
  to { opacity: 0; transform: scale(0.3) translateY(400px); }
}

.window.maximized {
  top: 32px !important;
  left: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 32px - 44px) !important;
}

.window-header {
  height: 36px;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 4px 0 14px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.window-header-title {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.window-header-title svg {
  width: 14px;
  height: 14px;
  stroke: var(--accent-cyan);
  fill: none;
  stroke-width: 1.5;
}

.window-header-title .classification {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--classified-red);
  border: 1px solid rgba(196, 47, 61, 0.4);
  padding: 1px 6px;
  margin-left: 8px;
  letter-spacing: 2px;
}

.window-controls {
  display: flex;
  gap: 2px;
}

.window-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-secondary);
}

.window-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.window-btn.close:hover { background: var(--status-critical); color: white; }

.window-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.window-body {
  flex: 1;
  overflow: auto;
  background: var(--bg-deep);
  position: relative;
}

.window-body::-webkit-scrollbar { width: 8px; height: 8px; }
.window-body::-webkit-scrollbar-track { background: var(--bg-deep); }
.window-body::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 0; }
.window-body::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.window.focused {
  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(74, 143, 224, 0.25);
  border-color: var(--accent-blue);
}

/* Resize handle */
.window-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  z-index: 10;
}

.window-resize::before {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--border-strong);
  border-bottom: 2px solid var(--border-strong);
}

/* ==========================================================================
   Common UI: buttons, chips, cards
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
}

.btn.primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.btn.primary:hover { background: #5a9fed; }

.btn.danger {
  color: var(--status-critical);
  border-color: rgba(232, 85, 99, 0.3);
}

.btn.danger:hover {
  background: rgba(232, 85, 99, 0.1);
  border-color: var(--status-critical);
}

.btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border: 1px solid;
  border-radius: 2px;
}

.chip.critical { background: rgba(232, 85, 99, 0.15); border-color: var(--status-critical); color: var(--status-critical); }
.chip.high     { background: rgba(232, 140, 69, 0.15); border-color: var(--status-high); color: var(--status-high); }
.chip.medium   { background: rgba(212, 184, 53, 0.12); border-color: var(--status-medium); color: var(--status-medium); }
.chip.low      { background: rgba(90, 179, 120, 0.12); border-color: var(--status-low); color: var(--status-low); }
.chip.active   { background: rgba(74, 143, 224, 0.15); border-color: var(--status-active); color: var(--status-active); }
.chip.closed   { background: rgba(90, 111, 147, 0.15); border-color: var(--status-closed); color: var(--status-closed); }
.chip.pending  { background: rgba(212, 166, 69, 0.12); border-color: var(--accent-gold); color: var(--accent-gold); }
.chip.approved { background: rgba(90, 179, 120, 0.12); border-color: var(--status-low); color: var(--status-low); }
.chip.denied   { background: rgba(232, 85, 99, 0.15); border-color: var(--status-critical); color: var(--status-critical); }

.chip::before {
  content: '';
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
}

/* Toolbar inside windows */
.toolbar {
  height: 44px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.toolbar-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.toolbar-search {
  flex: 1;
  max-width: 280px;
  padding: 6px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
}

.toolbar-search:focus { border-color: var(--accent-blue); }

.toolbar-spacer { flex: 1; }

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1;
}

.empty-state-text {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Notification toast */
.toast-container {
  position: fixed;
  top: 48px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 280px;
  max-width: 360px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent-blue);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.3s var(--ease-snap);
  font-size: 12px;
}

.toast.success { border-left-color: var(--status-low); }
.toast.error { border-left-color: var(--status-critical); }
.toast.warning { border-left-color: var(--accent-gold); }

.toast.closing { animation: toastOut 0.25s ease forwards; }

.toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.8; }

.toast.success .toast-icon { color: var(--status-low); }
.toast.error .toast-icon { color: var(--status-critical); }
.toast.warning .toast-icon { color: var(--accent-gold); }
.toast.info .toast-icon { color: var(--accent-blue); }

.toast-body { flex: 1; }

.toast-title {
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 1px;
  font-size: 12px;
  margin-bottom: 2px;
}

.toast-message {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.5;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* Context menu */
.context-menu {
  position: fixed;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 4px;
  z-index: 3000;
  animation: menuIn 0.12s ease;
}

@keyframes menuIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
}

.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger:hover { background: rgba(232, 85, 99, 0.15); color: var(--status-critical); }
.context-menu-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* Modal dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  min-width: 440px;
  max-width: 540px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.25s var(--ease-snap);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 2px;
  font-weight: 600;
}

.modal-body { padding: 20px; max-height: 60vh; overflow: auto; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Generic form inside modal / windows */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-blue); }
.field textarea { min-height: 80px; resize: vertical; font-family: var(--font-body); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
