/* =========================================================
   JAM (Jendela Aplikasi Madrasah) - Floating Window Manager
   ========================================================= */

.floating-window {
  position: absolute;
  min-width: var(--window-min-width);
  min-height: var(--window-min-height);
  background: var(--surface-window);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-windows-base);
  transition: box-shadow var(--duration-fast);
}

.floating-window.active {
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--primary-glow);
  border-color: rgba(56, 189, 248, 0.4);
}

.floating-window.minimized {
  display: none !important;
}

.floating-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: calc(100vh - var(--taskbar-height)) !important;
  border-radius: 0 !important;
  border: none !important;
}

/* Window Titlebar */
.window-titlebar {
  height: 38px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: grab;
  user-select: none;
}

.floating-window.maximized .window-titlebar {
  cursor: default;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 70%;
}

.window-app-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
}

.window-app-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Window Controls (Top Right) */
.window-controls-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.win-btn {
  width: 28px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--duration-fast);
}

.win-btn:hover {
  background: var(--surface-hover);
  color: var(--text-main);
}

.win-btn-external:hover {
  color: var(--primary);
}

.win-btn-reload:hover {
  color: var(--accent-green);
  transform: rotate(90deg);
}

.win-btn-close:hover {
  background: #dc2626 !important;
  color: #ffffff !important;
}

.win-btn svg {
  width: 13px;
  height: 13px;
}

/* Snap Preview Ghost Outline (Windows 11 Aero Snap) */
#snap-preview-ghost {
  position: absolute;
  background: rgba(56, 189, 248, 0.15);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: 0 0 30px var(--primary-glow);
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#snap-preview-ghost.active {
  opacity: 1;
}

/* Window Body & Iframe Content */
.window-body {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100% - 38px);
  background: #ffffff;
  overflow: hidden;
}

.window-iframe,
.window-webview {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

/* Mouse blocker during window drag or resize */
.window-drag-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  display: none;
  z-index: 50;
}

.is-dragging .window-drag-overlay,
.is-resizing .window-drag-overlay {
  display: block;
}

/* Fallback Notice for Web Apps that restrict iframes */
.window-security-notice {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  font-size: 11px;
  color: var(--text-muted);
  z-index: 40;
  pointer-events: auto;
}

.window-security-notice a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.notice-btn-popup {
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.notice-btn-popup:hover {
  background: var(--primary-hover);
  transform: scale(1.04);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Resize Handles (8 directions) */
.win-resize-handle {
  position: absolute;
  z-index: 60;
}

.win-resize-n { top: 0; left: 6px; right: 6px; height: 5px; cursor: n-resize; }
.win-resize-s { bottom: 0; left: 6px; right: 6px; height: 5px; cursor: s-resize; }
.win-resize-e { top: 6px; bottom: 6px; right: 0; width: 5px; cursor: e-resize; }
.win-resize-w { top: 6px; bottom: 6px; left: 0; width: 5px; cursor: w-resize; }
.win-resize-ne { top: 0; right: 0; width: 10px; height: 10px; cursor: ne-resize; }
.win-resize-nw { top: 0; left: 0; width: 10px; height: 10px; cursor: nw-resize; }
.win-resize-se { bottom: 0; right: 0; width: 10px; height: 10px; cursor: se-resize; }
.win-resize-sw { bottom: 0; left: 0; width: 10px; height: 10px; cursor: sw-resize; }

.floating-window.maximized .win-resize-handle {
  display: none !important;
}

/* =========================================================
   Chrome Fallback Bar — muncul saat webview gagal load
   ========================================================= */
.webview-chrome-bar {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(145deg, rgba(9, 13, 22, 0.97), rgba(15, 23, 42, 0.99));
  z-index: 50;
  padding: 40px 32px;
  text-align: center;
  animation: fadeInBar 0.3s ease;
}

@keyframes fadeInBar {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.chrome-bar-icon {
  font-size: 48px;
  filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.5));
  animation: pulse-warn 2s ease infinite;
}

@keyframes pulse-warn {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

.chrome-bar-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 380px;
}

.chrome-bar-text b {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #f0f9ff;
  letter-spacing: -0.3px;
}

.chrome-bar-text span {
  font-size: 13px;
  color: rgba(148, 163, 184, 0.85);
  line-height: 1.5;
}

.chrome-bar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.chrome-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: 50px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  letter-spacing: 0.01em;
}

.chrome-bar-btn-primary {
  background: linear-gradient(135deg, #4285f4, #0f9d58);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(66, 133, 244, 0.4);
}

.chrome-bar-btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 28px rgba(66, 133, 244, 0.6);
}

.chrome-bar-btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.chrome-bar-btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(148, 163, 184, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.chrome-bar-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

/* Badge pada app card: indikator mode Chrome */
.app-badge-chrome {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, rgba(66, 133, 244, 0.25), rgba(15, 157, 88, 0.2));
  border: 1px solid rgba(66, 133, 244, 0.35);
  color: #93c5fd;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 50px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 3px;
}
