/* 
MIT License

Copyright (c) 2025 Zac (zac.cy).

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
* {
    box-sizing: border-box;
}
html {
    height: 100%;
}
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}
body.dark {
    background-color: #1e1e1e;
    color: #ddd;
}
.page-content {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    position: relative;
}
.container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
    transition: background 0.3s;
    margin-top: 60px; /* Space for hamburger */
}
body.dark .container {
    background: #2c2c2c;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.tags-container {
    margin-top: 20px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-height: 50px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    overflow-y: auto;
    transition: border 0.3s, background 0.3s;
}
body.dark .tags-container {
    border: 1px solid #555;
    background: #333;
}
.tag {
    display: flex;
    align-items: center;
    background: #f0f0f0;
    border-radius: 20px;
    padding: 5px 10px;
    cursor: pointer;
    max-width: calc(100% - 20px);
    transition: background 0.3s;
}
body.dark .tag {
    background: #444;
}
.color-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}
.tag-text {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.edit-btn, .delete-btn {
    margin-left: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}
body.dark .edit-btn, body.dark .delete-btn {
    background: #666;
}
.edit-btn:hover, .delete-btn:hover {
    background: #ccc;
}
body.dark .edit-btn:hover, body.dark .delete-btn:hover {
    background: #777;
}
#tag-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    flex-grow: 1;
    min-width: 100px;
    color: inherit;
}
#hamburger {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    font-size: 24px;
    z-index: 11;
}
#menu {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 250px;
    background: white;
    padding: 20px;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 10;
}
#menu.open {
    transform: translateX(0);
}
body.dark #menu {
    background: #2c2c2c;
}
#menu button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: inherit;
    padding: 10px 0;
    text-align: left;
}
#menu button:hover {
    background: #f0f0f0;
}
body.dark #menu button:hover {
    background: #333;
}
.theme-toggle-container {
    display: flex;
    justify-content: flex-start;
    padding: 10px 0;
    user-select: none;
}
#theme-toggle {
    width: 40px;
    height: 40px;
    font-size: 20px;
    border-radius: 8px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}
body.dark #theme-toggle {
    background: #444;
}
#theme-toggle:hover {
    background: #e0e0e0;
}
body.dark #theme-toggle:hover {
    background: #555;
}
#collection-controls {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dropdown-trigger {
    cursor: pointer;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: border 0.3s;
}
body.dark .dropdown-trigger {
    border: 1px solid #555;
}
.color-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
    flex-shrink: 0;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: none;
    z-index: 1;
    max-width: 300px;
    width: auto;
    transition: background 0.3s, border 0.3s;
}
body.dark .dropdown-menu {
    background: #2c2c2c;
    border: 1px solid #555;
}
.collection-list {
    max-height: 200px;
    overflow-y: auto;
}
.collection-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    cursor: pointer;
    transition: background 0.3s;
}
.collection-item:hover {
    background: #f0f0f0;
}
body.dark .collection-item:hover {
    background: #444;
}
.collection-item .name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
}
#current-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rename-btn, .collection-delete-btn {
    margin-left: auto;
}
.new-collection {
    margin-top: 10px;
    display: flex;
    gap: 5px;
}
.new-collection input {
    flex-grow: 1;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
body.dark .new-collection input {
    border: 1px solid #555;
    background: #333;
    color: #ddd;
}
.new-collection button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.new-collection button:hover {
    background-color: #0056b3;
}
#save-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
#save-btn:hover {
    background-color: #218838;
}
#history-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}
#history-controls button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
#history-controls button:hover {
    background-color: #0056b3;
}
#history-controls button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 300px;
    width: 80%;
    text-align: center;
    transition: background 0.3s;
}
body.dark .modal-content {
    background: #2c2c2c;
}
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}
.modal-buttons button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}
.modal-buttons button:hover {
    background-color: #0056b3;
}
#message-area {
    display: none;
}
footer {
    width: 100%;
    text-align: center;
    padding: 10px 0;
    background-color: #f4f4f4;
    transition: background-color 0.3s;
}
body.dark footer {
    background-color: #1e1e1e;
}
@media (max-width: 480px) {
    .container {
        padding: 20px;
    }
    .tag-text {
        max-width: 200px;
    }
    .dropdown-menu {
        width: 100%;
        left: 0;
    }
    .page-content {
        padding: 10px;
    }
    #hamburger {
        right: 10px;
    }
    #menu {
        width: 100%;
    }
}
#theme-modal-content {
    max-width: 400px;
    text-align: left;
}
.theme-option {
    background: #f0f0f0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s;
}
body.dark .theme-option {
    background: #333;
}
.theme-option:hover {
    background: #e0e0e0;
}
body.dark .theme-option:hover {
    background: #444;
}
.theme-option input {
    margin-right: 10px;
}
.theme-option label {
    flex-grow: 1;
    font-weight: bold;
}
.swatches {
    display: flex;
    gap: 5px;
}
.swatch {
    width: 15px;
    height: 15px;
    border-radius: 50%;
}
#theme-list {
    max-height: 300px;
    overflow-y: auto;
}
.history-console-container {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    transition: border 0.3s, background 0.3s;
}
body.dark .history-console-container {
    border: 1px solid #555;
    background: #333;
}
.console-controls {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    border-bottom: 1px solid #ddd;
    transition: border 0.3s;
}
body.dark .console-controls {
    border-bottom: 1px solid #555;
}
.console-controls label {
    margin-right: 10px;
}
#write-to-log {
    margin-right: 10px;
}
#clear-log-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
#clear-log-btn:hover {
    background-color: #c82333;
}
#clear-log-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
.history-console {
    padding: 10px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 12px;
    text-align: left;
    display: block;
}
.history-console.collapsed {
    display: none;
}