/**
 * Web Desktop — main stylesheet.
 *
 * Provides styling for the login screen, desktop surface, toolbar,
 * context menu, editor dialogs, progress overlay, and file icons.
 */

/* ── Reset & base ───────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: #222;
  overflow: hidden;
  background: #1a1a2e;
}

/* ── Login screen ───────────────────────────────────────────────── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 40px 36px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
  color: #1a1a2e;
}

.login-subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #444;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #0f3460;
  box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.15);
}

#login-form button[type="submit"] {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: #0f3460;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

#login-form button[type="submit"]:hover {
  background: #16213e;
}

.error-message {
  margin-top: 12px;
  color: #d32f2f;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Desktop ────────────────────────────────────────────────────── */

.desktop {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
}

/* ── Toolbar ────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 44px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  color: #eee;
  flex-shrink: 0;
  z-index: 500;
}

.toolbar-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.toolbar-actions button {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #eee;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s;
}

.toolbar-actions button:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ── Desktop area (icon surface) ────────────────────────────────── */

.desktop-area {
  flex: 1;
  position: relative;
  overflow: auto;
}

/* ── Desktop icons ──────────────────────────────────────────────── */

.desktop-icon {
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 8px 4px;
  border-radius: 6px;
  transition: background 0.15s;
}

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

.desktop-icon img {
  width: 48px;
  height: 48px;
  pointer-events: none;
}

.desktop-icon-label {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #e0e0e0;
  text-align: center;
  word-break: break-all;
  max-width: 76px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ── Context menu ───────────────────────────────────────────────── */

.context-menu {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  min-width: 160px;
  padding: 4px 0;
  z-index: 10000;
  overflow: hidden;
}

.context-menu-item {
  padding: 8px 18px;
  cursor: pointer;
  font-size: 0.88rem;
  color: #333;
  transition: background 0.12s;
}

.context-menu-item:hover {
  background: #0f3460;
  color: #fff;
}

/* ── Editor window ──────────────────────────────────────────────── */

.editor-window {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  min-width: 300px;
  min-height: 200px;
  z-index: 1000;
  box-sizing: border-box;
}

.editor-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 36px;
  background: #0f3460;
  color: #fff;
  cursor: move;
  font-size: 0.85rem;
  font-weight: 500;
  user-select: none;
  flex-shrink: 0;
}

.editor-titlebar.saving {
  background: #0d2d55;
  transition: background 0.3s;
}

.editor-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.editor-close-btn:hover {
  color: #ff6b6b;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  border: none;
  padding: 12px;
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  line-height: 1.5;
}


/* ── Loading overlay ────────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
}

.loading-content {
  background: #fff;
  padding: 24px 36px;
  border-radius: 10px;
  text-align: center;
  min-width: 260px;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #0f3460;
  border-radius: 4px;
  transition: width 0.2s ease;
}

#loading-text {
  font-size: 0.85rem;
  color: #666;
}

/* ── Rename input (inline on icon) ──────────────────────────────── */

.rename-input {
  width: 76px;
  font-size: 0.72rem;
  text-align: center;
  border: 1px solid #0f3460;
  border-radius: 3px;
  padding: 2px;
  outline: none;
  background: #fff;
  color: #222;
}

/* ── Custom dialog ─────────────────────────────────────────────── */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30000;
}

.dialog-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  padding: 24px 28px;
  min-width: 320px;
  max-width: 460px;
  width: 90vw;
}

.dialog-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1a1a2e;
}

.dialog-message {
  font-size: 0.92rem;
  color: #444;
  margin-bottom: 18px;
  line-height: 1.5;
}

.dialog-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  margin-bottom: 18px;
  outline: none;
  transition: border-color 0.2s;
}

.dialog-input:focus {
  border-color: #0f3460;
  box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.15);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-btn {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #ccc;
  background: #f5f5f5;
  color: #333;
  transition: background 0.15s;
}

.dialog-btn:hover {
  background: #e8e8e8;
}

.dialog-btn-primary {
  background: #0f3460;
  color: #fff;
  border-color: #0f3460;
}

.dialog-btn-primary:hover {
  background: #16213e;
}

/* ── Connection status indicator ───────────────────────────────── */

.connection-status {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 10px;
  transition: background 0.3s;
  flex-shrink: 0;
}

.connection-status.online {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.connection-status.offline {
  background: #f44336;
  box-shadow: 0 0 6px rgba(244, 67, 54, 0.5);
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .login-card {
    padding: 28px 20px;
    width: 95vw;
  }

  .toolbar-actions button {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
}
