/* CSS Variables for theming */
:root {
  --primary-bg: rgba(30, 30, 30, 0.95);
  --secondary-bg: rgba(40, 40, 40, 0.9);
  --accent-color: #4CAF50;
  --text-color: #ffffff;
  --border-color: rgba(255, 255, 255, 0.2);
  --hover-bg: rgba(255, 255, 255, 0.1);
  --terminal-bg: #1a1a1a;
  --terminal-text: #00ff00;
  --window-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --taskbar-height: 50px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Ubuntu', 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
  position: relative;
  user-select: none; /* Prevent text selection */
}

/* Boot Screen */
.boot-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #00ff00;
  font-family: 'Courier New', monospace;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeOut 3s ease-in-out 2s forwards; /* Fade out after 2s delay */
}

.boot-text {
  font-size: 1.2rem;
  margin: 0.5rem 0;
  opacity: 0;
  animation: typewriter 0.5s ease-in-out forwards;
}

.boot-text:nth-child(1) { animation-delay: 0.2s; }
.boot-text:nth-child(2) { animation-delay: 0.7s; }
.boot-text:nth-child(3) { animation-delay: 1.2s; }
.boot-text:nth-child(4) { animation-delay: 1.7s; }

@keyframes typewriter {
  to { opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; visibility: hidden; }
}

/* Desktop */
.desktop {
  height: 100vh;
  background-image: url('https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1920&h=1080&fit=crop');
  background-size: cover;
  background-position: center;
  position: relative;
  padding: 20px;
  padding-bottom: calc(var(--taskbar-height) + 20px); /* Space for taskbar */
  transition: background-image 0.5s ease;
}

/* Desktop Icons */
.desktop-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, 80px);
  gap: 20px;
  position: absolute;
  top: 20px;
  left: 20px;
  max-height: calc(100vh - var(--taskbar-height) - 40px);
  overflow-y: auto;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(5px);
  user-select: none;
  position: relative;
  touch-action: none; /* Prevent default touch actions */
}

.desktop-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.desktop-icon.dragging {
  opacity: 0.7;
  transform: scale(1.1);
  z-index: 1000;
  position: fixed; /* Fixed position during drag */
  pointer-events: none; /* Allow events to pass through */
}

.desktop-icon.drag-mode {
  animation: wiggle 0.5s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

.desktop-icon i {
  font-size: 32px;
  margin-bottom: 5px;
  color: var(--text-color);
}

.desktop-icon span {
  font-size: 12px;
  text-align: center;
  color: var(--text-color);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Windows */
.window {
  position: absolute;
  background: var(--primary-bg);
  border-radius: 8px;
  box-shadow: var(--window-shadow);
  border: 1px solid var(--border-color);
  min-width: 400px;
  min-height: 300px;
  display: none; /* Hidden by default */
  overflow: hidden;
  resize: both; /* Allow resizing */
  z-index: 100; /* Base z-index */
  transition: all 0.2s ease-in-out; /* Smooth transitions for maximize/minimize */
}

.window.active {
  display: block; /* Show when active */
  z-index: 1000; /* Bring to front */
}

.window-header {
  background: var(--secondary-bg);
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move; /* Indicate draggable */
  user-select: none;
  border-bottom: 1px solid var(--border-color);
}

.window-title {
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.window-button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s ease;
  border: none; /* Remove default button border */
}

.window-button:hover {
  transform: scale(1.2);
}

.window-close { background: #ff5f56; } /* Red */
.window-minimize { background: #ffbd2e; } /* Yellow */
.window-maximize { background: #27c93f; } /* Green */

.window-content {
  padding: 20px;
  height: calc(100% - 50px); /* Header height is 50px */
  overflow-y: auto;
  color: var(--text-color);
}

/* Terminal */
.terminal {
  background: var(--terminal-bg);
  color: var(--terminal-text);
  font-family: 'Courier New', monospace;
  padding: 15px;
  height: 100%;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.4;
}

.terminal-line {
  margin: 5px 0;
  display: flex;
  align-items: center;
}

.terminal-prompt {
  color: var(--terminal-text);
  margin-right: 10px;
  white-space: nowrap;
}

.terminal-input {
  background: transparent;
  border: none;
  color: var(--terminal-text);
  outline: none;
  flex: 1;
  font-family: inherit;
  font-size: inherit;
  caret-color: var(--terminal-text); /* Blinking cursor */
}

.terminal-output {
  color: #ffffff; /* Output text color */
  margin: 5px 0;
  white-space: pre-wrap; /* Preserve whitespace and wrap text */
}

/* File Manager */
.file-manager {
  display: flex;
  height: 100%;
}

.file-sidebar {
  width: 200px;
  background: var(--secondary-bg);
  border-right: 1px solid var(--border-color);
  padding: 10px;
}

.file-main {
  flex: 1;
  padding: 20px;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 5px;
  transition: background 0.2s ease;
}

.file-item:hover {
  background: var(--hover-bg);
}

.file-item i {
  margin-right: 10px;
  width: 16px;
}

/* Taskbar */
.taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--taskbar-height);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  padding: 0 10px;
  z-index: 1000;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.start-button {
  background: linear-gradient(45deg, #ff6b6b, #ee5a24);
  border: none;
  color: white;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.start-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

/* Start Menu */
.start-menu {
  position: absolute;
  bottom: calc(var(--taskbar-height) + 10px); /* Position above taskbar */
  left: 10px;
  width: 350px;
  max-height: 500px;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: none;
  overflow-y: auto;
  z-index: 1001;
  transform-origin: bottom left;
}

.start-menu.active {
  display: block;
  animation: slideUp 0.3s ease forwards;
}

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

.start-menu-header {
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.start-menu-section {
  padding: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.start-menu-section:last-child {
  border-bottom: none;
}

.start-menu-section h3 {
  color: #fff;
  font-size: 0.9rem;
  margin-bottom: 10px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.start-menu-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
  text-decoration: none;
  gap: 10px;
}

.start-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.start-menu-item i {
  width: 20px;
  text-align: center;
}

.start-menu-item small {
  font-size: 11px;
  opacity: 0.7;
}

.start-menu-footer {
  background: var(--secondary-bg);
  padding: 10px 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-around;
  gap: 10px;
}

.start-menu-footer button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.start-menu-footer button:hover {
  background: var(--accent-color);
  transform: translateY(-2px);
}

.taskbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 20px;
}

.taskbar-item {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  justify-content: center;
}

.taskbar-item:hover {
  background: rgba(255, 255, 255, 0.2);
}

.taskbar-item.active {
  background: rgba(255, 255, 255, 0.3);
  border-bottom: 3px solid var(--accent-color);
  padding-bottom: 5px;
}

.taskbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
  color: white;
  font-size: 0.9rem;
}

.system-tray {
  display: flex;
  gap: 10px;
}

.system-tray i {
  cursor: pointer;
  padding: 5px;
  border-radius: 3px;
  transition: background 0.3s ease;
}

.system-tray i:hover {
  background: rgba(255, 255, 255, 0.1);
}

.clock {
  font-size: 14px;
  font-weight: 500;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--primary-bg);
  border-radius: 6px;
  box-shadow: var(--window-shadow);
  border: 1px solid var(--border-color);
  padding: 5px 0;
  display: none;
  z-index: 1002;
  min-width: 180px;
}

.context-menu-item {
  padding: 8px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s ease;
}

.context-menu-item:hover {
  background: var(--hover-bg);
}

.context-menu-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 5px 0;
}

/* Wallpaper Selector */
.wallpaper-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.wallpaper-option {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
  border: 2px solid transparent;
}

.wallpaper-option:hover {
  transform: scale(1.05);
}

.wallpaper-option.active {
  border-color: var(--accent-color);
}

.wallpaper-option img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.wallpaper-option .wallpaper-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px;
  font-size: 12px;
  text-align: center;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--secondary-bg);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border-color);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.project-title {
  color: var(--accent-color);
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.project-description {
  margin-bottom: 15px;
  line-height: 1.6;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 15px;
}

.project-tag {
  background: var(--accent-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.project-links {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.project-link {
  background: var(--accent-color);
  color: white;
  padding: 8px 15px;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.3s ease;
}

.project-link.github {
  background: #333; /* Darker for GitHub */
}

.project-link:hover {
  background: #45a049; /* Darker green on hover */
}
.project-link.github:hover {
  background: #555;
}

/* Skills */
.skills-category {
  margin-bottom: 25px;
}

.skills-category h3 {
  color: var(--accent-color);
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  background: var(--secondary-bg);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
}

/* Contact */
.contact-info {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contact-item i {
  width: 20px;
  color: var(--accent-color);
}

.contact-link {
  color: var(--accent-color);
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

/* Notification Toast */
.notification-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--accent-color);
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10000;
  font-size: 14px;
  opacity: 0;
  transform: translateY(-20px);
  animation: fadeInOut 3.5s forwards;
  display: flex;
  align-items: center;
  gap: 10px;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(-20px); }
  10% { opacity: 1; transform: translateY(0); }
  90% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .desktop-icons {
      grid-template-columns: repeat(auto-fill, 70px);
      gap: 15px;
  }

  .desktop-icon {
      padding: 8px;
  }

  .desktop-icon i {
      font-size: 28px;
  }

  .desktop-icon span {
      font-size: 11px;
  }

  .window {
      min-width: 90vw;
      min-height: 70vh;
      top: 5vh !important;
      left: 5vw !important;
      width: 90vw !important;
      height: 70vh !important;
      transform: none !important; /* Disable transform for mobile maximize */
      resize: none; /* Disable resizing on small screens */
  }

  .taskbar {
      padding: 0 10px;
  }

  .taskbar-center {
      margin: 0 5px;
      gap: 5px;
  }

  .taskbar-item {
      min-width: unset;
      padding: 8px;
      font-size: 0.8rem;
  }

  .taskbar-item span {
      display: none; /* Hide text on small screens */
  }

  .start-menu {
      width: calc(100vw - 20px);
      left: 10px;
      max-height: 80vh;
  }

  .file-sidebar {
      width: 150px;
  }

  .terminal {
      font-size: 12px;
      padding: 10px;
  }
}

@media (max-width: 480px) {
  .desktop-icons {
      grid-template-columns: repeat(auto-fill, 60px);
      gap: 10px;
  }

  .desktop-icon i {
      font-size: 24px;
  }

  .desktop-icon span {
      font-size: 10px;
  }

  .taskbar {
      padding: 0 5px;
  }

  .start-button {
      padding: 6px 10px;
      font-size: 0.8rem;
  }

  .taskbar-right {
      font-size: 0.8rem;
      gap: 10px;
  }

  .clock {
      font-size: 12px;
  }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px; /* For horizontal scrollbars */
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}