/* ── Gmail-Style Right Panel ── */

.rp {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 360px;
  z-index: 600;
  pointer-events: none;
  font-family: "Google Sans", Roboto, system-ui, -apple-system, sans-serif;
}

.rp.rp-open {
  pointer-events: auto;
}

.rp-sheet {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.rp.rp-open .rp-sheet {
  transform: translateX(0);
}

/* Header */
.rp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px 6px 16px;
  flex-shrink: 0;
}

.rp-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  flex: 1;
}

.rp-header-btns {
  display: flex;
  gap: 2px;
}

.rp-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 120ms ease, color 120ms ease;
  flex-shrink: 0;
  padding: 0;
}

.rp-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Save-Button in Note-Header bekommt Akzentfarbe */
#rp-note-save-btn {
  color: var(--accent);
}

#rp-note-save-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Title bar */
.rp-title-bar {
  padding: 2px 16px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rp-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
  line-height: 1.2;
}

.rp-cal-select {
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  max-width: 130px;
  outline: none;
  font-family: inherit;
}

/* View switching */
.rp-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.rp-view.hidden {
  display: none;
}

.rp-subview {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.rp-subview.hidden {
  display: none;
}

/* ── Tasks View ── */

.rp-add-task-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 100ms;
  min-height: 48px;
}

.rp-add-task-row:hover {
  background: var(--bg-hover);
}

.rp-add-circle {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: border-color 120ms ease, color 120ms ease;
}

.rp-add-task-row:hover .rp-add-circle {
  border-color: var(--accent);
  color: var(--accent);
}

.rp-add-placeholder {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
  user-select: none;
}

/* Task detail form */
.rp-task-detail {
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.rp-task-detail.hidden {
  display: none;
}

.rp-task-detail-title {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  padding: 4px 0 8px;
  outline: none;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.rp-task-detail-title::placeholder {
  color: var(--text-tertiary);
}

.rp-task-detail-desc {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  padding: 0 0 8px;
  outline: none;
  resize: none;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.rp-task-detail-desc::placeholder {
  color: var(--text-tertiary);
}

.rp-task-detail-desc:focus {
  border-bottom-color: var(--accent);
}

.rp-task-detail-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.rp-task-detail-row select,
.rp-task-detail-row input[type="date"] {
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  outline: none;
  flex: 1;
  min-width: 80px;
}

.rp-task-detail-row select:focus,
.rp-task-detail-row input:focus {
  border-color: var(--accent);
}

.rp-task-detail-actions {
  display: flex;
  gap: 8px;
}

.rp-save-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 4px;
  padding: 7px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, box-shadow 150ms;
}

.rp-save-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.rp-save-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.rp-cancel-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms;
}

.rp-cancel-btn:hover {
  background: var(--accent-soft);
}

/* Task list */
.rp-task-list-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.rp-task-list-wrap::-webkit-scrollbar { width: 6px; }
.rp-task-list-wrap::-webkit-scrollbar-track { background: transparent; }
.rp-task-list-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.rp-task-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.rp-task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  position: relative;
  transition: background 100ms;
  min-height: 48px;
}

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

.rp-task-item:hover .rp-task-edit-btn,
.rp-task-item:hover .rp-task-del-btn {
  opacity: 1;
}

/* Task circle (Gmail-style checkbox) */
.rp-task-circle {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  margin-top: 2px;
  transition: border-color 150ms, background 150ms, transform 150ms;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.rp-task-circle:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}

.rp-task-circle.checked {
  border-color: var(--accent);
  background: var(--accent);
  animation: rpCheckPop 200ms ease;
}

@keyframes rpCheckPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.rp-task-circle.checked::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
  display: block;
}

/* Task content */
.rp-task-content {
  flex: 1;
  min-width: 0;
}

.rp-task-title {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
  display: block;
  word-break: break-word;
}

.rp-task-item.rp-task-done .rp-task-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.rp-task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.rp-task-due {
  font-size: 11px;
  color: var(--text-secondary);
}

.rp-task-due.overdue {
  color: var(--danger);
  font-weight: 500;
}

.rp-task-prio {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.rp-task-prio.high { background: rgba(201, 87, 107, 0.15); color: var(--danger); }
.rp-task-prio.mid  { background: rgba(212, 162, 76, 0.15); color: var(--warning); }
.rp-task-prio.low  { background: var(--accent-soft); color: var(--accent); }

.rp-task-desc-preview {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Task action buttons (appear on hover) */
.rp-task-edit-btn,
.rp-task-del-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  opacity: 0;
  transition: background 100ms, opacity 150ms;
  flex-shrink: 0;
  padding: 0;
  margin-top: -4px;
}

.rp-task-edit-btn:hover,
.rp-task-del-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Empty state */
.rp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 32px;
  text-align: center;
  flex: 1;
}

.rp-empty-state.hidden {
  display: none;
}

.rp-empty-illus {
  width: 128px;
  height: 128px;
  margin-bottom: 20px;
}

.rp-empty-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 8px;
  line-height: 1.4;
}

.rp-empty-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* Completed section */
.rp-completed-section {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.rp-completed-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  transition: background 100ms;
}

.rp-completed-toggle:hover {
  background: var(--bg-hover);
}

.rp-chevron {
  width: 18px;
  height: 18px;
  transition: transform 200ms ease;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.rp-chevron.open {
  transform: rotate(0deg);
}

.rp-chevron.closed {
  transform: rotate(-90deg);
}

.rp-completed-count {
  color: var(--text-secondary);
}

.rp-completed-list {
  max-height: 260px;
  overflow-y: auto;
}

.rp-completed-list::-webkit-scrollbar { width: 6px; }
.rp-completed-list::-webkit-scrollbar-track { background: transparent; }
.rp-completed-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.rp-loading-msg {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── Notes View ── */

.rp-add-note-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 100ms;
  min-height: 48px;
}

.rp-add-note-row:hover {
  background: var(--bg-hover);
}

.rp-add-note-text {
  font-size: 14px;
  color: var(--text-tertiary);
  flex: 1;
  user-select: none;
}

.rp-notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rp-notes-list::-webkit-scrollbar { width: 6px; }
.rp-notes-list::-webkit-scrollbar-track { background: transparent; }
.rp-notes-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* Note card */
.rp-note-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow 150ms, border-color 150ms;
  background: var(--bg-elevated);
  position: relative;
}

.rp-note-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.rp-note-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
  line-height: 1.35;
  word-break: break-word;
}

.rp-note-card-body {
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.rp-note-card-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  display: block;
}

.rp-note-card-actions {
  display: none;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.rp-note-card:hover .rp-note-card-actions {
  display: flex;
}

.rp-note-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 100ms;
  padding: 0;
}

.rp-note-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.rp-notes-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.rp-notes-empty svg {
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Note edit subview */
.rp-note-edit-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 16px 16px;
  overflow-y: auto;
  gap: 0;
}

.rp-note-edit-body::-webkit-scrollbar { width: 6px; }
.rp-note-edit-body::-webkit-scrollbar-track { background: transparent; }
.rp-note-edit-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.rp-note-edit-title {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  padding: 10px 0 10px;
  outline: none;
  box-sizing: border-box;
}

.rp-note-edit-title:focus {
  border-bottom-color: var(--accent);
}

.rp-note-edit-title::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.rp-note-edit-content {
  flex: 1;
  width: 100%;
  min-height: 180px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  padding: 10px 0;
  outline: none;
  resize: none;
  box-sizing: border-box;
  line-height: 1.6;
}

.rp-note-edit-content::placeholder {
  color: var(--text-tertiary);
}

.rp-note-edit-meta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.rp-note-edit-meta select,
.rp-note-edit-meta input[type="date"] {
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  outline: none;
  flex: 1;
  min-width: 100px;
}

.rp-note-edit-meta select:focus,
.rp-note-edit-meta input:focus {
  border-color: var(--accent);
}

/* Delete-Button im Notiz-Header */
.rp-icon-btn.rp-danger:hover {
  background: rgba(201, 87, 107, 0.15);
  color: var(--danger);
}

/* Character counter */
.rp-char-counter {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: right;
  margin-top: 2px;
  margin-bottom: 6px;
  user-select: none;
  line-height: 1.2;
  transition: color 120ms;
}

.rp-char-counter.rp-char-near {
  color: var(--warning);
}

.rp-char-counter.rp-char-limit {
  color: var(--danger);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 600px) {
  .rp {
    width: 100vw;
  }
}
