:root {
    --background-primary: #ffffff;
    --background-secondary: #f7f7f7;
    --text-primary-color: #1a1a1a;
    --text-secondary-color: #5c5c5c;
    --text-tertiary-color: #8a8a8a;
    --border-color: #e0e0e0;
    --accent-color: #3b82f6;
    --hover-color: #f0f0f0;
    --icon-color: #4a4a4a;
    --favorite-icon-color: #f59e0b;
    --danger-color: #ef4444;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --scrollbar-thumb-color: #d1d1d1;
    --scrollbar-thumb-hover-color: #a8a8a8;
}

body.dark-mode {
    --background-primary: #1e1e1e;
    --background-secondary: #252525;
    --text-primary-color: #e1e1e1;
    --text-secondary-color: #a0a0a0;
    --text-tertiary-color: #7a7a7a;
    --border-color: #3a3a3a;
    --accent-color: #60a5fa;
    --hover-color: #2c2c2c;
    --icon-color: #b0b0b0;
    --favorite-icon-color: #facc15;
    --danger-color: #f87171;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --scrollbar-thumb-color: #424242;
    --scrollbar-thumb-hover-color: #555555;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-primary);
    color: var(--text-primary-color);
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
    -webkit-tap-highlight-color: transparent;
}

/* --- Custom Scrollbar --- */
/* For Webkit browsers (Chrome, Safari) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover-color);
}
/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb-color) transparent;
}


#app-container { display: grid; grid-template-columns: 350px 1fr; height: 100vh; }

/* --- Global --- */
.icon-button { background: none; border: none; cursor: pointer; padding: 0.5rem; color: var(--icon-color); font-size: 1.5rem; border-radius: 50%; transition: background-color 0.2s; }
.icon-button:hover { background-color: var(--hover-color); }

/* --- List View --- */
#list-view { background-color: var(--background-secondary); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; height: 100vh; overflow-y: auto; }
.list-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); }
.list-header h1 { margin: 0; font-size: 1.5rem; }
.header-actions { display: flex; gap: 0.5rem; }
#list-tabs { display: flex; padding: 0.5rem 1.5rem; gap: 1rem; border-bottom: 1px solid var(--border-color); }
.tab-button { background: none; border: none; padding: 0.5rem 0; font-size: 1rem; color: var(--text-secondary-color); cursor: pointer; border-bottom: 2px solid transparent; }
.tab-button.active { color: var(--text-primary-color); font-weight: 500; border-bottom-color: var(--accent-color); }
.search-and-sort-container { display: flex; gap: 1rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); }
#search-input, #sort-select { width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; background-color: var(--background-primary); color: var(--text-primary-color); font-size: 0.9rem; }
#tags-container { padding: 1rem 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-filter { background-color: var(--hover-color); color: var(--text-secondary-color); padding: 0.25rem 0.75rem; border-radius: 1rem; font-size: 0.8rem; cursor: pointer; transition: background-color 0.2s; }
.tag-filter.active { background-color: var(--accent-color); color: white; }
#notes-list { flex-grow: 1; overflow-y: auto; }

/* --- Editor View --- */
#editor-view { display: flex; flex-direction: column; padding: 0 2rem; height: 100vh; }
.editor-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border-color); }
.editor-content { flex-grow: 1; padding: 1.5rem 0; overflow-y: auto; }
#note-title { width: 100%; font-size: 2rem; font-weight: 700; border: none; outline: none; background: none; color: var(--text-primary-color); margin-bottom: 1rem; }
#note-content { outline: none; line-height: 1.7; font-size: 1rem; min-height: 50vh; }
#note-content:empty:before { content: attr(data-placeholder); color: var(--text-tertiary-color); cursor: text; }
#note-tags { width: 100%; font-size: 0.9rem; border: none; border-top: 1px dashed var(--border-color); outline: none; background: none; color: var(--text-secondary-color); padding: 1rem 0; margin-top: 1rem; }

/* --- Todo & Shopping Items --- */
.todo-item { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0; }
.todo-item input[type="checkbox"] { width: 1.25rem; height: 1.25rem; cursor: pointer; accent-color: var(--accent-color); }
.todo-item p { margin: 0; flex-grow: 1; outline: none; }
.todo-item input[type="checkbox"]:checked + p { text-decoration: line-through; color: var(--text-secondary-color); }

.shopping-list-container { border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.shopping-item { display: grid; grid-template-columns: 1fr 80px 120px 40px; gap: 1rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border-color); }
.shopping-item:last-of-type { border-bottom: none; }
.shopping-item input { background: none; border: none; outline: none; color: var(--text-primary-color); font-size: 1rem; padding: 0.25rem; }
.shopping-item .item-name { font-weight: 500; }
.shopping-item .item-qty, .shopping-item .item-price { font-family: 'Source Code Pro', monospace; text-align: right; }
.delete-item-btn { background: none; border: none; color: var(--danger-color); cursor: pointer; font-size: 1.25rem; opacity: 0.5; transition: opacity 0.2s; padding: 0; }
.delete-item-btn:hover { opacity: 1; }
.shopping-list-total { margin-top: 1rem; padding-top: 1rem; border-top: 2px solid var(--text-primary-color); text-align: right; font-size: 1.2rem; font-weight: 700; font-family: 'Source Code Pro', monospace; }


/* --- Responsive Mobile-First Enhancements --- */
@media (max-width: 768px) {
    #app-container { grid-template-columns: 1fr; }

    /* View Switching Logic */
    #list-view { display: flex; }
    #editor-view { display: none; }
    #app-container.editor-active #list-view { display: none; }
    #app-container.editor-active #editor-view { display: flex; height: 100vh; padding: 0 1rem; }

    /* Space & Font Optimization */
    .list-header, .search-and-sort-container, #list-tabs, #tags-container { padding-left: 1rem; padding-right: 1rem; }
    .editor-header { padding: 0.75rem 0; }
    .editor-header .header-actions { gap: 0.1rem; }
    .icon-button { font-size: 1.3rem; padding: 0.4rem; }
    #note-title { font-size: 1.6rem; }
    #note-content { font-size: 1rem; min-height: 60vh; }
    .editor-content { padding-bottom: 5rem; } /* Add padding to avoid keyboard overlap */

    /* Adaptive Shopping List Layout */
    .shopping-list-container { padding: 0.75rem; }
    .shopping-item {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 1rem 0.25rem;
    }
    .shopping-item .item-name { width: 100%; order: 1; }
    .shopping-item .item-qty { flex-grow: 1; order: 2; }
    .shopping-item .item-price { flex-grow: 2; order: 3; }
    .shopping-item .delete-item-btn { order: 4; align-self: center; padding: 0.5rem; }
    .shopping-item input { padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 6px; font-size: 1rem; width: 100%; }
    .shopping-list-total { font-size: 1.1rem; }
}
