/* inter-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/inter-v20-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-500 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/inter-v20-latin-500.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-600 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  src: url('../fonts/inter-v20-latin-600.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-700 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/inter-v20-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-800 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  src: url('../fonts/inter-v20-latin-800.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

:root {
    --bg: #0F1117;
    --text: #E0E0E0;
    --accent: #00D4AA;
    --gray: #292929;
    --grayButts: #292929; 
    --lightgray: #1E2127;
    --borderCol: #4b4b4b;
    --sideAddFolderBtn: #111111; 
    --textWhiteBlack: #FAFAFA; 
    --textBlackWhite: #111111;
    --header-botBrd:  #292929; 
}

[data-theme="light"] {
  --bg: #FAFAFA;
  --sidebar: #FFFFFF;
  --text: #111111;
  --textWhiteBlack: #FAFAFA;
  --text-muted: #666666;
  --accent: #0099AA;         /* more vibrant teal for light mode */
  --accent-hover: #00B3CC;
  --border: #E5E5E5;
  --gray: #d8d8d8;
  --grayButts: #2d2d2d; 
  --lightgray: #c0c0c0;
  --sideAddFolderBtn: #3d3a3a;
  --textWhiteblack: #FAFAFA;
  --textBlackWhite: #FAFAFA; 
  --header-botBrd:  #b0b0b0; 
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #fafafa;
        --text: #111111;
        --gray: #eeeeee;
        --lightgray: #cccccc;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter';
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr;
    overscroll-behavior: none;
}

header {
    padding: 1rem;
    border-bottom: 1px solid var(--header-botBrd);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.btn {
    background: var(--grayButts);
    color: var(--textWhiteBlack);
    border: none;
    padding: 0.6rem 1rem 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    opacity: 1; 
    transition: opacity 0.22s ease-in-out; 
}

.btn:hover {
    opacity: 0.7;
}

.btn.primary {
    background: var(--accent);
    color: var(--textBlackWhite);
    font-weight: 600;
    opacity: 1; 
    transition: opacity 0.22s ease-in-out; 
}

.btn.primary:hover {
    opacity: 0.8; 
}

.btn-primary2 {
  background: var(--sideAddFolderBtn);
  color: #eeeeee;
  font-weight: 600;
  border: none;
  padding: 0.7rem 1rem 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.75rem;
  opacity: 1; 
  transition: opacity 0.22s ease-in-out;
}

.btn-primary2:hover {
  opacity: 0.7;
}

#folder-btn:has(#folder-text::after) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#folder-btn {
    display: flex;
    align-items: center;
    gap: 6px;           
    padding: 0.4rem 0.8rem;
    max-width: 100%;        
    overflow: hidden;
}

.folder-icon {
    flex-shrink: 0;      
}

.folder-name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}


#folder-btn:hover .folder-name-text {
    overflow: visible;
    white-space: normal;
    word-break: break-all;
}

main {
    display: grid;
    grid-template-columns: 260px 1fr;
    overflow: hidden;
    height: 100%;
}

/* Sidebar – list of notes */
#note-list {
    background: var(--gray);
    border-right: 1px solid var(--lightgray);
    overflow-y: auto;
    padding: 0.5rem;
}

.note-item {
    padding: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600; 
}

.note-item:hover,
.note-item.active {
    background: var(--accent);
    color: var(--textBlackWhite)
}

/* Editor area */
#editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#editor {
    flex: 1;
    padding: 1.5rem 0.95rem;
    font-size: 1.1rem;
    line-height: 1.6;
    background: transparent;
    color: var(--text);
    border: none;
    outline: none;
    resize: none;
    font-family: 'Inter';
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Mobile fallback – stack vertically */
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    #note-list {
        max-height: 30vh;
    }

    header {
        padding: 1rem;
    }

    #editor-split {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }

    #editor-section, #preview-section {
        flex: none;
        height: auto;
        overflow: visible;
    }

    #editor, #preview {
        min-width: 0;
        height: auto;
        min-height: 400px;
        max-height: 50vh;
        padding: 1rem 0.75rem;
        overflow-y: auto;
    }

    #editor {
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    #preview {
        border-left: none;
        border-top: 1px solid var(--lightgray);
    }

    #preview table {
        font-size: 0.9rem;
    }

    #preview pre {
        overflow-x: auto;
        max-width: 100%;
    }

    #preview img {
        max-width: 100%;
        height: auto;
    }

    #preview code {
        word-break: break-word;
    }
}

.empty {
    padding: 2rem;
    text-align: center;
    color: #777;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* Modal overlay */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: grid;
  place-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}
.modal-content {
  background: var(--bg);
  border: 1px solid var(--gray);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(90vw, 420px);
  color: var(--text);
}
.modal-content h2 {
   margin-bottom: 0rem; 
}

.modal-content .info {
  margin: 0.2rem 0 0.9rem;
  opacity: 0.8;
  font-size: 0.95rem;
}
.modal-content input {
  width: 100%;
  padding: 0.8rem;
  background: var(--gray);
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.context-menu {
  position: absolute;
  background: var(--gray);
  border: 1px solid var(--lightgray);
  border-radius: 8px;
  padding: 0.5rem 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 1000;
  min-width: 140px;
  font-size: 0.95rem;
}
.context-menu button {
  width: 100%;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-family: 'Inter';
    font-weight: 700;
    font-size: 1rem;
}

.context-menu button:hover {
  background: var(--accent);
  color: #000;
}
.context-menu button.danger:hover {
  background: #ff4444;
  color: white;
}

#editor::placeholder {
 color: #c0c0c0;  
 opacity: 1;
}

#editor:not(:placeholder-shown)::placeholder {
  opacity: 1;
}

#sidebar {
  background: var(--gray);
  border-right: 1px solid var(--lightgray);
  display: flex;
  flex-direction: column;
  overflow: hidden;

}

.empty-state {
  padding: 0rem 0.75rem;
  color: var(--text);
  flex: 1;
}

.empty-state h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
}

.empty-state p {
  opacity: 0.8;
  font-size: 1rem;
}

#notes-state {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#notes-header {
  padding: 1rem 1rem 0.5rem;
  border-bottom: 1px solid var(--borderCol);
}

#notes-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text); 
}

#notes-count {
  font-size: 0.9rem;
}

#note-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

#welcome-screen {
  display: none; /* will be toggled by JS */
  padding: 1rem 0.95rem 1rem 0.9rem;
}

#welcome-screen.active {
  display: flex;
  flex-direction:column;
}

#welcome-screen h1 {
  margin-bottom: 0.5rem;
  color: var(--accent);
  font-size: 1.75rem;
  font-weight: 700;
}

.welcome-text {
  margin-top: 2rem;
  line-height: 1.8;
  font-size: 1.15rem;
  opacity: 0.9;
}

.welcome-text code {
  background: var(--gray);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.95em;
}

#editor {
  flex: 1;
  padding: 1.5rem 0.95rem;
  font-size: 1.1rem;
  line-height: 1.6;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  resize: none;
  font-family: 'Inter';
  display: none; /* hidden by default */
}

#editor.active {
  display: block;
}

@media screen and (min-width: 768px) {
  #folder-btn2 {
    width: 100%; 
  }
}

@media screen and (max-width: 768px) {
  main {
    display: flex; 
    flex-direction: column;
  }

  #sidebar {
    min-height: 215px;
    border-bottom: 1px solid var(--header-botBrd); 
  }
}

#editor-header {
  padding: 1.2rem 0.95rem 0.5rem;
  border-bottom: 1px solid var(--gray);
  background: var(--bg);
}

#editor-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  opacity: 0.95;
  color: var(--accent);
}

#current-note-path {
  font-family: 'Inter';
  word-break: break-all;
}

@media screen and (max-width: 488.9px) {
  .folderAddNoteContainer {
    margin-top: 0.25rem;
  }

  header {
    padding: 1.2rem 1rem;
  }
}

.deleteRenameP {
  opacity: 1;
  font-size: 0.9rem;
  text-wrap: balance;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  background: var(--gray);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.3s;
  padding: 0;
  margin-left: 0.75rem;
}
.theme-toggle:hover { background: var(--lightgray); }

.theme-toggle svg {
  width: 20px;
  height: 20px;
  display: none;            
}
.theme-toggle .moon { display: block; }   


[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

#new-btn {
  margin-left: 0.75rem;
}

@media screen and (max-width: 430px) {
  .folderAddNoteContainer {
    width: 100%; 
    
  }
}

@media screen and (max-width: 416px) {
  .modal-actions {
    flex-direction: column; 
    align-items:flex-start;
  }

  .modalActionsCancelCreate {
    margin-top: 0.75rem;
  }

  #cancel-new-note, #create-new-note {
    min-width: 100px;
  }
}

* High-quality Markdown preview styling */
#preview {
    white-space: pre-wrap;
    word-wrap: break-word;
}
#preview > :first-child {
    margin-top: 0;
}
#preview h1 {
    font-size: 1.8em;
    margin: 1.4em 0 0.8em;
    color: var(--accent);
    font-weight: 700;
}
#preview h2 {
    font-size: 1.5em;
    margin: 1.2em 0 0.6em;
    font-weight: 600;
}
#preview h3 {
    font-size: 1.3em;
    margin: 1em 0 0.5em;
    font-weight: 600;
}
#preview p {
    margin: 1em 0;
}
#preview ul, #preview ol {
    padding-left: 1.8em;
    margin: 1em 0;
}
#preview li {
    margin: 0.4em 0;
}
#preview blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1.2em;
    margin: 1.4em 0;
    opacity: 0.9;
    font-style: italic;
}
#preview code {
    background: var(--gray);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.95em;
}
#preview pre {
    background: var(--gray);
    padding: 1rem;
    overflow-x: auto;
    border-radius: 8px;
    margin: 1.2em 0;
}
#preview table {
    border-collapse: collapse;
    margin: 1.2em 0;
    width: 100%;
}
#preview th, #preview td {
    border: 1px solid var(--lightgray);
    padding: 0.6em 0.8em;
    text-align: left;
}
#preview th {
    background: var(--lightgray);
}
#preview a {
    color: var(--accent);
    text-decoration: underline;
}
#preview img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1em 0;
}
#preview hr {
    border: none;
    border-top: 2px solid var(--lightgray);
    margin: 2em 0;
}
#preview task-list-item {
    list-style: none;
}

/* Pane headers */
.pane-header {
    display: block;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    opacity: 0.7;
    border-bottom: 1px solid var(--gray);
    background: transparent;
}

.pane-header.hidden {
    display: none !important;
}

/* Formatting Toolbar */
#formatting-toolbar {
    font-size: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.tool-btn {
    background: var(--gray);
    color: var(--text);
    border: none;
    border-radius: 6px;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: grid;
    place-items: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--accent);
    color: var(--textBlackWhite);
}

.tool-btn:active {
    transform: scale(0.95);
}

.toolbar-separator {
    color: var(--lightgray);
    font-weight: bold;
    user-select: none;
}

.tool-btn.active {
    background: var(--accent);
    color: var(--textBlackWhite);
}

/* Word count display */
#word-count {
    font-family: 'Inter';
    color: var(--text);
}

#editor:empty::before {
    content: 'Start typing...';
    opacity: 0.5;
}

#editor:focus::before {
    content: '';
}

.tool-btn.bold-btn {
    font-weight: bold;
}

.tool-btn.italic-btn {
    font-style: italic;
}

.tool-btn.strike-btn {
    text-decoration: line-through;
}

.tool-btn.heading-btn {
    font-weight: bold;
    font-size: 1.1em;
}

.tool-btn.blockquote-btn {
    font-style: italic;
    opacity: 0.9;
}

.tool-btn.code-btn {
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.tool-btn.codeblock-btn {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

/* Optional: make active state more obvious */
.tool-btn.active {
    background: var(--accent) !important;
    color: var(--textBlackWhite) !important;
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--borderCol);
    background-clip: content-box;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}

*:hover {
    scrollbar-color: var(--borderCol) transparent;
}

/* Light mode scrollbar visibility fix */
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #999999;
    background-clip: content-box;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #666666;
    background-clip: content-box;
}

[data-theme="light"] * {
    scrollbar-color: #999999 transparent;
}

[data-theme="light"] *:hover {
    scrollbar-color: #666666 transparent;
}