/* =====================================================
   RESET & BASE
===================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   THEME VARIABLES
===================================================== */

/* ---------- LIGHT ---------- */
body.light {
  --bg-main: #f5f5f7;
  --bg-sidebar: #ffffff;
  --bg-editor: #ffffff;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-placeholder: #9e9ea3;
  --border: #9e9ea34e;





  --border-light: #e5e5ea;

  --accent: #ffd60a;
  --danger: #ff3b30;
}

/* ---------- DIM ---------- */
body.dim {
  --bg-main: #111827;
  --bg-sidebar: #1f2937;
  --bg-editor: #111827;

  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-placeholder: #6b7280;

  --border-light: rgba(255, 255, 255, 0.08);

  --accent: #facc15;
  --danger: #fb7185;
}

/* ---------- DARK ---------- */
body.dark {
  --bg-main: #020617;
  --bg-sidebar: #020617;
  --bg-editor: #020617;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-placeholder: #64748b;

  --border-light: rgba(255, 255, 255, 0.06);

  --accent: #fde047;
  --danger: #ff453a;
}

/* =====================================================
   APP LAYOUT
===================================================== */
.app {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: var(--bg-main);
}





/* ---------- HEADER ---------- */
.app-header {
  height: 64px;
  padding: 0 1rem env(safe-area-inset-right) 0
    env(safe-area-inset-left);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
  background: rgba(255, 255, 255, 0.75);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.3px;
}

.app-title span {
  color: var(--gold);
}


.header-icon {
  font-size: 1.25rem;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem;          /* ← THIS is the key */
  margin: 0 0.25rem;        /* subtle breathing room */

  transition: transform var(--transition), opacity var(--transition);
}

.app-header {
  height: 64px;
  padding:
    0
    calc(1rem + env(safe-area-inset-right))
    0
    calc(1rem + env(safe-area-inset-left));

    
}

.header-icon:hover {
  transform: scale(1.0);
  opacity: 0.8;
}




body.dark .app-header,
body.dim .app-header {
  background: rgba(17, 24, 39, 0.85);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  
}

body.dim .app-header {
  background: #131b2c;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}



/* =====================================================
   SIDEBAR
===================================================== */
.sidebar {
  width: 320px;
  min-width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

/* Header */
.sidebar-header {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  
  
  font-family: 'Poppins', system-ui, sans-serif;
}

.sidebar-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.sidebar-actions {
  display: flex;
  gap: 10px;
}



/* Header buttons */
.sidebar-header button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #000;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.sidebar-header button:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

#themeToggle {
  background: transparent;
  font-size: 18px;
  color: var(--text-primary);
}




/* Mobile Back Button */
.editor-back {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-primary);
}

/* Show only on mobile */
@media (max-width: 768px) {
  .editor-back {
    display: inline-flex;
    align-items: center;
  }
}


/* =====================================================
   SEARCH
===================================================== */
.search-box {
  margin: 0 16px 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-main);
  border-radius: 14px;
}

.search-box i {
  font-size: 14px;
  color: var(--text-secondary);
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-primary);
}

.search-box input::placeholder {
  color: var(--text-placeholder);
}

/* =====================================================
   NOTES LIST
===================================================== */
.notes-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.notes-list li {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s ease;
}

.notes-list li:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.dark .notes-list li:hover,
body.dim .notes-list li:hover {
  background: rgba(255, 255, 255, 0.05);
}

.notes-list li.active {
  background: rgba(255, 214, 10, 0.22);
}

.notes-list h3 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-list p {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================================================
   EDITOR
===================================================== */
.editor {
  flex: 1;
  background: var(--bg-editor);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Empty State */
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-state i {
  font-size: 46px;
  opacity: 0.5;
}

/* =====================================================
   EDITOR CONTENT
===================================================== */
.editor-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 28px 32px;
}

.editor-content.hidden {
  display: none;
}

/* Mobile Editor Header (Back + Actions) */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.editor-actions {
  display: flex;
  gap: 14px;
}

.editor-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-secondary);
  transition: transform 0.15s ease, color 0.15s ease;
}

.editor-actions button:hover {
  transform: scale(1.1);
  color: var(--accent);
}

#deleteNoteBtn:hover {
  color: var(--danger);
}

/* =====================================================
   TITLE
===================================================== */
.note-title {
  font-size: 30px;
  font-weight: 600;
  border: none;
  outline: none;
  background: transparent;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.note-title::placeholder {
  color: var(--text-placeholder);
}

/* =====================================================
   CONTENT
===================================================== */
.note-content {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 16px;
  line-height: 1.7;
  background: transparent;
  color: var(--text-primary);
}

.note-content::placeholder {
  color: var(--text-placeholder);
}

/* =====================================================
   SCROLLBARS
===================================================== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
}

body.dark ::-webkit-scrollbar-thumb,
body.dim ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
}

/* =====================================================
   RESPONSIVE (MOBILE)
===================================================== */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 100%;
  }

  .editor {
    display: none;
    width: 100%;
    height: 100%;
  }

  .editor-content {
    padding: 22px;
  }

  .notes-list li {
    padding: 16px;
  }
}

/* Small Phones */
@media (max-width: 480px) {
  .sidebar-header h1 {
    font-size: 18px;
  }

  .note-title {
    font-size: 22px;
  }
}




/* =====================================================
   MODAL (DELETE CONFIRM)
===================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  max-width: 320px;
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-editor);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}
