/* Osadzenie Oni Nasi — @scope (.drzewo-rod-host), :scope = aktywny kontener osadzenia */
@scope (.drzewo-rod-host) {
:scope { height: 100%; margin: 0; }
    :scope {
      color-scheme: light;
      font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    }
    * { box-sizing: border-box; }

    :scope {
      margin: 0;
      background: #f7f7f7;
      color: #1f2933;
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      overflow: hidden;
      position: relative;
    }

    header {
      padding: 16px 24px;
      background: linear-gradient(135deg, #0f62fe, #0043ce);
      color: #fff;
      box-shadow: 0 2px 12px rgba(15, 98, 254, 0.3);
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .header-content {
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      gap: 16px;
    }
    header h1 { margin: 0; font-weight: 600; font-size: 1.5rem; text-align: center; flex: 1; }
    .header-actions { position: absolute; right: 24px; display: flex; gap: 10px; }
    .header-left { position: absolute; left: 24px; display: flex; align-items: center; }
    .header-left .btn-menu {
      padding: 8px 16px;
      font-size: 14px;
      background: rgba(255,255,255,0.2);
      color: #fff;
      border: 1px solid rgba(255,255,255,0.5);
      border-radius: 6px;
      cursor: pointer;
      transition: background 0.2s, border-color 0.2s;
    }
    .header-left .btn-menu:hover {
      background: rgba(255,255,255,0.35);
      border-color: rgba(255,255,255,0.8);
    }

    #breadcrumbs {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      padding: 12px 24px;
      background: #fff;
      border-bottom: 1px solid #e4e7eb;
      align-items: center;
    }
    .breadcrumb-item {
      padding: 6px 12px;
      border-radius: 999px;
      border: 1px solid transparent;
      background: #eef5ff;
      color: #0f62fe;
      cursor: pointer;
      font-size: 0.88rem;
      transition: all 0.2s ease;
    }
    .breadcrumb-item:hover {
      border-color: #0f62fe;
      background: #fff;
    }
    .breadcrumb-item.current {
      background: #0f62fe;
      color: #fff;
      cursor: default;
      border-color: transparent;
    }
    .breadcrumb-separator {
      margin: 0 4px;
      color: #6b7280;
    }

    main {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    .canvas-area {
      flex: 1;
      min-height: 0;
      display: flex;
      position: relative;
    }
    #canvasContainer {
      flex: 1;
      min-height: 0;
      overflow: auto;
      position: relative;
      -webkit-overflow-scrolling: touch;
      /* W osadzeniu (szeroki moduł + wąski canvas) bez tego zostaje pusta pionowa „szpala” po prawej */
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    canvas {
      display: block;
      background: #fff;
      margin: 0;
      box-shadow: 0 10px 30px rgba(15, 98, 254, 0.1);
      cursor: pointer;
    }

    .navigation-buttons {
      position: absolute;
      left: 16px;
      top: 16px;
      display: flex;
      gap: 8px;
      z-index: 5;
    }
    .return-to-main-btn {
      padding: 10px 18px;
      border-radius: 999px;
      border: 1px solid #0f62fe;
      background: #fff;
      color: #0f62fe;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s ease, color 0.2s ease;
      box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
      font-size: 14px;
    }
    .return-to-main-btn:hover {
      background: #0f62fe;
      color: #fff;
    }
    .return-to-main-btn.home-btn {
      padding: 10px 14px;
      font-size: 18px;
    }

    .tree-map-panel {
      position: absolute;
      left: 24px;
      top: 0;
      z-index: 10;
      min-width: 140px;
      max-width: 220px;
      background: rgba(255, 255, 255, 0.96);
      border-radius: 12px;
      box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
      overflow: hidden;
    }
    .tree-map-panel.collapsed .tree-map-list { display: none; }
    .tree-map-header {
      display: flex;
      align-items: center;
      padding: 6px 12px;
      border-radius: 999px;
      border: 1px solid transparent;
      background: #eef5ff;
      color: #0f62fe;
      cursor: pointer;
      font-size: 0.88rem;
      font-weight: 600;
      width: fit-content;
      margin: 4px 0 0 0;
      transition: border-color 0.15s ease, background 0.15s ease;
    }
    .tree-map-header:hover {
      border-color: #0f62fe;
      background: #fff;
    }
    .tree-map-title {
      font-weight: 600;
      font-size: 0.88rem;
      color: #0f62fe;
    }
    .tree-map-list {
      max-height: calc(100vh - 170px);
      overflow-y: auto;
      padding: 0 0 6px 0;
    }
    .tree-map-item {
      padding: 8px 14px;
      font-size: 0.88rem;
      cursor: pointer;
      transition: background 0.15s ease;
      color: #1f2933;
    }
    .tree-map-item:hover {
      background: rgba(15, 98, 254, 0.08);
    }
    .tree-map-item.current {
      background: rgba(15, 98, 254, 0.15);
      color: #0f62fe;
      font-weight: 600;
    }

    .cell-tooltip {
      position: fixed;
      z-index: 9999;
      padding: 6px 12px;
      background: rgba(15, 23, 42, 0.92);
      color: #fff;
      font-size: 14px;
      font-family: "Segoe UI", Arial, sans-serif;
      border-radius: 6px;
      pointer-events: none;
      white-space: nowrap;
      box-shadow: 0 4px 12px rgba(0,0,0,0.2);
      display: none;
      max-width: 90vw;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .cell-tooltip.visible {
      display: block;
    }

    .zoom-controls {
      position: absolute;
      right: 16px;
      bottom: 16px;
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 10px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.9);
      box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
      z-index: 5;
    }
    .zoom-controls button {
      padding: 4px 10px;
      border-radius: 999px;
      border: 1px solid #e2e8f0;
      background: #fff;
      color: #0f62fe;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s ease, color 0.2s ease;
    }
    .zoom-controls button:hover {
      background: #0f62fe;
      color: #fff;
    }
    .zoom-value {
      font-weight: 600;
      min-width: 48px;
      text-align: center;
      color: #1f2933;
    }

    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 10000;
      align-items: center;
      justify-content: center;
      background: rgba(9, 17, 34, 0.5);
      backdrop-filter: blur(6px);
    }
    .modal-overlay.visible {
      display: flex;
    }
    .modal-box {
      width: min(440px, 92vw);
      max-height: 85vh;
      overflow: auto;
      background: #fff;
      border: none;
      border-radius: 20px;
      padding: 0;
      box-shadow: 0 32px 64px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 98, 254, 0.08);
    }
    .modal-box.modal-wide {
      width: min(560px, 95vw);
    }
    dialog.prompt-dialog {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: min(440px, 92vw);
      border: none;
      border-radius: 20px;
      padding: 0;
      box-shadow: 0 32px 64px rgba(15, 23, 42, 0.28);
      background: white;
    }
    dialog.prompt-dialog::backdrop {
      background: white;
    }
    form.modal-form {
      display: flex;
      flex-direction: column;
      gap: 0;
    }
    form.modal-form h3 {
      margin: 0;
      padding: 24px 28px 20px;
      font-size: 1.25rem;
      font-weight: 600;
      color: #0f172a;
      background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
      border-bottom: 3px solid #0f62fe;
      letter-spacing: -0.02em;
    }
    form.modal-form .modal-form-body {
      padding: 24px 28px;
      display: flex;
      flex-direction: column;
      gap: 18px;
    }
    form.modal-form .form-field {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    form.modal-form .form-field label {
      font-weight: 400;
      font-size: 0.88rem;
      color: #475569;
      letter-spacing: 0.01em;
    }
    form.modal-form .form-info {
      font-size: 0.9rem;
      color: #475569;
      line-height: 1.5;
      padding: 12px 16px;
      background: #f8fafc;
      border-radius: 10px;
      border-left: 4px solid #0f62fe;
      margin: 0;
    }
    form.modal-form label { font-weight: 600; font-size: 0.9rem; color: #1e293b; }
    form.modal-form input,
    form.modal-form select,
    form.modal-form textarea {
      padding: 12px 16px;
      border-radius: 10px;
      border: 1px solid #e2e8f0;
      font-size: 1.02rem;
      font-weight: 600;
      background: #fff;
      color: #0f172a;
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    form.modal-form input:focus,
    form.modal-form select:focus,
    form.modal-form textarea:focus {
      outline: none;
      border-color: #0f62fe;
      box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.15);
    }
    form.modal-form input::placeholder { color: #94a3b8; }
    form.modal-form textarea {
      min-height: 100px;
      resize: vertical;
      font-family: inherit;
    }
    .form-photo-section {
      padding: 16px;
      background: #f8fafc;
      border-radius: 12px;
      border: 1px dashed #e2e8f0;
    }
    .form-photo-section label { margin-bottom: 4px; }
    .form-photo-preview {
      max-width: 140px;
      max-height: 140px;
      object-fit: cover;
      border-radius: 12px;
      border: 1px solid #e2e8f0;
      box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }
    dialog.prompt-dialog.form-wide {
      width: min(560px, 95vw);
      max-height: 90vh;
      top: 2vh;
      left: 50%;
      transform: translateX(-50%);
      overflow-y: auto;
      padding: 0;
    }
    .modal-actions {
      display: flex;
      gap: 12px;
      justify-content: flex-end;
      padding: 20px 28px 24px;
      background: #fafbfc;
      border-top: 1px solid #eef2f7;
    }

    .btn {
      padding: 8px 18px;
      border-radius: 999px;
      border: 2px solid transparent;
      font-weight: 600;
      cursor: pointer;
      transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    }
    .btn:active { transform: scale(0.98); }
    .btn-primary {
      background: #0f62fe;
      color: #fff;
      border-color: #0043ce;
      box-shadow: 0 8px 20px rgba(15, 98, 254, 0.25);
    }
    .btn-light {
      background: rgba(255, 255, 255, 0.85);
      color: #0f62fe;
      border-color: #d0e2ff;
      box-shadow: 0 8px 20px rgba(255, 255, 255, 0.25);
    }
    .btn-secondary {
      background: #eef2ff;
      color: #1f2933;
      border-color: #c7d2fe;
    }
    .btn-danger {
      background: #ff5c5c;
      color: #fff;
      border-color: #e11d48;
      box-shadow: 0 8px 20px rgba(255, 92, 92, 0.25);
    }

    #toast {
      position: fixed;
      bottom: 24px;
      right: 24px;
      min-width: 220px;
      padding: 14px 18px;
      background: rgba(15, 98, 254, 0.95);
      color: #fff;
      border-radius: 12px;
      box-shadow: 0 18px 40px rgba(15, 23, 42, 0.3);
      opacity: 0;
      transform: translateY(16px);
      pointer-events: none;
      transition: opacity 0.25s ease, transform 0.25s ease;
      z-index: 1000;
    }
    #toast.visible {
      opacity: 1;
      transform: translateY(0);
    }

    /* Panel Kosza (absolute w osadzeniu — fixed zasłaniałby drzewo w Oni Nasi) */
    #trashPanel {
      position: absolute;
      top: 0;
      right: 0;
      width: min(360px, 90vw);
      max-width: 360px;
      height: 100%;
      background: #fff;
      box-shadow: -4px 0 24px rgba(15, 23, 42, 0.15);
      z-index: 100;
      display: none;
      flex-direction: column;
      transform: translateX(100%);
      transition: transform 0.25s ease;
    }
    #trashPanel.open {
      display: flex;
      transform: translateX(0);
    }
    .trash-panel-header {
      padding: 16px 20px;
      border-bottom: 1px solid #e4e7eb;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #f8fafc;
    }
    .trash-panel-header h2 {
      margin: 0;
      font-size: 1.1rem;
      font-weight: 600;
      color: #1f2933;
    }
    .trash-panel-close {
      padding: 6px 12px;
      border: none;
      background: transparent;
      color: #64748b;
      cursor: pointer;
      font-size: 1.2rem;
      line-height: 1;
      border-radius: 8px;
    }
    .trash-panel-close:hover {
      background: #e2e8f0;
      color: #1f2933;
    }
    .trash-panel-body {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
    }
    .trash-panel-empty {
      color: #64748b;
      text-align: center;
      padding: 32px 16px;
      font-size: 0.95rem;
    }
    .trash-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px;
      border: 1px solid #e4e7eb;
      border-radius: 8px;
      margin-bottom: 8px;
      background: #fff;
    }
    .trash-item:hover {
      border-color: #0f62fe;
      background: #eef5ff;
    }
    .trash-item input[type="checkbox"] {
      width: 18px;
      height: 18px;
      cursor: pointer;
    }
    .trash-item-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .trash-item-name {
      font-weight: 500;
      color: #1f2933;
    }
    .trash-item-date {
      font-size: 0.75rem;
      color: #64748b;
    }
    .trash-panel-footer {
      padding: 16px 20px;
      border-top: 1px solid #e4e7eb;
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }
    .trash-panel-footer .btn {
      flex: 1;
      min-width: 120px;
    }
}
