@import url('https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap');

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

:root {
  --brand-color: #fd7041;
  --brand-hover: #d25635;
  --base-color: #fff3f8;
  --surface-color: #eec197;
  --text-color: #36302a;
  --secondary-text-color: #7a5c43;
  --base-transparent-90: rgba(255, 243, 248, 0.9);
  --base-transparent-100: rgba(255, 243, 248, 1);
  --shadow-color: rgba(54, 48, 42, 0.1);
  --backdrop-color: rgba(54, 48, 42, 0.2);
}

.dark-theme {
  --brand-color: #ff845e;
  --brand-hover: #fd7041;
  --base-color: #1f1a17;
  --surface-color: #2d2520;
  --text-color: #fff3f8;
  --secondary-text-color: #eec197;
  --base-transparent-90: rgba(31, 26, 23, 0.9);
  --base-transparent-100: rgba(31, 26, 23, 1);
  --shadow-color: rgba(0, 0, 0, 0.5);
  --backdrop-color: rgba(31, 26, 23, 0.7);
}

body {
  font-family: 'Geist', sans-serif;
  margin: 2rem;
  background: var(--base-color);
  color: var(--text-color);
}

h1 {
  margin-bottom: 0;
}

button, input, textarea {
  font: inherit;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  gap: 1rem;
}

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

.add-note-btn, .cancel-btn, .save-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.add-note-btn, .save-btn {
  background: var(--brand-color);
  color: white;
}

.add-note-btn:hover, .save-btn:hover {
  background: var(--brand-hover);
}

.theme-toggle-btn {
  height: 42px;
  width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-color);
  color: var(--text-color);
  border: 1px solid var(--surface-color);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 0;
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.theme-toggle-btn:hover {
  background: var(--brand-color);
  color: white;
}

.search-bar {
  flex: 1 0 100%; 
  max-width: 400px;
  margin: 0 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--surface-color);
  border-radius: 0.5rem;
  background: var(--base-color);
  color: var(--text-color);
  transition: border-color 0.2s ease;
}

.search-bar:focus {
  outline: none;
  border-color: var(--brand-color);
}

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

.note-card {
  background: var(--surface-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  border: 1px solid var(--surface-color);
  transition: all 0.2s ease;
  position: relative;
}

.note-card:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px var(--shadow-color);
}

.note-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-color);
  word-wrap: break-word;
}

.note-content {
  color: var(--secondary-text-color);
  line-height: 1.6;
  margin-bottom: 1rem;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.note-actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.note-card:hover .note-actions {
  opacity: 1;
  visibility: visible;
}

.edit-btn, .delete-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  background: var(--base-transparent-90);
  color: var(--text-color);
  border: 1px solid var(--surface-color);
}

.edit-btn:hover {
  background: var(--base-transparent-100);
  transform: scale(1.05);
}

.delete-btn:hover {
  background: #ff5252;
  transform: scale(1.05);
  color: white;
}

dialog {
  margin: auto;
  inset: 0;
  border: none;
  border-radius: 1rem;
  padding: 0;
  background: var(--surface-color);
  color: var(--text-color);
  max-width: 500px;
  width: 90vw;
}

dialog::backdrop {
  background: var(--backdrop-color);
  backdrop-filter: blur(4px);
}

.dialog-content {
  padding: 2rem;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.dialog-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--secondary-text-color);
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: background 0.2s ease;
}

.close-btn:hover {
  background: var(--surface-color);
}

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

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-color);
}

.form-input, .form-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--surface-color);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s ease;
  background: var(--base-color);
  color: var(--text-color);
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-color);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.dialog-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.cancel-btn {
  background: var(--base-color);
  color: var(--text-color);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--secondary-text-color);
}

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

.empty-state p {
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* Fix mobile layout */
@media (max-width: 600px) {
  body {
    margin: 1rem; 
  }

  header {
    flex-wrap: wrap; 
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
  }

  header h1 {
    order: 1;
    font-size: 1.5rem;
  }

  .header-actions {
    order: 2;
    display: flex;
    align-items: center;
  }

  .add-note-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .theme-toggle-btn {
    padding: 0.6rem 0.8rem;
  }

  .search-bar {
    order: 3; 
    margin: 0.5rem 0 0 0;
    max-width: 100%;
    width: 100%;
  }
}

/* Ensure dark text on cards with light pastel backgrounds */
.note-card[style*="background-color: #"],
.note-card[style*="background-color:#"] {
  color: #36302a;
}

.note-card[style*="background-color: #"] .note-title,
.note-card[style*="background-color:#"] .note-title {
  color: #36302a;
}

.note-card[style*="background-color: #"] .note-content,
.note-card[style*="background-color:#"] .note-content {
  color: #524336;
}