/* Base Styles */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --success-color: #10b981;
  --success-hover: #059669;
  --warning-color: #f59e0b;
  --warning-hover: #d97706;
  --text-color: #1e293b;
  --text-light: #64748b;
  --bg-color: #f8fafc;
  --bg-secondary: #ffffff;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
    "Helvetica Neue", sans-serif;
  --sidebar-width: 280px;
  --editor-font-size: 16px;
  --editor-line-height: 1.5;
}

.dark-theme {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --secondary-color: #94a3b8;
  --danger-color: #f87171;
  --danger-hover: #ef4444;
  --success-color: #34d399;
  --success-hover: #10b981;
  --warning-color: #fbbf24;
  --warning-hover: #f59e0b;
  --text-color: #e2e8f0;
  --text-light: #94a3b8;
  --bg-color: #0f172a;
  --bg-secondary: #1e293b;
  --border-color: #334155;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  color: var(--text-color);
  background-color: var(--bg-color);
  line-height: 1.5;
  font-size: 16px;
  overflow: hidden;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.3s ease, width 0.3s ease, min-width 0.3s ease;
  z-index: 10;
  position: relative;
}

.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  min-width: 0;
  width: 0;
}

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

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.sidebar-actions {
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
}

.search-container {
  padding: 0 1rem 1rem;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.search-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.875rem;
}

.view-options {
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.view-option {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.view-option:hover {
  background-color: var(--bg-color);
}

.view-option.active {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
}

.view-option i {
  width: 1rem;
  text-align: center;
}

.folders-section,
.tags-section {
  padding: 0 1rem 1rem;
}

.folders-section h3,
.tags-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.folders-list {
  list-style: none;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
}

.folder-item:hover {
  background-color: var(--bg-color);
}

.folder-item.active {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
}

.folder-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.folder-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

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

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tag:hover {
  background-color: rgba(37, 99, 235, 0.2);
}

.tag-remove {
  cursor: pointer;
  font-size: 0.625rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  transition: width 0.3s ease, margin-left 0.3s ease;
  width: calc(100% - var(--sidebar-width));
}

/* Sidebar Toggle Button */
.show-sidebar-btn {
  position: fixed;
  top: 10px;
  left: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-collapsed .show-sidebar-btn {
  opacity: 1;
  visibility: visible;
}

/* Adjust the main content to make room for the sidebar toggle button */
.sidebar-collapsed .main-content {
  margin-left: 0;
  width: 100%;
}

/* Calendar Section */
.calendar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  overflow-y: auto;
}

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

.calendar-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.calendar-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.calendar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.year-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: var(--border-color);
  flex: 1;
}

.calendar-day-header {
  background-color: var(--bg-secondary);
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-light);
}

.calendar-days-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: var(--border-color);
  grid-column: 1 / -1;
}

.calendar-day {
  background-color: var(--bg-secondary);
  min-height: 100px;
  padding: 0.5rem;
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  flex-direction: column;
}

.calendar-day:hover {
  background-color: var(--bg-color);
}

.calendar-day.other-month {
  opacity: 0.5;
}

.calendar-day.today {
  background-color: rgba(37, 99, 235, 0.1);
}

.calendar-day.selected {
  background-color: rgba(37, 99, 235, 0.2);
}

.calendar-day.has-notes::after {
  content: "";
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--primary-color);
  border-radius: 50%;
}

.calendar-day-number {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.calendar-day-notes {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  flex: 1;
}

.calendar-note {
  background-color: var(--primary-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendar-note:hover {
  background-color: var(--primary-hover);
}

.calendar-note-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

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

.calendar-note-action {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.125rem;
}

.calendar-day-add-note {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background-color: var(--bg-color);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}

.calendar-day:hover .calendar-day-add-note {
  opacity: 1;
}

.calendar-day-add-note:hover {
  background-color: var(--primary-color);
  color: white;
}

.notes-list-section {
  width: 300px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
}

.notes-list-header {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.notes-list-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.notes-list-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.notes-list-actions select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.notes-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.notes-container.list-view {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notes-container.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.note-card {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.note-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.note-card-header {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.note-card-title {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-card-favorite {
  color: #f59e0b;
  font-size: 0.75rem;
}

.note-card-content {
  padding: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-light);
  height: 100px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.note-card-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.625rem;
  color: var(--text-light);
}

.note-card-tags {
  display: flex;
  gap: 0.25rem;
}

.note-card-tag {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.625rem;
}

.note-editor-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
}

.note-editor-header {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.note-title-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

#note-title {
  font-size: 1.25rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-color);
  width: 100%;
  padding: 0;
}

#note-title:focus {
  outline: none;
}

#save-status {
  font-size: 0.75rem;
  color: var(--text-light);
}

.note-actions {
  display: flex;
  gap: 0.5rem;
}

/* Quill Editor Styles */
.editor-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#editor {
  flex: 1;
  overflow-y: auto;
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  font-family: var(--font-family);
}

.ql-toolbar.ql-snow {
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-color);
}

.ql-container.ql-snow {
  border: none;
  font-family: var(--font-family);
}

.ql-editor {
  min-height: 100%;
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
}

.ql-editor h1 {
  font-size: 1.5em;
  margin-bottom: 0.5em;
}

.ql-editor h2 {
  font-size: 1.3em;
  margin-bottom: 0.5em;
}

.ql-editor h3 {
  font-size: 1.1em;
  margin-bottom: 0.5em;
}

.ql-editor p {
  margin-bottom: 1em;
}

.ql-editor ul,
.ql-editor ol {
  margin-bottom: 1em;
  padding-left: 2em;
}

.ql-editor blockquote {
  border-left: 3px solid var(--primary-color);
  padding-left: 1em;
  margin-left: 0;
  margin-bottom: 1em;
  color: var(--text-light);
}

.ql-editor pre {
  background-color: var(--bg-color);
  padding: 1em;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 1em;
  font-family: monospace;
}

.ql-editor img {
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  display: block;
}

.ql-editor a {
  color: var(--primary-color);
  text-decoration: underline;
}

.note-footer {
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-color);
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.note-info {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Quick Note Editor */
#quick-note-editor {
  height: 200px;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background-color: var(--bg-secondary);
  color: var(--text-color);
  border-left: 4px solid var(--primary-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 400px;
  animation: toast-in 0.3s ease-in-out forwards;
}

.toast.success {
  border-left-color: var(--success-color);
}

.toast.error {
  border-left-color: var(--danger-color);
}

.toast.warning {
  border-left-color: var(--warning-color);
}

.toast.info {
  border-left-color: var(--primary-color);
}

.toast-icon {
  font-size: 1.25rem;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-light);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1rem;
}

@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* Buttons */
.primary-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.primary-button:hover {
  background-color: var(--primary-hover);
}

.secondary-button {
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.secondary-button:hover {
  background-color: var(--bg-color);
}

.icon-button {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
}

.icon-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.icon-button.active {
  color: var(--primary-color);
}

.danger-button {
  background-color: var(--danger-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.danger-button:hover {
  background-color: var(--danger-hover);
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.settings-modal-content {
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal input {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.settings-section {
  margin-bottom: 1.5rem;
}

.settings-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0;
}

.setting-item label {
  font-size: 0.875rem;
}

.setting-item select,
.setting-item input {
  width: auto;
  margin-bottom: 0;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.history-item:hover {
  background-color: var(--bg-color);
}

.history-item-date {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.history-item-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.history-item-preview {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  color: var(--text-light);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 300px;
}

/* Responsive */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }

  .calendar-section {
    height: 50vh;
  }

  .notes-list-section {
    width: 100%;
    height: 50vh;
  }

  .note-editor-section {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    height: 100%;
  }

  .notes-list-section {
    width: 100%;
  }

  .main-content {
    flex-direction: column;
  }

  .note-editor-section {
    display: none;
  }

  .note-editor-active .notes-list-section {
    display: none;
  }

  .note-editor-active .note-editor-section {
    display: flex;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, 1fr);
  }

  .calendar-day {
    min-height: 60px;
  }

  .calendar-day-notes {
    max-height: 40px;
  }
}

/* Error Modal */
.error-modal-content {
  max-width: 450px;
  text-align: center;
}

.error-icon {
  font-size: 3rem;
  color: var(--danger-color);
  margin-bottom: 1rem;
}

.error-message {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--danger-color);
}

.recovery-message {
  margin-bottom: 1.5rem;
  color: var(--text-light);
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Save Status Animation */
@keyframes saving-pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

.saving {
  animation: saving-pulse 1.5s infinite;
}

.save-failed {
  color: var(--danger-color);
}

.save-success {
  color: var(--success-color);
}
