* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #e9e5dc; 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M0 0h100v100H0z" fill="none" stroke="%23d9d5cc" stroke-width="0.5"/></svg>');
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
}

body::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    width: 33vw;
    height: 33vh;
    background-image: url('../assets/images/penbg.png');
    background-repeat: no-repeat;
    background-position: bottom left;
    background-size: contain;
    z-index: -1;
    pointer-events: none;
}

body.dark-theme::after {
    filter: invert(1);
}

body.dark-theme {
    background-color: #2d2d2d;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M0 0h100v100H0z" fill="none" stroke="%23393939" stroke-width="0.5"/></svg>');
    color: #e0e0e0;
}

body.dark-theme .input-container,
body.dark-theme .note-edit-overlay .paper {
    box-shadow: 3px 3px 15px rgba(0,0,0,0.3);
}

body.dark-theme .input-container,
body.dark-theme .note-edit-overlay .paper {
    background-color: #383838;
}

body.dark-theme #note-input,
body.dark-theme #new-note-input,
body.dark-theme #search-input,
body.dark-theme .note-title-input,
body.dark-theme .note-content-input {
    color: #e0e0e0;
    background-color: transparent;
}

body.dark-theme .note-card {
    background-color: #383838;
    box-shadow: 3px 3px 15px rgba(0,0,0,0.3);
}

body.dark-theme .binder-header {
    background-color: #383838;
}

body.dark-theme button {
    background-color: #444;
    color: #ddd;
}

body.dark-theme #pass-note-btn {
    background-color: #0d47a1;
    color: #e3f2fd;
}

body.dark-theme #save-to-binder-btn {
    background-color: #1b5e20;
    color: #e8f5e9;
}

body.dark-theme #scrap-it-btn {
    background-color: #b71c1c;
    color: #ffebee;
}

body.dark-theme .corner-button {
    background-color: #4527a0;
    color: #ede7f6;
}

.icon {
    font-family: monospace;
    font-weight: bold;
    margin-right: 4px;
    font-style: normal;
}

#app {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

.hidden {
    display: none !important;
}

#home-page {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #3a3a3a;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    transform: rotate(-1deg);
}

body.dark-theme h1 {
    color: #f0f0f0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.input-container {
    width: 100%;
    max-width: 600px;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 3px 3px 15px rgba(0,0,0,0.1);
    transform: rotate(0.5deg);
    position: relative;
    margin-bottom: 20px;
    
    background-image: linear-gradient(0deg, rgba(240,240,240,0.1) 1px, transparent 1px);
    background-size: 100% 24px;
}

.input-container:before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: calc(100% + 10px);
    height: calc(100% + 10px);
    background-color: rgba(255,255,255,0.6);
    z-index: -1;
    transform: rotate(-1deg);
    border-radius: 8px;
}

body.dark-theme .input-container:before {
    background-color: rgba(40,40,40,0.6);
}

.note-title-input {
    width: 100%;
    padding: 5px 15px;
    border: none;
    border-bottom: 1px solid #ddd;
    background-color: transparent;
    font-size: 1.2rem;
    outline: none;
    margin-bottom: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-transform: uppercase;
    font-weight: bold;
}

#note-input, #new-note-input, .note-content-input {
    width: 100%;
    height: 150px;
    padding: 15px;
    border: none;
    background-color: transparent;
    font-size: 1rem;
    resize: none;
    outline: none;
    margin-bottom: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 24px;
}

.button-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
}

button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background-color: #f0f0f0;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
    position: relative;
}

button:hover {
    background-color: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 1px 3px 5px rgba(0,0,0,0.1);
}

body.dark-theme button:hover {
    background-color: #555;
}

#pass-note-btn {
    background-color: #e3f2fd;
    color: #0d47a1;
}

#save-to-binder-btn {
    background-color: #e8f5e9;
    color: #1b5e20;
}

#scrap-it-btn {
    background-color: #ffebee;
    color: #b71c1c;
}

.corner-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: #ede7f6;
    color: #4527a0;
}

#theme-toggle, #binder-theme-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: #fff3e0;
    color: #e65100;
}

#binder-theme-toggle {
    position: relative;
    top: auto;
    left: auto;
    margin-left: 15px;
}

body.dark-theme #theme-toggle,
body.dark-theme #binder-theme-toggle {
    background-color: #4a148c;
    color: #ea80fc;
}

.copy-feedback {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    opacity: 0;
    pointer-events: none;
    animation: flyOut 1.5s ease forwards;
    white-space: nowrap;
}

@keyframes flyOut {
    0% {
        opacity: 0;
        top: 0;
    }
    20% {
        opacity: 1;
        top: -30px;
    }
    80% {
        opacity: 1;
        top: -40px;
    }
    100% {
        opacity: 0;
        top: -50px;
    }
}

#binder-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 80vh;
}

.binder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

.binder-code-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-sort-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

.search-container {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 200px;
}

.sort-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#sort-select {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
}

body.dark-theme #sort-select {
    background-color: #444;
    color: #eee;
    border-color: #555;
}

#search-input {
    width: 100%;
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

body.dark-theme #search-input {
    border-color: #555;
    background-color: #444;
}

#search-input:focus {
    border-color: #9c27b0;
    box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.2);
}

body.dark-theme #search-input:focus {
    border-color: #bb86fc;
    box-shadow: 0 0 0 2px rgba(187, 134, 252, 0.2);
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    flex: 1;
}

.note-card {
    background-color: #fff;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
    position: relative;
    transform: rotate(var(--random-rotation));
    
    background-image: linear-gradient(0deg, rgba(240,240,240,0.1) 1px, transparent 1px);
    background-size: 100% 24px;
    
    color: #000000 !important;
}

.note-title {
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
    text-transform: uppercase;
    font-size: 1.1rem;
    
    color: #000000 !important;
}

.note-content {
    margin-bottom: 10px;
    white-space: pre-wrap;
    
    color: #000000 !important;
}

.note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.binder-footer {
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

body.dark-theme .binder-footer {
    border-top-color: #444;
}

#add-note-btn {
    background-color: #e8f5e9;
    color: #1b5e20;
    padding: 10px 20px;
    font-size: 1rem;
}

body.dark-theme #add-note-btn {
    background-color: #1b5e20;
    color: #e8f5e9;
}

#im-bored-btn {
    background-color: #f5f5f5;
    color: #616161;
    margin-top: 20px;
}

body.dark-theme #im-bored-btn {
    background-color: #424242;
    color: #bdbdbd;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

body.dark-theme .overlay-content {
    background-color: #333;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.overlay h3 {
    margin-bottom: 20px;
    text-align: center;
}

.share-link-container, 
.overlay-buttons {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

#share-link, 
#binder-code-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    outline: none;
}

body.dark-theme #share-link,
body.dark-theme #binder-code-input {
    background-color: #444;
    color: #eee;
    border-color: #555;
}

#close-share-btn,
#submit-code-btn,
#cancel-code-btn {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
}

.note-edit-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 1000;
}

.note-edit-overlay .paper {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 600px;
    transform: rotate(0.5deg);
    position: relative;
    background-image: linear-gradient(0deg, rgba(240,240,240,0.1) 1px, transparent 1px);
    background-size: 100% 24px;
}

.note-edit-overlay .note-title-input {
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
    padding-bottom: 5px;
}

.note-edit-overlay .note-content-input {
    min-height: 200px;
}

.note-edit-overlay .button-container {
    margin-top: 20px;
}

.logout-overlay p {
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.6;
}

#notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

body.dark-theme #notification {
    background-color: #555;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }
    
    .button-container {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .binder-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .notes-grid {
        grid-template-columns: 1fr;
    }

    .corner-button, #theme-toggle {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        margin: 10px 0;
        width: auto;
        align-self: center;
    }

    #home-page {
        gap: 20px;
    }

    .search-sort-container {
        flex-direction: column;
        align-items: stretch;
    }

    .sort-container {
        justify-content: space-between;
    }
    
    #binder-theme-toggle {
        margin: 0 0 10px 0;
    }
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    border: 1px solid rgba(0,0,0,0.1);
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.edit-color-picker {
    margin: 15px 0;
}

.edit-color-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.edit-color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    border: 2px solid transparent;
}

.edit-color-swatch:hover {
    transform: scale(1.1);
}

.edit-color-swatch.selected {
    border-color: #000;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000;
}

body.dark-theme .edit-color-swatch.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px #333, 0 0 0 4px #fff;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}

#color-filter {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
}

body.dark-theme #color-filter {
    background-color: #444;
    color: #eee;
    border-color: #555;
}

.note-actions .color-btn {
    background-color: #f5f5f5;
    color: #333;
}

body.dark-theme .note-actions .color-btn {
    background-color: #555;
    color: #eee;
}

.note-card:nth-child(odd),
.note-card:nth-child(3n),
.note-card:nth-child(4n) {
    background-color: inherit;
}

body.dark-theme .note-card:nth-child(odd),
body.dark-theme .note-card:nth-child(3n),
body.dark-theme .note-card:nth-child(4n) {
    background-color: inherit;
}

@media (max-width: 768px) {
    .filter-container {
        margin-left: 0;
        margin-top: 10px;
    }
    
    .color-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    #app {
        padding: 10px;
    }
    
    .input-container {
        padding: 15px;
    }
    
    #note-input, 
    #new-note-input,
    .note-content-input {
        height: 120px;
    }
    
    .corner-button {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}
