/* =====================================================================
   shell.css - JessOS Shell Components
   Desktop layout, windows, modals, toasts, transfers, loading states
   Dark Theme - Based on GNOME Professional Solid Dark
   NOTE: Tokens are in tokens.css
   ===================================================================== */

/* ===================== GLOBAL CURSOR ===================== */
*, *::before, *::after,
*:hover, *:active, *:focus,
*:link, *:visited {
  cursor: url('/shared/img/jessos-cursor.png'), auto !important;
}

/* Safari fix: explicitly set cursor on interactive elements */
button, button:hover, button:active, button:focus,
a, a:hover, a:active, a:focus,
[role="button"], [role="button"]:hover, [role="button"]:active,
.clickable, .clickable:hover, .clickable:active,
.dock-icon, .dock-icon:hover, .dock-icon:active,
.menu-item, .menu-item:hover, .menu-item:active,
.menu-dropdown-item, .menu-dropdown-item:hover, .menu-dropdown-item:active,
.context-menu-item, .context-menu-item:hover, .context-menu-item:active,
.file-row, .file-row:hover, .file-row:active,
.row-download-btn, .row-download-btn:hover, .row-download-btn:active,
.nav-button, .nav-button:hover, .nav-button:active,
.toolbar-btn, .toolbar-btn:hover, .toolbar-btn:active {
  cursor: url('/shared/img/jessos-cursor.png'), auto !important;
}

/* Text input cursor - keep system text cursor for editing */
input[type="text"], input[type="password"], input[type="email"],
input[type="search"], input[type="number"], textarea,
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus,
input[type="search"]:focus, input[type="number"]:focus, textarea:focus {
  cursor: text;
}

/* Sidebar resize handle - override global cursor for resize behavior */
.files-sidebar-resize,
.files-sidebar-resize:hover,
.files-sidebar-resize:active {
  cursor: url('/shared/img/BeOS5-Horizontal-Resize.png') 8 8, col-resize !important;
}

/* ===================== GLOBAL FONT ===================== */
*, *::before, *::after {
  font-family: "Ubuntu", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===================== RESET & BASE ===================== */
* {
  box-sizing: border-box;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Ubuntu", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: var(--text-primary);
}

/* Wallpaper */
body {
  background-image: url("/shared/img/ubuntuwallpaper2.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-color: #000;
}

/* ===================== DESKTOP LAYOUT ===================== */
.desktop {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.desktop-main {
  flex: 1;
  position: relative;
  padding: 16px 8px 24px;
  display: flex;
  flex-direction: column;
}

/* Z-Index Layering */
#desktop-bg { z-index: 0; }
#dock       { z-index: 100; }
#window     { z-index: 50; }
.top-bar    { z-index: 200; }

/* ===================== WINDOW SHELL ===================== */
.window-shell {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 96px;
}

@media (max-width: 600px) {
  .window-shell {
    padding-top: 72px;
  }
}

/* ===================== WINDOW CHROME ===================== */
.window {
  width: min(96vw, 1100px);
  height: 700px;
  max-height: calc(100vh - 80px);
  background: var(--window-bg);
  border-radius: 6px;
  box-shadow: var(--window-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 50;
}

@media (max-height: 700px) {
  .window {
    height: calc(100vh - 80px);
  }
}

.window.drag-over {
  filter: brightness(0.85);
}

/* Title Bar - GNOME Dark Style */
.window-header {
  height: 38px;
  flex-shrink: 0;
  background: var(--headerbar-bg);
  color: var(--headerbar-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  text-shadow: var(--text-shadow);
}

.window-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.window-btn {
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.window-btn img {
  width: 14px;
  height: 14px;
  display: block;
}

/* Window button hover states (show different icon on hover) */
.window-btn .btn-normal { display: block; }
.window-btn .btn-hover { display: none; }
.window-btn:hover .btn-normal { display: none; }
.window-btn:hover .btn-hover { display: block; }

/* Fallback for windows without icon images */
.window-btn.close { background: transparent; }
.window-btn.min { background: transparent; }
.window-btn.max { background: transparent; }

.window-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.window-icon {
  width: 20px;
  height: 20px;
}

.window-spacer {
  flex: 1;
}

.window-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg-view);
  overflow: hidden;
}

/* ===================== BREADCRUMB NAVIGATION ===================== */
.window-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: auto;
}

.window-breadcrumb .back-link {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  opacity: 0.8;
}

.window-breadcrumb .back-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.window-breadcrumb .separator {
  opacity: 0.5;
}

/* ===================== MODAL OVERLAYS ===================== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.modal-window {
  width: min(420px, 90vw);
  background: var(--bg-window);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  border: 1px solid var(--border-dark);
}

.modal-header {
  height: 34px;
  background: var(--headerbar-bg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--headerbar-text);
  font-size: 13px;
  text-shadow: var(--text-shadow);
}

.modal-title {
  font-weight: 500;
}

.modal-body {
  padding: 16px;
  color: var(--text-primary);
}

/* Modal Inputs */
.modal-body input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--input-text);
  font-family: inherit;
  font-size: 13px;
  box-shadow: var(--input-shadow);
}

.modal-body input[type="text"]:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: var(--input-shadow), 0 0 0 var(--focus-ring-width) var(--focus-ring);
}

.modal-body input[type="text"]::placeholder {
  color: var(--input-placeholder);
}

/* Modal Buttons */
.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--btn-shadow);
  text-shadow: var(--text-shadow);
}

.modal-btn:hover {
  background: var(--btn-bg-hover);
}

.modal-btn:active {
  background: var(--btn-bg-active);
  box-shadow: var(--btn-shadow-active);
}

.modal-btn.primary {
  background: var(--btn-suggested-bg);
  border-color: transparent;
  color: #fff;
}

.modal-btn.primary:hover {
  background: var(--btn-suggested-hover);
}

.modal-btn.primary:active {
  background: var(--btn-suggested-active);
}

/* ===================== CONTEXT MENU ===================== */
.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 160px;
  background: var(--popover-bg);
  border: 1px solid var(--popover-border);
  border-radius: 8px;
  box-shadow: var(--popover-shadow);
  font-size: 13px;
  padding: 6px 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: url('/shared/img/jessos-cursor.png'), auto;
  white-space: nowrap;
  color: var(--menu-text);
  transition: background 100ms;
}

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

.context-menu-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.context-menu-item.danger {
  color: var(--gp-error);
}

.context-menu-item.danger:hover {
  background: rgba(207, 102, 121, 0.2);
  color: var(--gp-error);
}

.context-menu-separator {
  height: 1px;
  margin: 6px 0;
  background: var(--menu-separator);
}

/* ===================== TOAST NOTIFICATIONS ===================== */
.jessos-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: 8px;
  background: var(--gp-gray-900);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-default);
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.jessos-toast-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.jessos-toast-success { background: #1e4620; border-color: var(--gp-success); }
.jessos-toast-error { background: #4a1e1e; border-color: var(--gp-error); }
.jessos-toast-warning { background: #4a3a1e; border-color: var(--gp-warning); }

/* Alternative toast style */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gp-gray-900);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  font-size: 13px;
  z-index: 9999;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toast.fade-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* ===================== LOADING STATES ===================== */
.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

.app-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--gp-accent);
  border-top-color: transparent;
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===================== PLACEHOLDER APP ===================== */
.app-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
}

.app-placeholder img {
  width: 64px;
  height: 64px;
  opacity: 0.5;
}

.app-placeholder .title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
}

.app-placeholder .subtitle {
  font-size: 12px;
  opacity: 0.7;
}

/* ===================== CONTROL PANEL GRID ===================== */
.control-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 24px;
  padding: 32px;
}

.control-panel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.control-panel-item:hover {
  background: var(--hover-overlay);
}

.control-panel-item img {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}

.control-panel-item .label {
  font-size: 12px;
  text-align: center;
  color: var(--text-primary);
}

/* ===================== TRANSFERS PANEL ===================== */
.transfers-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  font-family: "Ubuntu", system-ui, sans-serif;
  font-size: 12px;
  z-index: 9999;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.transfers-panel.hidden {
  transform: translateY(100%);
}

/* Header row (always visible) */
.transfers-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  user-select: none;
}

.transfers-header:hover {
  background: var(--gp-gray-600);
}

.transfers-toggle {
  font-size: 10px;
  width: 12px;
  color: var(--text-muted);
}

.transfers-title {
  font-weight: 500;
  color: var(--text-primary);
}

.transfers-global-progress {
  flex: 1;
  max-width: 200px;
  height: 10px;
  background: var(--gp-gray-700);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.transfers-global-fill {
  height: 100%;
  background: var(--gp-success);
  transition: width 0.3s ease;
}

.transfers-global-text {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 80px;
  text-align: right;
}

/* Per-item list (collapsible) */
.transfers-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
  background: var(--bg-view);
}

.transfers-panel.collapsed .transfers-list {
  display: none;
}

/* Individual transfer row */
.transfer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-default);
}

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

.transfer-row.complete {
  opacity: 0.7;
}

.transfer-row.error {
  background: rgba(207, 102, 121, 0.1);
}

.transfer-icon {
  font-size: 14px;
  width: 16px;
  text-align: center;
  color: var(--text-muted);
}

.transfer-row.complete .transfer-icon { color: var(--gp-success); }
.transfer-row.error .transfer-icon { color: var(--gp-error); }

.transfer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.transfer-status {
  min-width: 70px;
  color: var(--text-secondary);
}

.transfer-progress-bar {
  width: 80px;
  height: 8px;
  background: var(--gp-gray-700);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.transfer-progress-fill {
  height: 100%;
  background: var(--gp-success);
  transition: width 0.3s ease;
}

/* Indeterminate shimmer animation */
.transfer-progress-bar.indeterminate .transfer-progress-fill {
  width: 30%;
  animation: transfer-shimmer 1.5s ease-in-out infinite;
}

@keyframes transfer-shimmer {
  0% { margin-left: -30%; }
  100% { margin-left: 100%; }
}

.transfer-count {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 50px;
}

.transfer-percent {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 30px;
  text-align: right;
}

.transfer-error {
  color: var(--gp-error);
  font-size: 11px;
}

/* Cancel button */
.transfer-cancel-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: var(--gp-gray-600);
  border-radius: 50%;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.transfer-cancel-btn:hover {
  background: var(--gp-gray-550);
  color: var(--gp-error);
}

/* Dismiss button (for completed/error rows) */
.transfer-dismiss-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.transfer-dismiss-btn:hover {
  background: var(--hover-overlay);
  color: var(--text-secondary);
}

/* Global progress indeterminate animation */
.transfers-global-progress.indeterminate .transfers-global-fill {
  animation: transfer-shimmer 1.5s ease-in-out infinite;
}

/* ===================== UTILITY CLASSES ===================== */
.muted {
  color: var(--text-muted);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 600px) {
  .window {
    width: 100%;
    max-height: calc(100vh - 120px);
    border-radius: 0;
  }
}
