/* ==========================================================================
   Memo_Modal Styles — public/memo-modal.css
   Meeting Notes Memo feature (spec: meeting-notes-memo)

   All styles use design tokens from public/design-tokens.css (--dt-* prefix).
   No new CSS variables are defined here. Dark mode is handled automatically
   because --dt-* variables switch via prefers-color-scheme: dark.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Floating panel (no backdrop overlay)
   -------------------------------------------------------------------------- */
.memo-modal {
  position: fixed;
  z-index: 9000;
  /* default position: bottom-left area (opposite side from agenda) */
  bottom: 80px;
  left: 24px;
  width: 720px;
  height: 640px;
  min-width: 280px;
  max-width: 90vw;
  max-height: 90vh;
  background: transparent;
  pointer-events: none;
}

.memo-modal.is-open {
  pointer-events: auto;
}

.memo-modal[hidden] {
  display: none !important;
}

/* Overlay no longer needed */
.memo-modal__overlay {
  display: none;
}

/* --------------------------------------------------------------------------
   Panel (floating card)
   -------------------------------------------------------------------------- */
.memo-modal__panel {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: var(--dt-bg-surface, #ffffff);
  color: var(--dt-text-primary, #0a0f1a);
  border-radius: var(--dt-radius-lg, 16px);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.22), 0 2px 8px rgba(15,23,42,0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Header — drag handle
   -------------------------------------------------------------------------- */
.memo-modal__header {
  display: flex;
  align-items: flex-start;
  gap: var(--dt-space-3, 12px);
  padding: var(--dt-space-3, 12px) var(--dt-space-4, 16px);
  border-bottom: 1px solid var(--dt-border-default, #e2e8f0);
  flex-wrap: wrap;
  cursor: grab;
  user-select: none;
  background: var(--dt-color-neutral-100, #f3f4f6);
  border-radius: var(--dt-radius-lg, 16px) var(--dt-radius-lg, 16px) 0 0;
}

.memo-modal__header:active {
  cursor: grabbing;
}

.memo-modal__header h2 {
  margin: 0;
  flex: 1 1 auto;
  font-size: var(--dt-font-size-lg, 21px);
  font-weight: var(--dt-font-weight-semibold, 600);
  color: var(--dt-text-primary);
  line-height: var(--dt-leading-tight, 1.3);
}

.memo-modal__close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--dt-text-secondary, #4a5568);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--dt-radius-sm, 8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}

.memo-modal__close:hover,
.memo-modal__close:focus-visible {
  background: var(--dt-color-neutral-200, #e5e7eb);
  color: var(--dt-text-primary);
  outline: none;
}

/* --------------------------------------------------------------------------
   Role note bar (info hint below header)
   -------------------------------------------------------------------------- */
.memo-modal__note {
  flex: 1 0 100%;
  margin: 0;
  padding: var(--dt-space-2, 8px) var(--dt-space-3, 12px);
  background: var(--dt-color-primary-50, var(--dt-bg-subtle, #f3f4f6));
  color: var(--dt-text-secondary, #4a5568);
  font-size: var(--dt-font-size-sm, 15px);
  line-height: var(--dt-leading-normal, 1.5);
  border-radius: var(--dt-radius-sm, 8px);
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */
.memo-modal__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dt-space-2, 8px);
  padding: var(--dt-space-2, 8px) var(--dt-space-4, 16px);
  background: var(--dt-color-neutral-100, var(--dt-bg-subtle, #f3f4f6));
  border-bottom: 1px solid var(--dt-border-default, #e2e8f0);
}

.memo-toolbar__group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: var(--dt-space-3, 12px);
}

.memo-toolbar__group:not(:last-child) {
  border-right: 2px solid var(--dt-color-neutral-300, #cbd5e1);
  margin-right: var(--dt-space-2, 8px);
}

.memo-modal__toolbar button {
  min-width: 36px;
  min-height: 36px;
  padding: 0 var(--dt-space-2, 8px);
  border: none;
  background: transparent;
  color: var(--dt-text-primary);
  border-radius: var(--dt-radius-sm, 8px);
  cursor: pointer;
  font-size: var(--dt-font-size-sm, 15px);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
}

.memo-modal__toolbar button:hover,
.memo-modal__toolbar button:focus-visible {
  background: var(--dt-color-neutral-200, #e5e7eb);
  outline: none;
}

.memo-modal__toolbar button:active,
.memo-modal__toolbar button[aria-pressed="true"] {
  background: var(--dt-color-primary-100, #dbeafe);
}

/* Font size buttons — visual size difference to aid recognition */
.memo-modal__toolbar button[data-memo-cmd="fontSize"][data-value="small"] {
  font-size: 13.5px;
}

.memo-modal__toolbar button[data-memo-cmd="fontSize"][data-value="medium"] {
  font-size: 13.5px;
}

.memo-modal__toolbar button[data-memo-cmd="fontSize"][data-value="large"] {
  font-size: 17px;
}

/* Color swatch buttons (inline background-color set from JS data-value) */
.memo-modal__toolbar button[data-memo-cmd="color"] {
  min-width: 28px;
  min-height: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--dt-border-default, #e2e8f0);
}

.memo-modal__toolbar button[data-memo-cmd="color"]:hover,
.memo-modal__toolbar button[data-memo-cmd="color"]:focus-visible {
  outline: 2px solid var(--dt-accent-primary, #1f6feb);
  outline-offset: 2px;
  background: transparent;
}

/* --------------------------------------------------------------------------
   Editor (contenteditable)
   -------------------------------------------------------------------------- */
.memo-modal__editor {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: none;
  overflow-y: auto;
  padding: var(--dt-space-4, 16px);
  font-size: var(--dt-font-size-base, 16px);
  line-height: var(--dt-leading-relaxed, 1.7);
  color: var(--dt-text-primary);
  background: var(--dt-bg-surface, #ffffff);
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.memo-modal__editor:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--dt-accent-primary, #1f6feb);
}

.memo-modal__editor[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--dt-text-muted, #94a3b8);
  pointer-events: none;
  display: block;
}

.memo-modal__editor[contenteditable="false"] {
  background: var(--dt-bg-subtle, #f3f4f6);
  color: var(--dt-text-secondary, #4a5568);
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Footer (status + retry)
   -------------------------------------------------------------------------- */
.memo-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--dt-space-3, 12px);
  padding: var(--dt-space-3, 12px) var(--dt-space-4, 16px);
  border-top: 1px solid var(--dt-border-default, #e2e8f0);
  font-size: var(--dt-font-size-sm, 15px);
}

.memo-modal__status {
  color: var(--dt-text-secondary, #4a5568);
  font-size: var(--dt-font-size-sm, 15px);
}

.memo-modal__retry {
  min-height: 32px;
  padding: 4px var(--dt-space-3, 12px);
  border: 1px solid var(--dt-color-danger-300, #fca5a5);
  border-radius: var(--dt-radius-sm, 8px);
  background: var(--dt-color-danger-50, #fef2f2);
  color: var(--dt-color-danger-700, #b91c1c);
  font-size: var(--dt-font-size-sm, 15px);
  font-weight: var(--dt-font-weight-medium, 500);
  cursor: pointer;
  transition: background 120ms ease;
}

.memo-modal__retry:hover,
.memo-modal__retry:focus-visible {
  background: var(--dt-color-danger-100, #fee2e2);
  outline: none;
}

.memo-modal__retry[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Mobile: full-screen modal
   Container-query preferred; media-query fallback since the ancestor may not
   be a container-query root in the existing app.
   -------------------------------------------------------------------------- */
@container (max-width: 600px) {
  .memo-modal {
    bottom: 0; left: 0; right: 0;
    width: 100% !important;
    max-width: 100%;
    height: 70vh !important;
  }
  .memo-modal__panel { border-radius: 0; }
  .memo-modal__toolbar { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 640px) {
  .memo-modal {
    bottom: 0; left: 0; right: 0;
    width: 100% !important;
    max-width: 100%;
    height: 70vh !important;
  }
  .memo-modal__panel { border-radius: 0; }
  .memo-modal__toolbar { overflow-x: auto; flex-wrap: nowrap; }
  .memo-modal__toolbar button { min-width: 44px; min-height: 44px; }
  .memo-modal__editor { max-height: none; }
}

/* Mobile: larger color swatches and undo/redo targets */
@media (max-width: 640px) {
  .memo-modal__toolbar button[data-memo-cmd="color"] {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
  }
  .memo-toolbar__group[aria-label="取り消し/やり直し"] button {
    min-width: 48px;
    min-height: 48px;
    margin: 0 4px;
  }
  .memo-modal__editor {
    max-height: calc(var(--memo-modal-vh, 100vh) - 220px);
  }
}

/* --------------------------------------------------------------------------
   Resize handle (bottom-right corner)
   -------------------------------------------------------------------------- */
.memo-modal__resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: se-resize;
  z-index: 10;
  background-image:
    radial-gradient(circle, var(--dt-color-neutral-400, #9ca3af) 1.5px, transparent 1.5px),
    radial-gradient(circle, var(--dt-color-neutral-400, #9ca3af) 1.5px, transparent 1.5px),
    radial-gradient(circle, var(--dt-color-neutral-400, #9ca3af) 1.5px, transparent 1.5px);
  background-size: 6px 6px;
  background-position: 10px 10px, 4px 10px, 10px 4px;
  background-repeat: no-repeat;
  border-radius: 0 0 var(--dt-radius-lg, 16px) 0;
}
