/**
 * Manic Pixels Web OS — Taskbar CSS
 * Glassmorphism | 4 bordas | Usa var(--mp-taskbar-*)
 */

/* ── Elemento principal ─────────────────────────────────────────────────── */

#mp-taskbar {
  position: fixed;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 2px;

  background: var(--mp-taskbar-bg);
  border-top: 1px solid var(--mp-taskbar-border);
  color: var(--mp-taskbar-fg);
  font-family: var(--mp-font-ui);
  font-size: var(--mp-font-size-sm);

  user-select: none;
  -webkit-user-select: none;

  transition: background 0.2s ease;
}

/* Glass — pipeline W7: blur + tint de acento + highlights de borda */
#mp-taskbar.glass-on {
  backdrop-filter:         blur(var(--mp-taskbar-blur)) saturate(var(--mp-aero-saturation, 160%));
  -webkit-backdrop-filter: blur(var(--mp-taskbar-blur)) saturate(var(--mp-aero-saturation, 160%));
  background: rgba(var(--mp-accent-rgb), calc(var(--mp-glass-tint-opacity, 0.35) * 0.80)) !important;
  border-color: rgba(var(--mp-accent-rgb), 0.65) !important;
}

#mp-taskbar[data-position="bottom"].glass-on {
  border-top: 1px solid rgba(var(--mp-accent-rgb), 0.70) !important;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.40),
              0 0 0 1px rgba(var(--mp-accent-rgb), 0.30),
              inset 0  1px 0 rgba(255, 255, 255, 0.50),
              inset 0 -1px 0 rgba(255, 255, 255, 0.06),
              inset  1px 0 0 rgba(255, 255, 255, 0.10),
              inset -1px 0 0 rgba(255, 255, 255, 0.10);
}

#mp-taskbar[data-position="top"].glass-on {
  border-bottom: 1px solid rgba(var(--mp-accent-rgb), 0.70) !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.40),
              0 0 0 1px rgba(var(--mp-accent-rgb), 0.30),
              inset 0 -1px 0 rgba(255, 255, 255, 0.50),
              inset 0  1px 0 rgba(255, 255, 255, 0.06),
              inset  1px 0 0 rgba(255, 255, 255, 0.10),
              inset -1px 0 0 rgba(255, 255, 255, 0.10);
}

#mp-taskbar[data-position="left"].glass-on,
#mp-taskbar[data-position="right"].glass-on {
  box-shadow: 0 0 0 1px rgba(var(--mp-accent-rgb), 0.35),
              inset 0  1px 0 rgba(255, 255, 255, 0.50),
              inset 0 -1px 0 rgba(255, 255, 255, 0.06),
              inset  1px 0 0 rgba(255, 255, 255, 0.12),
              inset -1px 0 0 rgba(255, 255, 255, 0.12);
}

/* ── Posicionamento ──────────────────────────────────────────────────────── */

#mp-taskbar[data-position="bottom"] {
  bottom: 0; left: 0; right: 0;
  height: var(--mp-taskbar-height);
  flex-direction: row;
  border-top: 1px solid var(--mp-taskbar-border);
  border-bottom: none;
}

#mp-taskbar[data-position="top"] {
  top: 0; left: 0; right: 0;
  height: var(--mp-taskbar-height);
  flex-direction: row;
  border-bottom: 1px solid var(--mp-taskbar-border);
  border-top: none;
}

#mp-taskbar[data-position="left"] {
  top: 0; left: 0; bottom: 0;
  width: var(--mp-taskbar-height);
  flex-direction: column;
  border-right: 1px solid var(--mp-taskbar-border);
  border-top: none;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 0;
}

#mp-taskbar[data-position="right"] {
  top: 0; right: 0; bottom: 0;
  width: var(--mp-taskbar-height);
  flex-direction: column;
  border-left: 1px solid var(--mp-taskbar-border);
  border-top: none;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 0;
}

/* ── Botão Start ─────────────────────────────────────────────────────────── */

#mp-start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px;
  min-width: 44px;
  background: transparent;
  border: none;
  color: var(--mp-taskbar-fg);
  font-family: var(--mp-font-ui);
  font-size: var(--mp-font-size-base);
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

#mp-start-btn:hover {
  background: var(--mp-taskbar-highlight);
}

#mp-start-btn.active {
  background: rgba(var(--mp-accent-rgb), 0.20);
}

#mp-start-btn .mp-start-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mp-start-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--mp-accent);
}

#mp-start-btn .mp-start-label {
  display: none;
}

[data-position="bottom"] #mp-start-btn .mp-start-label,
[data-position="top"]    #mp-start-btn .mp-start-label {
  display: inline;
}

/* Vertical — ajuste do botão start */
[data-position="left"] #mp-start-btn,
[data-position="right"] #mp-start-btn {
  width: 100%;
  height: 44px;
  padding: 0;
  flex-direction: column;
  border-radius: 4px;
}

/* ── Separador vertical ──────────────────────────────────────────────────── */

.mp-taskbar-sep {
  width: 1px;
  height: 24px;
  background: var(--mp-taskbar-border);
  margin: 0 4px;
  flex-shrink: 0;
}

[data-position="left"]  .mp-taskbar-sep,
[data-position="right"] .mp-taskbar-sep {
  width: 24px;
  height: 1px;
  margin: 4px 0;
}

/* ── Área de apps fixos (pinned) ──────────────────────────────────────────── */

#mp-taskbar-pinned {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px;
  flex-shrink: 0;
}

[data-position="left"] #mp-taskbar-pinned,
[data-position="right"] #mp-taskbar-pinned {
  flex-direction: column;
  padding: 2px 0;
}

/* ── Área de janelas abertas ─────────────────────────────────────────────── */

#mp-taskbar-windows {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow: hidden;
  padding: 0 2px;
  min-width: 0;
}

[data-position="left"] #mp-taskbar-windows,
[data-position="right"] #mp-taskbar-windows {
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
  align-items: stretch;
}

/* ── Botão de janela / app pinado ─────────────────────────────────────────── */

.mp-taskbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  max-width: 160px;
  min-width: 32px;
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--mp-taskbar-fg);
  font-family: var(--mp-font-ui);
  font-size: var(--mp-font-size-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}

.mp-taskbar-btn:hover {
  background: var(--mp-taskbar-highlight);
}

.mp-taskbar-btn.focused {
  background: rgba(var(--mp-accent-rgb), 0.18);
  border-color: rgba(var(--mp-accent-rgb), 0.35);
}

.mp-taskbar-btn.minimized {
  opacity: 0.6;
}

.mp-taskbar-btn.pinned-only {
  background: transparent;
  max-width: 44px;
  justify-content: center;
  padding: 0;
}

.mp-taskbar-btn.pinned-only:hover {
  background: var(--mp-taskbar-highlight);
}

.mp-taskbar-btn .mp-tb-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.mp-taskbar-btn .mp-tb-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mp-taskbar-btn .mp-tb-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Indicador de hibernado */
.mp-taskbar-btn.hibernated::after {
  content: '';
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(var(--mp-accent-rgb), 0.5);
  flex-shrink: 0;
}

/* Indicador de janela aberta abaixo do ícone */
.mp-taskbar-btn::before {
  content: '';
  display: block;
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--mp-accent);
  opacity: 0;
  transition: opacity 0.15s;
}

.mp-taskbar-btn:not(.pinned-only)::before {
  opacity: 1;
}

/* Versão vertical */
[data-position="left"] .mp-taskbar-btn,
[data-position="right"] .mp-taskbar-btn {
  width: 36px;
  height: 36px;
  max-width: 36px;
  padding: 0;
  justify-content: center;
}

[data-position="left"] .mp-taskbar-btn .mp-tb-label,
[data-position="right"] .mp-taskbar-btn .mp-tb-label {
  display: none;
}

/* ── Preview hover da janela ─────────────────────────────────────────────── */

.mp-tb-preview {
  position: fixed;
  z-index: 9500;
  background: var(--mp-menu-bg);
  border: 1px solid var(--mp-menu-border);
  border-radius: var(--mp-menu-radius);
  box-shadow: var(--mp-menu-shadow);
  backdrop-filter: blur(var(--mp-menu-blur));
  -webkit-backdrop-filter: blur(var(--mp-menu-blur));
  padding: 8px;
  pointer-events: none;
  animation: mp-preview-in 0.12s ease;
}

.mp-tb-preview-title {
  font-family: var(--mp-font-ui);
  font-size: var(--mp-font-size-sm);
  color: var(--mp-menu-fg);
  margin-bottom: 6px;
  text-align: center;
  opacity: 0.8;
}

.mp-tb-preview-thumb {
  width: 180px;
  height: 110px;
  background: var(--mp-window-bg-solid);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.2);
  font-size: 11px;
}

@keyframes mp-preview-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── System Tray ─────────────────────────────────────────────────────────── */

#mp-taskbar-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  flex-shrink: 0;
  margin-left: auto;
}

[data-position="left"] #mp-taskbar-tray,
[data-position="right"] #mp-taskbar-tray {
  margin-left: 0;
  margin-top: auto;
  flex-direction: column;
  padding: 8px 0;
}

/* ── Relógio ─────────────────────────────────────────────────────────────── */

#mp-clock {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  cursor: default;
  border-radius: 4px;
  transition: background 0.12s;
  white-space: nowrap;
}

#mp-clock:hover {
  background: var(--mp-taskbar-highlight);
}

#mp-clock .mp-clock-time {
  font-size: var(--mp-font-size-sm);
  font-weight: 500;
  color: var(--mp-taskbar-fg);
}

/* Data incorporada no mp-clock-time — span vazio oculto */
#mp-clock .mp-clock-date {
  display: none;
}

[data-position="left"] #mp-clock,
[data-position="right"] #mp-clock {
  align-items: center;
  padding: 4px 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* ── Botão show-desktop ──────────────────────────────────────────────────── */

#mp-show-desktop {
  width: 8px;
  height: 100%;
  background: transparent;
  border: none;
  border-left: 1px solid var(--mp-taskbar-border);
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
}

#mp-show-desktop:hover {
  background: var(--mp-taskbar-highlight);
}

[data-position="left"] #mp-show-desktop,
[data-position="right"] #mp-show-desktop {
  width: 100%;
  height: 8px;
  border-left: none;
  border-top: 1px solid var(--mp-taskbar-border);
}

/* ── Tray icons ──────────────────────────────────────────────────────────── */

.mp-tray-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  transition: background 0.12s, color 0.12s;
}

.mp-tray-icon:hover {
  background: var(--mp-taskbar-highlight);
  color: var(--mp-taskbar-fg);
}

.mp-tray-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ── Barra de progresso no botão ─────────────────────────────────────────── */

.mp-taskbar-btn.has-progress {
  position: relative;
  overflow: hidden;
}

.mp-tb-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--mp-accent);
  border-radius: 0 0 6px 6px;
  transition: width 0.3s ease;
}
