/* ─── Vinara App Styles ───────────────────────────────────────
 *  App-specific styles for the note-taking interface.
 *  Shared variables and base styles come from ../style.css.
 * ───────────────────────────────────────────────────────────── */

/* App layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app header {
  flex-shrink: 0;
}

.app .body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Wordmark link */
.wordmark {
  text-decoration: none;
  color: inherit;
}

/* Sidebar */
.sidebar {
  width: 260px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.sidebar-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-search svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-dim);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sidebar-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.sidebar-search input::placeholder {
  color: var(--text-dim);
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.note-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.pin-section-label {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.note-item {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.1s;
}

.note-item:hover {
  background: var(--hover);
}

.note-item.active {
  background: var(--active);
}

.note-item.pinned.active {
  background: var(--active);
}

.note-item-title {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.note-item:hover .note-actions {
  opacity: 1;
}

.delete-indicator,
.rename-indicator,
.pin-indicator {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
}

.delete-indicator:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.rename-indicator:hover,
.pin-indicator:hover {
  background: var(--hover);
  color: var(--text);
}

.pin-indicator svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.note-item.pinned .pin-indicator svg {
  fill: var(--accent);
}

.note-item-date {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.note-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--text-dim);
}

/* Main area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.panel.active {
  display: flex;
}

/* Editor toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.editor-meta {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 80px;
}

.input-mode-group,
.latin-sub-group {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.input-mode-btn,
.latin-sub-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-ui);
}

.input-mode-btn.active,
.latin-sub-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.editor-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* Font size toggle */
.font-size-group {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.font-size-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-ui);
  min-width: 28px;
}

.font-size-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Editor size classes */
#editor.font-small,
#vinaraPreviewContent.font-small {
  font-size: 32px;
}

#editor.font-medium,
#vinaraPreviewContent.font-medium {
  font-size: 48px;
}

#editor.font-large,
#vinaraPreviewContent.font-large {
  font-size: 72px;
}

/* Editor */
.editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
}

#editor {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  line-height: 1.7;
  resize: none;
  outline: none;
  padding: 0;
}

#editor.vinara-font {
  font-family: 'Vinara', serif;
}

#latinView {
  flex: 1;
  gap: 8px;
}

.latin-editor {
  flex: 1;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  outline: none;
  padding: 12px;
  font-family: var(--font-ui);
}

.vinara-preview-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.vinara-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.vinara-preview-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.vinara-preview-actions {
  display: flex;
  gap: 6px;
}

.vinara-preview-content {
  flex: 1;
  padding: 12px;
  font-family: 'Vinara', serif;
  line-height: 1.7;
  overflow-y: auto;
  color: var(--text);
  background: var(--bg);
}

/* Capture target */
#capture-target {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 800px;
  padding: 40px;
  font-family: 'Vinara', serif;
  font-size: 48px;
  line-height: 1.8;
  background: #ffffff;
  color: #000000;
  white-space: pre-wrap;
  display: none;
}

#capture-target.font-small {
  font-size: 32px;
}

#capture-target.font-medium {
  font-size: 48px;
}

#capture-target.font-large {
  font-size: 72px;
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 101;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-handle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.drawer-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.ref-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ref-key {
  text-align: center;
  padding: 8px 4px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ref-vinara {
  font-family: 'Vinara', serif;
  font-size: 22px;
  line-height: 1.2;
  color: var(--text);
}

.ref-thaana {
  font-family: 'Noto Sans Thaana', 'Thaana', sans-serif;
  font-size: 16px;
  line-height: 1.2;
  color: var(--text-dim);
  margin-top: 2px;
  min-height: 20px;
}

.ref-roman {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 200;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.shortcut-row:last-of-type {
  border-bottom: none;
  margin-bottom: 16px;
}

.key {
  display: flex;
  gap: 4px;
  align-items: center;
}

.key kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

.close-modal {
  width: 100%;
  margin-top: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

/* Stats bar */
.stats-bar {
  font-size: 11px;
  color: var(--text-dim);
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}

.save-dot.saving {
  background: var(--accent);
  animation: pulse 0.6s infinite alternate;
}

.save-dot.saved {
  background: #22c55e;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Font dot */
.font-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.font-dot.loaded {
  background: #22c55e;
}

.font-dot.missing {
  background: var(--danger);
}

/* Mobile */
@media (max-width: 600px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .drawer {
    width: 100%;
    max-width: 100vw;
  }
  .ref-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .editor-toolbar {
    padding: 8px;
  }
  .editor-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }
}
