/* TillaNote 2025 Design System */

/* Light Mode (Default) */
:root {
  --night: #0a100dff;
  --ash-gray: #b9baa3ff;
  --timberwolf: #d6d5c9ff;
  --auburn: #a22c29ff;
  --burnt-umber: #902923ff;

  /* Theme Colors */
  --bg-primary: #d6d5c9ff;
  --bg-secondary: #b9baa3ff;
  --bg-tertiary: #ffffff;
  --bg-accent: #902923ff;

  --text-primary: #0a100dff;
  --text-secondary: #666666;
  --text-muted: #888888;

  --border-color: rgba(10, 16, 13, 0.1);
  --border-hover: rgba(10, 16, 13, 0.2);

  --shadow-sm: 0 1px 2px 0 rgba(10, 16, 13, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(10, 16, 13, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(10, 16, 13, 0.1);
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-primary: #0a100dff;
  --bg-secondary: #1a1a1aff;
  --bg-tertiary: #2a2a2aff;
  --bg-accent: #a22c29ff;

  --text-primary: #d6d5c9ff;
  --text-secondary: #b9baa3ff;
  --text-muted: #888888;

  --border-color: rgba(214, 213, 201, 0.1);
  --border-hover: rgba(214, 213, 201, 0.2);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Modern Base Styles */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: all 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Tailwind-like utility classes */
.text-primary { color: var(--text-primary); }
.text-primary-900 { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--bg-accent); }

.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }
.bg-accent { background-color: var(--bg-accent); }

.border-border { border-color: var(--border-color); }
.shadow-soft {
  box-shadow: var(--shadow-md);
}
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Layout utilities */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.items-center { align-items: center; }
.space-x-2 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.5rem; }
.space-x-4 > :not([hidden]) ~ :not([hidden]) { margin-left: 1rem; }
.overflow-x-auto { overflow-x: auto; }
.ml-auto { margin-left: auto; }
.ml-2 { margin-left: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mx-4 { margin-left: 1rem; margin-right: 1rem; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.indent { text-indent: 1.5rem; }
.indent-2 { text-indent: 2rem; }
.font-bold { font-weight: bold; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.h-64 { height: 16rem; }
.flex-1 { flex: 1; }
.m-0 { margin: 0; }
.border-0 { border: none; }

/* Menu bar styles */
.menu-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.menu-container {
  max-width: 1200px;
  margin: 0 auto;
}

.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

/* Enhanced navigation styles (from BACKUP) */
.dropdown-item {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: all 0.2s ease;
  border-radius: 0.375rem;
}

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

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 12rem;
  padding: 0.5rem 0;
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-align: left;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  border-radius: 0.375rem;
}

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

/* Toolbar styles */
.toolbar {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.toolbar select {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar select:focus {
  outline: none;
  border-color: var(--border-hover);
  box-shadow: 0 0 0 2px rgba(10, 16, 13, 0.1);
}

/* Logo styles */
.logo {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Editor container styles */
.editor-container {
  flex: 1;
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Modal header styles */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Material symbols styling */
.material-symbols-outlined {
  font-size: 5.5rem;
}


/* Footer styles */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-primary);
}

/* Animation utilities */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--bg-accent);
  color: var(--text-primary);
  border-color: var(--bg-accent);
}

.btn-primary:hover {
  background-color: var(--bg-accent);
  filter: brightness(0.9);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-secondary);
  opacity: 0.9;
}

/* Icon button styles */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.btn-icon:hover {
  background-color: var(--bg-secondary);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-icon.active {
  background-color: var(--bg-accent);
  color: var(--text-primary);
  border-color: var(--bg-accent);
}

/* Navigation dropdown styles */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 12rem;
  padding: 0.5rem 0;
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-align: left;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  clear: both;
  font-weight: normal;
  color: var(--text-primary);
  text-align: inherit;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Editor styles */
.editor {
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  transition: all 0.2s ease;
  min-height: 400px;
  padding: 1rem;
  max-width: 100%;
  overflow-wrap: break-word;
  outline: none;
}

/* Editor Readability Styles - Only applied to editor content */
/* Reset and Base Styles for Readability in Editor */
/* Based on 2025 UX/UI best practices: Responsive, accessible, with fluid typography. */

#editor {
  /* Readable typography for editor content */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; /* Modern sans-serif stack */
  font-size: 1rem; /* 16px for accessibility */
  line-height: 1.6; /* Optimal for readability: 1.5-1.6 */
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

/* Editor content elements - scoped to editor only */
#editor p {
  margin: 0 0 1rem 0; /* Bottom margin for separation */
  text-align: left; /* Left-aligned for readability */
  line-height: 1.6;
}

#editor h1, #editor h2, #editor h3, #editor h4, #editor h5, #editor h6 {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: bold; /* Bold for hierarchy */
  line-height: 1.3; /* Tighter for impact */
  margin-top: 1.5rem; /* Top spacing for sections */
  margin-bottom: 0.75rem; /* Bottom to connect content */
  color: var(--text-primary);
}

#editor h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem); /* Fluid: 28-40px */
}

#editor h2 {
  font-size: clamp(1.375rem, 4vw, 2rem); /* 22-32px */
}

#editor h3 {
  font-size: clamp(1.125rem, 3vw, 1.5rem); /* 18-24px */
}

#editor h4 {
  font-size: clamp(1rem, 2.5vw, 1.25rem); /* 16-20px */
}

#editor h5 {
  font-size: clamp(0.875rem, 2vw, 1.125rem); /* 14-18px */
}

#editor h6 {
  font-size: clamp(0.875rem, 1.5vw, 1rem); /* 14-16px */
}

/* Lists in editor */
#editor ul, #editor ol {
  margin: 0 0 1rem 0;
  padding-left: 2rem; /* Indent for hierarchy */
  line-height: 1.6;
}

#editor ul {
  list-style-type: disc; /* Bullets */
}

#editor ol {
  list-style-type: decimal; /* Numbers */
}

#editor li {
  margin-bottom: 0.5rem; /* Space between items */
}

/* Support for nested lists created by indent/outdent */
#editor ul ul, #editor ol ol, #editor ul ol, #editor ol ul {
  margin-left: 1.5em; /* Slightly less indent for nested lists */
  margin-bottom: 0.5rem;
}

/* Horizontal Rule in editor */
#editor hr {
  border: none;
  border-top: 1px solid #ddd; /* Subtle line */
  margin: 2rem 0; /* Ample space for section breaks */
}

/* Blockquote in editor */
#editor blockquote {
  margin: 1rem 0;
  padding: 0 1.5rem;
  border-left: 4px solid #ccc; /* Visual cue */
  font-style: italic; /* For emphasis */
  color: #555; /* Slightly muted */
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 0 4px 4px 0;
}

/* Links in editor */
#editor a {
  color: #007bff;
  text-decoration: underline; /* Underline for accessibility */
}

#editor a:hover, #editor a:focus {
  color: #0056b3;
  text-decoration: none; /* Remove on hover for modern feel */
}

/* Strong and Emphasis in editor */
#editor strong, #editor b {
  font-weight: bold;
}

#editor em, #editor i {
  font-style: italic;
}

/* Code and Pre in editor */
#editor code {
  font-family: "Courier New", Courier, monospace; /* For code */
  background-color: #f4f4f4;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

#editor pre {
  font-family: "Courier New", Courier, monospace;
  background-color: #f4f4f4;
  padding: 1rem;
  overflow-x: auto; /* Horizontal scroll for long lines */
  margin: 1rem 0;
  border-radius: 5px;
  line-height: 1.4; /* Slightly tighter for code */
  border: 1px solid #e0e0e0;
}

/* Images in editor */
#editor img {
  max-width: 100%; /* Responsive */
  height: auto;
  display: block;
  margin: 1rem auto; /* Center with space */
  border-radius: 4px;
}

/* Tables in editor */
#editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  border: 1px solid #ddd;
}

#editor th, #editor td {
  border: 1px solid #ddd;
  padding: 0.75rem;
  text-align: left;
}

#editor th {
  background-color: #f4f4f4;
  font-weight: bold;
}

/* Responsive adjustments for editor content */
@media (max-width: 768px) {
  #editor {
    padding: 1rem;
    font-size: 1.125rem; /* Slightly larger on mobile for touch */
  }

  #editor h1, #editor h2, #editor h3, #editor h4, #editor h5, #editor h6 {
    margin-top: 1rem; /* Reduce top margins on small screens */
  }

  #editor ul, #editor ol {
    padding-left: 1.5rem; /* Less indent on mobile */
  }

  #editor blockquote {
    padding: 0 1rem;
  }

  #editor pre {
    padding: 0.75rem;
  }
}

.editor:focus {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 2px rgba(10, 16, 13, 0.1);
}

/* Editor placeholder */
.editor-placeholder {
  position: absolute;
  pointer-events: none;
  color: var(--text-primary);
  opacity: 1.0;
  z-index: 1;
  padding: 2rem;
  font-size: 2rem;
}

.editor-container {
    flex: 1;
    position: relative;
    width: 100%;
}

/* Theme toggle button */
.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
}

.theme-toggle:hover {
  background-color: var(--bg-secondary);
  border-color: var(--border-hover);
  transform: scale(1.05);
}

/* Modal styles (for preview, source, fullscreen) */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-tertiary);
  margin: auto;
  padding: 2rem;
  border-radius: 0.5rem;
  width: 80%;
  max-width: 800px;
  max-height: 80%;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

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

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* File input hidden */
#fileInput {
  display: none;
}

/* Responsive utilities */
@media (max-width: 768px) {
  .menu-bar .menu-btn span:not(.material-icons) {
    display: none;
  }

  .toolbar {
    padding: 0.75rem;
  }

  .btn-icon {
    width: 2rem;
    height: 2rem;
  }

  .modal-content {
    width: 95%;
    padding: 1rem;
  }

  /* Remove bottom spacing from header on mobile */
  header.bg-gradient-to-r {
    padding-bottom: 0;
  }

  /* Logo icon responsive sizing */
  header .flex.items-center.space-x-2 .material-symbols-outlined {
    font-size: 3.5rem !important;
  }
}

/* Print styles */
@media print {
  .theme-toggle,
  .menu-bar,
  .toolbar,
  .btn,
  footer,
  .modal {
    display: none !important;
  }

  .editor {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: none;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --border-hover: #000000;
  }

  [data-theme="dark"] {
    --border-color: #ffffff;
    --border-hover: #ffffff;
  }
}