/* ============================================
   macOS System CSS - Core Styles
   Premium Quality System Stylesheet
   ============================================ */

:root {
  --system-font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  --menubar-height: 25px;
  --dock-height: 70px;
  --dock-icon-size: 52px;
  --dock-magnify-size: 76px;
  
  /* Colors - Light Mode */
  --bg-primary: rgba(255, 255, 255, 0.80);
  --bg-secondary: rgba(246, 246, 246, 0.80);
  --bg-tertiary: rgba(239, 239, 239, 0.80);
  --bg-window: rgba(236, 236, 236, 0.95);
  --bg-sidebar: rgba(245, 245, 245, 0.95);
  --bg-toolbar: rgba(228, 228, 228, 0.90);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --border-color: rgba(0, 0, 0, 0.12);
  --separator-color: rgba(0, 0, 0, 0.08);
  --accent-color: #007aff;
  --accent-hover: #0066d6;
  --selection-color: rgba(0, 122, 255, 0.15);
  --shadow-window: 0 22px 70px 4px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  --shadow-dock: 0 0 0 0.5px rgba(255,255,255,0.3), 0 15px 60px rgba(0,0,0,0.3);
  --shadow-menu: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 0.5px rgba(0, 0, 0, 0.1);
  --blur-amount: 40px;
  --vibrancy-bg: rgba(255, 255, 255, 0.72);
  --vibrancy-dark: rgba(30, 30, 30, 0.72);
  
  /* Traffic light colors */
  --traffic-close: #ff5f57;
  --traffic-minimize: #febc2e;
  --traffic-maximize: #28c840;
  --traffic-close-hover: #e0443e;
  --traffic-minimize-hover: #dea123;
  --traffic-maximize-hover: #1aab29;
  --traffic-inactive: #ddd;
}

/* Dark Mode */
body.dark-mode {
  --bg-primary: rgba(40, 40, 40, 0.85);
  --bg-secondary: rgba(50, 50, 50, 0.85);
  --bg-tertiary: rgba(60, 60, 60, 0.85);
  --bg-window: rgba(38, 38, 38, 0.97);
  --bg-sidebar: rgba(30, 30, 30, 0.97);
  --bg-toolbar: rgba(48, 48, 48, 0.95);
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --border-color: rgba(255, 255, 255, 0.1);
  --separator-color: rgba(255, 255, 255, 0.06);
  --accent-color: #0a84ff;
  --selection-color: rgba(10, 132, 255, 0.2);
  --shadow-window: 0 22px 70px 4px rgba(0, 0, 0, 0.56), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --vibrancy-bg: rgba(30, 30, 30, 0.72);
  --traffic-inactive: #555;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--system-font);
  font-size: 13px;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  user-select: none;
  cursor: default;
}

.hidden {
  display: none !important;
}

/* ============ BOOT SCREEN ============ */
#boot-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

#boot-screen.fade-out {
  opacity: 0;
}

.apple-logo {
  margin-bottom: 40px;
  animation: logoPulse 2.5s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { opacity: 0.7; filter: brightness(0.9); }
  50% { opacity: 1; filter: brightness(1.1); }
}

.boot-progress {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.boot-progress-bar {
  width: 0%;
  height: 100%;
  background: white;
  border-radius: 2px;
  animation: bootLoad 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes bootLoad {
  0% { width: 0%; }
  20% { width: 15%; }
  40% { width: 35%; }
  60% { width: 60%; }
  80% { width: 85%; }
  100% { width: 100%; }
}

/* ============ DESKTOP ============ */
#desktop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #533483 75%, #e94560 100%);
  background-size: cover;
  overflow: hidden;
}

/* Cross-fade overlay for smooth wallpaper transitions */
#wallpaper-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

#desktop.wallpaper-1 {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #533483 75%, #e94560 100%);
}

#desktop.wallpaper-2 {
  background: linear-gradient(135deg, #0c0c1d 0%, #1b1b3a 25%, #2d1b69 50%, #6b3fa0 75%, #ff6b6b 100%);
}

#desktop.wallpaper-3 {
  background: linear-gradient(135deg, #141e30 0%, #243b55 25%, #2c5f7c 50%, #00b4db 75%, #0083b0 100%);
}

#desktop.wallpaper-4 {
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}

#desktop.wallpaper-5 {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 30%, #4ca2cd 60%, #67b26f 100%);
}

#desktop.wallpaper-6 {
  background: linear-gradient(180deg, #ff7e5f 0%, #feb47b 30%, #ffcb80 50%, #86a8e7 75%, #7f7fd5 100%);
}

/* ============ DESKTOP ICONS ============ */
#desktop-icons {
  position: absolute;
  top: calc(var(--menubar-height) + 10px);
  right: 0;
  bottom: calc(var(--dock-height) + 20px);
  width: 100%;
  pointer-events: none;
  z-index: 1;
}

.desktop-icon {
  position: absolute;
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: default;
  pointer-events: all;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.desktop-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.desktop-icon.selected {
  background: rgba(0, 122, 255, 0.35);
}

.desktop-icon-img {
  width: 56px;
  height: 56px;
}

.desktop-icon-img svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.desktop-icon span {
  color: white;
  font-size: 11px;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  line-height: 1.3;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ============ BRANDING WATERMARK ============ */
#desktop-watermark {
  position: fixed;
  bottom: calc(var(--dock-height) + 22px);
  left: 16px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.2px;
  z-index: 5;
  pointer-events: auto;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  transition: color 0.3s ease;
}

#desktop-watermark:hover {
  color: rgba(255, 255, 255, 0.65);
}

#desktop-watermark a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  transition: border-color 0.3s ease;
}

#desktop-watermark a:hover {
  border-bottom-color: rgba(255, 255, 255, 0.5);
}

/* ============ KEYBOARD LAYOUT TOGGLE PILL ============ */
#keyboard-layout-pill {
  position: fixed;
  bottom: calc(var(--dock-height) + 20px);
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 8px;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  cursor: pointer;
  z-index: 5;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

#keyboard-layout-pill:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

#keyboard-layout-pill:active {
  transform: translateY(0);
}

.kb-pill-icon {
  display: flex;
  align-items: center;
}

.kb-pill-label {
  font-size: 11px;
  min-width: 22px;
  text-align: center;
}

.kb-pill-switch-track {
  width: 28px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  position: relative;
  transition: background 0.3s ease;
}

.kb-pill-switch-track.active {
  background: #34c759;
}

.kb-pill-switch-thumb {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.kb-pill-switch-track.active .kb-pill-switch-thumb {
  transform: translateX(12px);
}

/* ============ WINDOWS CONTAINER ============ */
#windows-container {
  position: absolute;
  top: var(--menubar-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 10;
}

/* ============ SPOTLIGHT ============ */
#spotlight-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.18);
  z-index: 10000;
  display: flex;
  justify-content: center;
  padding-top: 18vh;
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  animation: spotlightOverlayIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes spotlightOverlayIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to { opacity: 1; }
}

#spotlight {
  width: 680px;
  max-height: 460px;
  background: var(--vibrancy-bg);
  backdrop-filter: blur(60px) saturate(200%);
  -webkit-backdrop-filter: blur(60px) saturate(200%);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35), 0 0 0 0.5px rgba(255,255,255,0.12), inset 0 0 0 0.5px rgba(255,255,255,0.06);
  overflow: hidden;
  animation: spotlightIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.spotlight-search {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 10px;
  border-bottom: 1px solid var(--separator-color);
}

.spotlight-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 22px;
  font-weight: 300;
  color: var(--text-primary);
  font-family: var(--system-font);
  letter-spacing: -0.3px;
}

.spotlight-search input::placeholder {
  color: var(--text-tertiary);
}

.spotlight-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px 0;
}

.spotlight-result {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  gap: 10px;
  cursor: default;
  transition: background 0.12s ease, transform 0.12s ease;
  border-radius: 6px;
  margin: 1px 6px;
}

.spotlight-result:hover,
.spotlight-result.selected {
  background: var(--accent-color);
  color: white;
}

.spotlight-result:active {
  transform: scale(0.99);
}

.spotlight-result-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.spotlight-result-text {
  display: flex;
  flex-direction: column;
}

.spotlight-result-title {
  font-size: 13px;
  font-weight: 500;
}

.spotlight-result-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

.spotlight-result:hover .spotlight-result-subtitle,
.spotlight-result.selected .spotlight-result-subtitle {
  color: rgba(255, 255, 255, 0.7);
}

/* ============ LAUNCHPAD ============ */
#launchpad {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: launchpadIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#launchpad.closing {
  animation: launchpadOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes launchpadIn {
  from { opacity: 0; transform: scale(1.15); filter: blur(6px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes launchpadOut {
  from { opacity: 1; transform: scale(1); filter: blur(0); }
  to { opacity: 0; transform: scale(1.15); filter: blur(6px); }
}

.launchpad-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

.launchpad-search {
  position: relative;
  z-index: 2;
  margin-top: 50px;
  margin-bottom: 30px;
}

.launchpad-search input {
  width: 240px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0 12px 0 32px;
  font-size: 13px;
  color: white;
  outline: none;
  font-family: var(--system-font);
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.launchpad-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.launchpad-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(7, 100px);
  gap: 30px 20px;
  max-width: 900px;
  justify-content: center;
}

.launchpad-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: default;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.launchpad-app:hover {
  transform: scale(1.1);
}

.launchpad-app:active {
  transform: scale(0.92);
  transition: transform 0.1s ease;
}

.launchpad-app-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.launchpad-app-icon svg {
  width: 100%;
  height: 100%;
}

.launchpad-app-name {
  color: white;
  font-size: 11px;
  text-align: center;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.launchpad-dots {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 8px;
  margin-top: 30px;
}

.launchpad-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: background 0.2s;
}

.launchpad-dot.active {
  background: white;
}

/* ============ ABOUT THIS MAC ============ */
#about-mac-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-mac-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
}

.about-mac-window {
  position: relative;
  width: 320px;
  background: var(--bg-window);
  backdrop-filter: blur(60px) saturate(200%);
  -webkit-backdrop-filter: blur(60px) saturate(200%);
  border-radius: 14px;
  box-shadow: var(--shadow-window);
  padding: 24px;
  animation: dialogIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialogIn {
  from { transform: scale(0.88); opacity: 0; filter: blur(4px); }
  to { transform: scale(1); opacity: 1; filter: blur(0); }
}

.about-mac-close {
  position: absolute;
  top: 8px;
  left: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--traffic-close);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  line-height: 1;
  transition: color 0.15s;
}

.about-mac-close:hover {
  color: rgba(0,0,0,0.5);
}

.about-mac-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.about-mac-content h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.about-version {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.about-specs {
  width: 100%;
  text-align: left;
}

.about-spec-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--separator-color);
}

.about-spec-row:last-child {
  border-bottom: none;
}

.about-spec-row span:first-child {
  color: var(--text-secondary);
}

.about-spec-row span:last-child {
  font-weight: 500;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
  background-clip: content-box;
}

body.dark-mode ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  background-clip: content-box;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
  background-clip: content-box;
}

/* Utility */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.fade-in { animation: fadeIn 0.2s ease; }
.fade-out { animation: fadeOut 0.2s ease forwards; }
