*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --background-color: #2e3440;
    --surface-color: #3b4252;
    --primary-color: #a3be8c;
    --secondary-color: #81a1c1;
    --on-surface-color: #eceff4;
    --on-primary-color: #2e3440;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--on-surface-color);
    min-height: 100vh; /* Ensure body is at least viewport height */
    overflow-y: scroll; /* Allow body to scroll */
    position: relative; /* For fixed positioning of children */
}

body.no-scroll {
    overflow: hidden;
}

.container {
    max-width: 800px;
    margin: 2em auto;
    padding: 1em;
}

h1, h2 {
    text-align: center;
    color: var(--primary-color);
}

form {
    display: flex;
    flex-direction: column;
    gap: 1em;
    margin-bottom: 2em;
    background-color: var(--surface-color);
    padding: 1.5em;
    border-radius: 8px;
}

input {
    padding: 0.8em;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--on-surface-color);
    font-size: 1em;
}

button {
    padding: 0.8em 1.2em;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: var(--on-primary-color);
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: var(--secondary-color);
}

#quotes-container {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.5em;
}

.quote-card {
    background-color: var(--surface-color);
    padding: 1em;
    border-radius: 8px;
    border-left: 5px solid var(--primary-color);
    display: flex;
    flex-direction: column;
}

.quote-card p {
    margin: 0;
}

.quote-card .quote-text {
    font-style: italic;
    margin-bottom: 0.5em;
}

.quote-text .greyed-out {
    color: #999;
}

.quote-card .teacher-text {
    font-weight: bold;
    color: var(--secondary-color);
    text-align: right;
    margin-top: auto;
}

.quote-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5em;
}

.quote-card .date-text,
.quote-card .owner-text {
    font-size: 0.8em;
    color: #aaa;
}

.filters {
    display: flex;
    gap: 1em;
    margin-bottom: 1em;
    align-items: center;
}

.filters > input,
.filters > select {
    flex: 1;
}

.teacher-warning {
    margin-top: 0.5em;
    color: #d08770;
    display: flex;
    align-items: center;
    gap: 0.5em;
    width: 100%;
}

a:link {
    color: #81a1c1;
}

a:visited {
    color: #b48ead;
}

.teacher-warning a {
    color: #ebcb8b;
    text-decoration: underline;
}

.teacher-warning .icon {
    font-size: 1.2em;
}

select,
input[type="date"] {
    width: auto;
    padding: 0.8em;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--on-surface-color);
    font-size: 1em;
}

.context-menu {
    position: absolute;
    display: none;
    background-color: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 0.5em 0;
    z-index: 1000;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu li {
    padding: 0.5em 1em;
    cursor: pointer;
}

.context-menu li:hover {
    background-color: var(--primary-color);
    color: var(--on-primary-color);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: var(--surface-color);
    margin: 15% auto;
    padding: 20px;
    border: 1px solid var(--primary-color);
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: var(--on-surface-color);
    text-decoration: none;
    cursor: pointer;
}

.header-icons {
    display: flex;
    justify-content: flex-end;
    padding: 10px;
    gap: 10px;
    font-size: 1.5em;
    color: var(--primary-color);
    align-items: center;
}

.header-icons i {
    cursor: pointer;
}

.header-icons a {
    color: var(--primary-color);
}

#readme-modal .modal-content {
    max-width: 800px;
    margin: 5% auto;
    text-align: left;
}

#readme-content h1, #readme-content h2 {
    color: var(--primary-color);
    text-align: left;
}

#readme-content p {
    margin-bottom: 1em;
}

#readme-content blockquote {
    border-left: 4px solid var(--secondary-color);
    padding-left: 1em;
    margin-left: 0;
    color: #d8dee9;
}

#back-to-top {
    display: none; /* Hidden by default */
    position: fixed; /* Fixed/sticky position */
    bottom: 30px; /* Place the button at the bottom of the page */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%); /* Adjust for exact centering */
    z-index: 99; /* Make sure it does not overlap */
    border: none; /* Remove borders */
    outline: none; /* Remove outline */
    background-color: var(--primary-color); /* Set a background color */
    color: var(--on-primary-color); /* Text color */
    cursor: pointer; /* Add a mouse pointer on hover */
    padding: 15px; /* Some padding */
    border-radius: 10px; /* Rounded corners */
    font-size: 18px; /* Increase font size */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.8);
    transition: background-color 0.3s ease;
}

#back-to-top:hover {
    background-color: var(--secondary-color);
}

.error-box {
    background-color: #bf616a;
    color: #eceff4;
    padding: 1em;
    border-radius: 8px;
    margin-bottom: 1em;
    display: none;
}

@media screen and (max-width: 768px) {
    body {
        font-size: 1em;
    }

    .container {
        margin: 1em;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

    .filters {
        flex-direction: column;
    }

    .filters > input,
    .filters > select {
        width: 100%;
        box-sizing: border-box;
    }

    #quotes-container {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10% auto;
        width: 90%;
    }

    input[type="text"],
    select,
    button {
        font-size: 1.1em;
        padding: 0.8em;
    }
}
