/* =========================
   Base & Reset
   ========================= */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
    sans-serif;
  background: #ddd8b8;
  padding: 1rem;
}

body:has(.login-container) {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

h1 {
  color: #1e152a;
  font-size: 1.5rem;
}

/* =========================
   Header & Navigation
   ========================= */

.header {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(30, 21, 42, 0.15);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.username {
  color: #2a2b2a;
  font-size: 0.9rem;
}

.logout-btn {
  padding: 0.5rem 1rem;
  background: #f78154;
  color: white;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.logout-btn:hover {
  background: #e56840;
}

/* =========================
   Layout & Containers
   ========================= */

.content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(30, 21, 42, 0.15);
}

.login-container {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(30, 21, 42, 0.15);
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.note-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* =========================
   Forms & Inputs
   ========================= */

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: #2a2b2a;
  font-size: 0.9rem;
}

input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #c9c5ad;
  border-radius: 4px;
  font-size: 1rem;
}

input:focus {
  outline: none;
  border-color: #087e8b;
}

button {
  width: 100%;
  padding: 0.75rem;
  background: #087e8b;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

button:hover {
  background: #065f69;
}

.search-and-create {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
}

.search-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #c9c5ad;
  border-radius: 4px;
  font-size: 1rem;
}

.search-input:focus {
  outline: none;
  border-color: #087e8b;
}

.search-button {
  padding: 0.75rem 1.5rem;
  background: #087e8b;
  color: white;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
  width: auto;
  margin-top: 0;
}

.search-button:hover {
  background: #065f69;
}

.clear-button {
  padding: 0.75rem 1rem;
  background: #f78154;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.clear-button:hover {
  background: #e56840;
}

.edit-form {
  margin-top: 1rem;
}

.note-editor {
  width: 100%;
  min-height: 400px;
  padding: 1rem;
  border: 1px solid #c9c5ad;
  border-radius: 4px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  resize: vertical;
  line-height: 1.5;
}

.note-editor:focus {
  outline: none;
  border-color: #087e8b;
}

.form-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.form-actions button {
  width: auto;
}

/* =========================
   Buttons & Links
   ========================= */

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-block;
}

.btn-primary {
  background: #087e8b;
  color: white;
}

.btn-primary:hover {
  background: #065f69;
}

.btn-secondary {
  background: #c9c5ad;
  color: #2a2b2a;
}

.btn-secondary:hover {
  background: #b5b19a;
}

.new-note-btn.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  margin-top: 0;
  border: 1px solid transparent;
  white-space: nowrap;
}

.sync-form {
  display: inline;
}

.sync-btn.btn {
  padding: 0.75rem 1rem;
  font-size: 1.2rem;
  margin-top: 0;
  border: 1px solid transparent;
  width: auto;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #087e8b;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* =========================
   Note Components
   ========================= */

.section-title {
  color: #1e152a;
  margin-bottom: 1rem;
}

.note-link {
  display: block;
  text-decoration: none;
  color: inherit;
  margin-bottom: 1rem;
}

.note-card {
  padding: 1rem;
  background: #f8f8f8;
  border-radius: 4px;
  border-left: 4px solid #087e8b;
  transition: transform 0.2s, box-shadow 0.2s;
}

.note-link:hover .note-card {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.note-title {
  font-size: 1.1rem;
  color: #2a2b2a;
  font-weight: 500;
}

.note-subtitle {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.5rem;
}

.tag-list {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.5rem;
}

.note-meta {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e0e0e0;
}

.tag-badge {
  display: inline-block;
  background: #087e8b;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  margin-right: 0.3rem;
  margin-bottom: 0.3rem;
}

/* =========================
   Markdown Content
   ========================= */

.markdown-content {
  color: #2a2b2a;
  line-height: 1.6;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  color: #1e152a;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.markdown-content h1 {
  font-size: 2rem;
}

.markdown-content h2 {
  font-size: 1.5rem;
}

.markdown-content h3 {
  font-size: 1.25rem;
}

.markdown-content h4 {
  font-size: 1.1rem;
}

.markdown-content p {
  margin-bottom: 1rem;
}

.markdown-content ul,
.markdown-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.markdown-content li {
  margin-bottom: 0.5rem;
}

.markdown-content a {
  color: #087e8b;
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

.markdown-content code {
  background: #f8f8f8;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.markdown-content pre {
  background: #f8f8f8;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.markdown-content pre code {
  background: none;
  padding: 0;
}

.markdown-content blockquote {
  border-left: 4px solid #087e8b;
  padding-left: 1rem;
  margin: 1rem 0;
  color: #666;
}

.markdown-content strong {
  font-weight: 600;
}

.markdown-content em {
  font-style: italic;
}

/* =========================
   Search & Highlighting
   ========================= */

mark {
  background: #fff3cd;
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
  font-weight: 500;
}

/* =========================
   Messages & Alerts
   ========================= */

.error {
  background: #fce8e2;
  color: #c44e2f;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.error-message {
  background: #fce8e2;
  color: #c44e2f;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* =========================
   Responsive Design
   ========================= */

@media (max-width: 600px) {
  .search-and-create {
    flex-direction: column;
  }

  .search-form {
    flex-wrap: wrap;
  }

  .search-input {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .search-button,
  .clear-button {
    flex: 1;
  }

  .new-note-btn {
    flex: 1;
  }

  .sync-btn.btn {
    flex: 0;
  }

  .note-header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}
