/* ═══════════════════════════════════════════════
   Focus Mode UI Overrides
   ═══════════════════════════════════════════════ */

/* Base Container */
.focus-app-container {
  position: relative;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-primary); /* Slate-50 logic from root */
}

/* ─── DASHBOARD SCREEN ─── */
.dashboard-screen {
  position: absolute;
  inset: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(60px, env(safe-area-inset-bottom, 20px) + 30px);
  background: var(--bg-primary);
}

.dashboard-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97) translateY(20px);
}

.dashboard-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
}

.dashboard-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.dashboard-date {
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 500;
}

.header-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.search-form {
  position: relative;
}

.search-form input {
  width: 260px;
  height: 42px;
  border-radius: 21px;
  padding-left: 38px;
  padding-right: 32px;
  border: 1px solid transparent;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
}

.search-form input:focus {
  background: var(--bg-secondary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 13px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.btn-icon-clear {
  position: absolute;
  right: 12px;
  top: 13px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-new {
  border-radius: 21px;
  padding: 0 20px;
  height: 42px;
  font-weight: 600;
}

/* Filter Toolbar */
.filter-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: 16px;
  margin-bottom: 32px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.filter-tabs-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-tabs-container::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.view-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.sort-select {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  padding-right: 8px;
}

.layout-toggles {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 12px;
}

.layout-toggles .btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.layout-toggles .btn-icon.active {
  background: var(--bg-secondary);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Notes Layout */
.notes-grid {
  transition: all 0.3s;
}

.notes-grid.layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.notes-grid.layout-grid .note-card {
  margin-bottom: 0;
  width: 100%;
}

.notes-grid.layout-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
}

.note-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.note-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.06);
  border-color: var(--border);
}

.note-card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-preview {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.note-card-date {
  color: var(--text-tertiary);
  margin-right: auto;
}

.tag {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

/* ─── WORKSPACE SCREEN ─── */
.workspace-screen {
  position: absolute;
  inset: 0;
  background: #ffffff; /* White workspace */
  z-index: 100;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  transform: translateY(0);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

[data-theme="dark"] .workspace-screen {
  background: var(--bg-secondary);
}

.workspace-screen[style*="display: none;"] {
  display: block !important;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.99);
}

.btn-logout {
  color: var(--text-secondary);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  color: var(--red) !important;
}

.workspace-sticky-header {
  position: sticky;
  top: 0;
  z-index: 110;
  background: var(--bg-primary);
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.3s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .workspace-sticky-header {
  background: var(--bg-secondary);
}

.workspace-toolbar {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.workspace-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

#toolbar-view-actions, #toolbar-edit-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#toolbar-edit-actions {
  gap: 8px;
}

.btn-edit-action {
  border-radius: 16px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.floating-toolbar {
  display: none;
}

.btn-toolbar-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

.btn-toolbar-icon.danger:hover {
  background: #FEF2F2;
  color: var(--red);
}

[data-theme="dark"] .btn-toolbar-icon.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn-toolbar-icon.text-green {
  color: var(--green);
}
.btn-toolbar-icon.text-green:hover {
  background: #F0FDF4;
}
[data-theme="dark"] .btn-toolbar-icon.text-green:hover {
  background: rgba(34, 197, 94, 0.15);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.save-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 0 6px;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background 0.3s;
}

.save-status-indicator.saving .status-dot { background: var(--orange); animation: pulse 1.5s infinite; }
.save-status-indicator.saved .status-dot { background: var(--green); }
.save-status-indicator.error .status-dot { background: var(--red); }

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.workspace-content {
  max-width: 1100px;
  width: 100%;
  margin: 24px auto 120px;
  padding: 0 24px;
  box-sizing: border-box;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.workspace-sticky-header #edit-toolbar-container {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 10px;
  width: 100%;
}

.note-title-input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 22px;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-title-input::placeholder {
  color: var(--text-tertiary);
  opacity: 0.6;
}

.editor-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.editor-tags::-webkit-scrollbar {
  display: none;
}

#tags-container {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.tags-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.tag-input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 4px 0;
  width: 80px;
  flex-shrink: 0;
}

.tag-input::placeholder {
  color: var(--text-tertiary);
}

.editor-tag {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.remove-tag {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  line-height: 1;
  transition: opacity 0.2s;
}
.remove-tag:hover { opacity: 1; color: var(--red); }

/* Quill Editor Overrides */
.ql-container.ql-snow {
  border: none !important;
  font-family: inherit !important;
  font-size: 18px !important;
  color: var(--text-primary) !important;
}

.ql-editor {
  padding: 8px 0 !important;
  line-height: 1.75 !important;
  min-height: 320px;
  font-size: 18px !important;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ql-editor p { margin-bottom: 1em; }
.ql-editor h1 { font-size: 2.2em; font-weight: 700; margin-top: 1.4em; margin-bottom: 0.5em; letter-spacing: -0.01em; }
.ql-editor h2 { font-size: 1.75em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.4em; }
.ql-editor h3 { font-size: 1.35em; font-weight: 600; margin-top: 1em; margin-bottom: 0.3em; }

.ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 12px 0;
}

.ql-editor pre {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 14px;
  margin: 16px 0;
  max-width: 100%;
}

.ql-editor table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 16px 0;
}

.ql-editor blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 16px 0;
  color: var(--text-secondary);
}

.ql-toolbar.ql-snow {
  border: none !important;
  background: var(--bg-tertiary) !important;
  border-radius: 12px;
  padding: 6px 10px !important;
  margin-bottom: 0;
  opacity: 1;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 2px;
  align-items: center;
  justify-content: flex-start;
  box-shadow: var(--shadow-xs);
}

.ql-toolbar.ql-snow::-webkit-scrollbar {
  display: none;
}

.ql-snow .ql-formats {
  margin-right: 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Custom HR dropdown */
.ql-snow .ql-picker.ql-customHr {
  width: 50px;
}
.ql-snow .ql-picker.ql-customHr .ql-picker-label::before {
  content: '───';
  font-weight: bold;
}
.ql-snow .ql-picker.ql-customHr .ql-picker-item[data-value="single"]::before {
  content: '──────────';
}
.ql-snow .ql-picker.ql-customHr .ql-picker-item[data-value="double"]::before {
  content: '══════════';
}
.ql-snow .ql-picker.ql-customHr .ql-picker-item[data-value="star"]::before {
  content: '*******';
}

.view-container {
  font-size: 18px;
  line-height: 1.75;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.view-container h1 { font-size: 2.2em; font-weight: 700; margin-top: 1.4em; margin-bottom: 0.5em; letter-spacing: -0.01em; }
.view-container h2 { font-size: 1.75em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.4em; }
.view-container h3 { font-size: 1.35em; font-weight: 600; margin-top: 1em; margin-bottom: 0.3em; }

.view-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 12px 0;
}

.view-container pre {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 14px;
  margin: 16px 0;
  max-width: 100%;
}

.view-container table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 16px 0;
}

.view-container blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 16px 0;
  color: var(--text-secondary);
}

.view-empty {
  color: var(--text-tertiary);
  font-size: 16px;
  padding: 40px 0;
  text-align: center;
}

.editor-footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  color: var(--text-tertiary);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ═══════════════════════════════════════════════
   Mobile Responsive Rules
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .dashboard-inner {
    padding: 20px 16px 40px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 20px;
  }

  .dashboard-header .header-left {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .dashboard-title {
    font-size: 28px;
  }

  .header-right {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    align-items: center;
  }

  .search-form {
    width: 100%;
    min-width: 0;
  }

  .search-form input {
    width: 100%;
    height: 38px;
    font-size: 14px;
    padding-left: 34px;
    padding-right: 28px;
  }

  .search-icon {
    left: 11px;
    top: 11px;
  }

  .btn-new {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: 19px;
  }

  .header-right .btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
  }

  .filter-toolbar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    padding: 8px 10px;
    margin-bottom: 20px;
  }

  .filter-tabs-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .filter-tab {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .view-controls {
    justify-content: space-between;
    width: 100%;
  }

  .notes-grid.layout-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .notes-grid.layout-list {
    width: 100%;
    max-width: 100%;
    gap: 12px;
  }

  .note-card {
    padding: 16px 18px;
    border-radius: 16px;
  }

  .note-card-title {
    font-size: 16px;
  }

  .note-card-preview {
    font-size: 13px;
    -webkit-line-clamp: 3;
    margin-bottom: 12px;
  }

  /* Workspace Detail & Edit on Mobile */
  .workspace-sticky-header {
    padding: 10px 14px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .workspace-nav-row {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "left right"
      "header header";
    gap: 8px 0;
    align-items: center;
    width: 100%;
  }

  .toolbar-left {
    grid-area: left;
  }

  .toolbar-right {
    grid-area: right;
    justify-self: end;
  }

  .editor-header {
    grid-area: header;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    padding-top: 4px;
    min-width: 0;
  }

  .note-title-input {
    font-size: 20px !important;
    font-weight: 700;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.3;
    padding: 2px 0;
  }

  .editor-tags {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .tag-input {
    width: 70px;
    font-size: 12px;
  }

  .editor-tag {
    padding: 2px 8px;
    font-size: 11px;
  }

  .btn-toolbar-icon {
    width: 36px;
    height: 36px;
  }

  #toolbar-view-actions {
    gap: 2px;
  }

  #toolbar-edit-actions {
    gap: 6px;
  }

  .btn-edit-action {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 14px;
  }

  .save-status-indicator {
    font-size: 11px;
    padding: 0 4px;
  }

  .workspace-sticky-header #edit-toolbar-container {
    padding-top: 8px;
    width: 100%;
  }

  .ql-toolbar.ql-snow {
    padding: 4px 6px !important;
    border-radius: 10px;
    width: 100%;
    box-sizing: border-box;
  }

  .ql-snow .ql-formats {
    margin-right: 6px;
  }

  .ql-toolbar.ql-snow button,
  .ql-toolbar.ql-snow .ql-picker {
    width: 30px;
    height: 30px;
  }

  .workspace-content {
    padding: 0 16px;
    margin: 16px auto 80px;
  }

  .view-container {
    font-size: 16px;
    line-height: 1.65;
  }

  .view-container h1 { font-size: 1.65em; }
  .view-container h2 { font-size: 1.4em; }
  .view-container h3 { font-size: 1.2em; }

  .ql-container.ql-snow {
    font-size: 16px !important;
  }

  .ql-editor {
    padding: 6px 0 120px !important;
    font-size: 16px !important;
    min-height: 250px;
  }

  .ql-editor h1 { font-size: 1.65em; }
  .ql-editor h2 { font-size: 1.4em; }
  .ql-editor h3 { font-size: 1.2em; }

  .editor-footer {
    margin-top: 24px;
    padding-top: 16px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .dashboard-inner {
    padding: 16px 12px 36px;
  }

  .dashboard-title {
    font-size: 24px;
  }

  .header-right {
    grid-template-columns: 1fr auto auto auto;
    gap: 6px;
  }

  .btn-new span {
    display: none;
  }

  .btn-new {
    width: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  .workspace-sticky-header {
    padding: 8px 12px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .workspace-content {
    padding: 0 12px;
    margin: 14px auto 70px;
  }

  .note-title-input {
    font-size: 18px !important;
  }
}

