/* Heyming OS Styles */

/* OS Window Styling */
.os-window {
  position: absolute;
  min-width: 400px;
  min-height: 300px;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 20;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, z-index 0.2s ease;
}

.os-window.dragging {
  transition: none;
}

.os-window.dragging .resize-handle {
  opacity: 0.4;
  background: rgba(59, 130, 246, 0.2);
}

.os-window.active {
  z-index: 50;
  border-color: #3182ce;
}

.os-window.minimized {
  transform: scale(0.1);
  opacity: 0;
  pointer-events: none;
}

.os-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100vh - 48px) !important;
  border-radius: 0;
}

/* Window Title Bar */
.os-window-titlebar {
  height: 32px;
  background: linear-gradient(to bottom, #4a5568, #2d3748);
  border-bottom: 1px solid #1a202c;
  display: flex;
  align-items: center;
  padding: 0 8px;
  cursor: move;
  user-select: none;
}

.os-window-titlebar:hover {
  background: linear-gradient(to bottom, #3182ce, #2b6cb0);
}

.os-window-title {
  flex: 1;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  margin-left: 8px;
}

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

.os-window-control {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.os-window-control.minimize {
  background: #fbbf24;
  color: #92400e;
}

.os-window-control.maximize {
  background: #10b981;
  color: #064e3b;
}

.os-window-control.close {
  background: #ef4444;
  color: #7f1d1d;
}

.os-window-control:hover {
  transform: scale(1.1);
  opacity: 0.8;
}

/* Window Content */
.os-window-content {
  height: calc(100% - 32px);
  overflow: auto;
  background: #1a202c;
  color: #e2e8f0;
  position: relative;
  z-index: 3; /* Above resize handles but below iframe content */
  padding-bottom: 20px; /* Reserve space for drag handle */
}

/* Terminal Specific Styles */
.terminal-content {
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.4;
  background: #000000;
  color: #00ff00;
  height: 100%;
  overflow-y: auto;
}

.terminal-line {
  margin-bottom: 4px;
}

.terminal-prompt {
  color: #00ff00;
}

.terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: #00ff00;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
  caret-color: #00ff00;
}

.terminal-input::placeholder {
  color: #008000;
  opacity: 0.6;
}

/* Taskbar Button */
.taskbar-app {
  height: 32px;
  padding: 0 12px;
  background: #4a5568;
  border: 1px solid #2d3748;
  color: #e2e8f0;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  max-width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.taskbar-app:hover {
  background: #2b6cb0;
}

.taskbar-app.active {
  background: #3182ce;
  border-color: #63b3ed;
}

/* Application Icons */
.app-icon {
  font-size: 16px;
  display: inline-block;
}

/* Desktop Icons */
.desktop-icon {
  position: absolute;
  width: 64px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  z-index: 5;
  padding: 4px;
}

.desktop-icon:hover .icon {
  transform: scale(1.1);
}

.desktop-icon:hover .label {
  background: rgba(0, 123, 255, 0.8);
  color: white;
}

.desktop-icon .icon {
  font-size: 48px;
  margin-bottom: 4px;
  transition: all 0.2s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.desktop-icon .label {
  font-size: 11px;
  font-weight: 500;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  text-align: center;
  line-height: 1.2;
  max-width: 64px;
  word-wrap: break-word;
  padding: 1px 3px;
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* Application Content Styles */
.calculator-content {
  padding: 16px;
  background: #2d3748;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calculator-display {
  background: #000000;
  color: #00ff00;
  padding: 12px;
  text-align: right;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  border: 1px solid #4a5568;
  border-radius: 4px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.calculator-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calculator-button {
  height: 40px;
  background: #4a5568;
  border: 1px solid #2d3748;
  color: #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.calculator-button:hover {
  background: #2b6cb0;
}

.calculator-button:active {
  transform: scale(0.95);
}

.calculator-button.operator {
  background: #3182ce;
}

.calculator-button.equals {
  background: #10b981;
}

/* Animation Classes */
.os-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.os-fade-out {
  animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* Window Resize Handles */
.resize-handle {
  position: absolute;
  background: transparent;
  z-index: 2; /* Lower than iframe content */
  pointer-events: auto;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.resize-handle:hover {
  background: rgba(59, 130, 246, 0.3);
}

.os-window:hover .resize-handle {
  opacity: 0.8;
}

.os-window .resize-handle {
  opacity: 0.2;
}

.resize-handle.n {
  top: -4px;
  left: 12px;
  right: 12px;
  height: 8px;
  cursor: n-resize;
}

.resize-handle.s {
  bottom: -4px;
  left: 12px;
  right: 12px;
  height: 8px;
  cursor: s-resize;
}

.resize-handle.e {
  top: 12px;
  bottom: 12px;
  right: -4px;
  width: 8px;
  cursor: e-resize;
}

.resize-handle.w {
  top: 12px;
  bottom: 12px;
  left: -4px;
  width: 8px;
  cursor: w-resize;
}

.resize-handle.ne {
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  cursor: ne-resize;
}

.resize-handle.nw {
  top: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  cursor: nw-resize;
}

.resize-handle.se {
  bottom: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  position: relative;
}

.resize-handle.sw {
  bottom: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  cursor: sw-resize;
}

/* Visible Drag Handle */
.window-drag-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: linear-gradient(
    135deg,
    transparent 30%,
    #4a5568 30%,
    #4a5568 40%,
    transparent 40%,
    transparent 50%,
    #4a5568 50%,
    #4a5568 60%,
    transparent 60%,
    transparent 70%,
    #4a5568 70%
  );
  cursor: se-resize;
  z-index: 1000;
  opacity: 0.7;
  transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
  border-top-left-radius: 4px;
  pointer-events: auto;
}

.window-drag-handle:hover {
  opacity: 1;
  background: linear-gradient(
    135deg,
    transparent 30%,
    #3182ce 30%,
    #3182ce 40%,
    transparent 40%,
    transparent 50%,
    #3182ce 50%,
    #3182ce 60%,
    transparent 60%,
    transparent 70%,
    #3182ce 70%
  );
  transform: scale(1.1);
}

.window-drag-handle::before {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 4px;
  height: 4px;
  background: #718096;
  border-radius: 50%;
}

.window-drag-handle::after {
  content: '';
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid #718096;
  border-top: none;
  border-left: none;
  transform: rotate(-45deg);
}

/* Iframe Content Styling */
.iframe-content {
  position: relative;
  width: 100%;
  height: calc(100% - 20px); /* Leave space for drag handle */
  z-index: 15; /* Higher than desktop icons */
}

.iframe-content iframe {
  position: relative;
  z-index: 16;
}

/* Scrollbar Styling */
.os-window-content::-webkit-scrollbar,
.terminal-content::-webkit-scrollbar {
  width: 12px;
}

.os-window-content::-webkit-scrollbar-track,
.terminal-content::-webkit-scrollbar-track {
  background: #2d3748;
}

.os-window-content::-webkit-scrollbar-thumb,
.terminal-content::-webkit-scrollbar-thumb {
  background: #4a5568;
  border-radius: 6px;
}

.os-window-content::-webkit-scrollbar-thumb:hover,
.terminal-content::-webkit-scrollbar-thumb:hover {
  background: #2b6cb0;
}

/* Loading Animation */
.loading-spinner {
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid #3182ce;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Context Menu */
.context-menu {
  position: absolute;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  min-width: 160px;
  padding: 4px 0;
}

.context-menu-item {
  padding: 8px 16px;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s ease;
}

.context-menu-item:hover {
  background: #3182ce;
}

.context-menu-separator {
  height: 1px;
  background: #4a5568;
  margin: 4px 0;
}

/* System Notifications */
.notification {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 8px;
  padding: 16px;
  color: #e2e8f0;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 300px;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* App Launcher Improvements */
#app-launcher-menu {
  backdrop-filter: blur(10px);
  z-index: 1000; /* Very high z-index to appear above all windows */
  position: absolute;
  transform-origin: bottom left;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Fancy App Launcher Animations */
@keyframes slideUpFadeIn {
  0% {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }
  50% {
    transform: translateY(-5px) scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes slideDownFadeOut {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }
}

@keyframes appItemSlideIn {
  0% {
    transform: translateX(-20px);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

#app-launcher-menu.show {
  animation: slideUpFadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#app-launcher-menu.hide {
  animation: slideDownFadeOut 0.3s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

#app-launcher-menu .app-item.animated {
  animation: appItemSlideIn 0.3s ease-out forwards;
  animation-delay: calc(var(--item-index) * 0.05s);
  opacity: 0;
  transform: translateX(-20px);
}

/* Enhanced visual effects */
#app-launcher-menu {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  background: linear-gradient(145deg, rgba(55, 65, 81, 0.95), rgba(31, 41, 55, 0.95));
}

/* Iframe App Content */
.iframe-content {
  background: #ffffff;
  overflow: hidden;
  position: relative;
  z-index: 15; /* Higher than desktop icons and resize handles */
  pointer-events: auto;
}

.iframe-content iframe {
  background: #ffffff;
  pointer-events: auto;
  position: relative;
  z-index: 16;
}

/* Loading indicator for iframes */
.iframe-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #1a202c;
  color: #e2e8f0;
  font-family: monospace;
}

.iframe-loading::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #3182ce;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

/* App category headers in launcher */
.category-header {
  color: #9ca3af;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px 4px 12px;
  margin-top: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid #374151;
}

/* Enhanced launcher menu */
#app-launcher-menu {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a5568 #2d3748;
}

#app-launcher-menu::-webkit-scrollbar {
  width: 8px;
}

#app-launcher-menu::-webkit-scrollbar-track {
  background: #2d3748;
}

#app-launcher-menu::-webkit-scrollbar-thumb {
  background: #4a5568;
  border-radius: 4px;
}

#app-launcher-menu::-webkit-scrollbar-thumb:hover {
  background: #2b6cb0;
}

/* Desktop Background with Famous Ghostscript Tiger SVG */
#os-desktop {
  background-image: url('assets/ghostscript_tiger.svg');
  background-size: 25%;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Subtle overlay to enhance tiger visibility */
#os-desktop::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, transparent 20%, rgba(0, 0, 0, 0.1) 70%);
  pointer-events: none;
  opacity: 0.6;
}

/* Shutdown Button Styling */
.shutdown-btn {
  position: relative;
  overflow: hidden;
}

.shutdown-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 0, 0, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
}

.shutdown-btn:hover::before {
  width: 100%;
  height: 100%;
}

/* Shutdown Dialog Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* Shutdown Dialog Styling */
#shutdown-dialog {
  backdrop-filter: blur(4px);
}

#shutdown-dialog .bg-gray-800 {
  animation: slideUp 0.3s ease-out;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

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