@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap");

/* main colour scheme and font for site */
:root {
    --bg-color: #161319; /* background */
    --surface-color: #0e0d0f; /* boxes background */
    --primary-color: #64317f; /* primary accent */
    --primary-hover-color: #784097; /* primary color when hovered */
    --secondary-color: #332e36; /* secondary color */
    --secondary-hover-color: #4b474d; /* secondary color when hovered */
    --text-color: #f7ebff; /* text colour */
    --text-dark-color: #736b78; /* darker text */
    --border-color: #272329; /* border of boxes */
    --input-color: #0d0b0f; /* email display */
    --container-radius: 8px; /* border radius */
    --content-radius: 5px; /* border radius */
    --font-family: 'Roboto Mono', monospace; /* cool font */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* set global propeties */
body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 2rem 1rem;
}

/* contains entire content of site */
.container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* address sidebar next to the inbox */
.workspace {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* the column holding the current address and the inbox */
.main-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

/* box listing every address the user created */
.address-sidebar {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--container-radius);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-in-out;
}

/* sidebar title and add buttons */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

/* sidebar title */
.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* EN / RU language switcher */
.lang-switch {
    display: flex;
    gap: 0.15rem;
    font-size: 0.7rem;
}

.lang-option {
    padding: 0.15rem 0.4rem;
    border-radius: var(--content-radius);
    color: var(--text-dark-color);
    text-decoration: none;
    letter-spacing: 0.05em;
    transition: background-color 0.2s, color 0.2s;
}

.lang-option:hover {
    color: var(--text-color);
    background-color: var(--secondary-color);
}

/* the language the page is currently shown in */
.lang-option.active {
    color: var(--text-color);
    background-color: var(--primary-color);
}

/* on the login page the switcher sits in its own row above the title */
.login-lang-switch {
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

/* container for the add buttons */
.sidebar-actions {
    display: flex;
    gap: 0.25rem;
}

/* small square buttons that add an address */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--content-radius);
    display: flex;
    transition: background-color 0.2s ease;
}

.icon-btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

.icon-btn:hover {
    background-color: var(--secondary-hover-color);
}

/* the address list itself */
#address-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* a single saved address */
.address-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--content-radius);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.address-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* the address currently being viewed */
.address-item.active {
    background-color: var(--primary-color);
}

/* the address text, cut off when too long */
.address-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    min-width: 0;
}

/* the part before the @, which is what identifies the inbox */
.address-local {
    font-weight: 600;
}

/* the domain is the same for every address, so play it down */
.address-domain {
    color: var(--text-dark-color);
}

.address-item.active .address-domain {
    color: rgba(247, 235, 255, 0.65);
}

/* email counter on the right of an address */
.address-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background-color: var(--secondary-color);
    color: var(--text-dark-color);
}

/* counter when there is mail the user has not opened yet */
.address-badge.unread {
    background-color: var(--primary-hover-color);
    color: white;
    font-weight: 600;
}

.address-item.active .address-badge {
    background-color: rgba(0, 0, 0, 0.25);
    color: var(--text-color);
}

/* padlock shown on password protected inboxes */
.address-badge.locked {
    background: none;
    padding: 0;
}

/* the note the user wrote for an address, on its own line */
.address-note {
    grid-column: 1 / -1;
    font-size: 0.7rem;
    color: var(--text-dark-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.address-item.active .address-note {
    color: rgba(247, 235, 255, 0.75);
}

/* a note that is a link */
.address-note-link {
    color: inherit;
}

.address-note-link:hover {
    color: var(--text-color);
}

/* buttons that edit and remove an address */
.address-edit,
.address-remove {
    background: none;
    border: none;
    color: var(--text-dark-color);
    cursor: pointer;
    font-family: var(--font-family);
    line-height: 1;
    padding: 0 0.15rem;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.address-edit {
    font-size: 0.8rem;
}

.address-remove {
    font-size: 1.1rem;
}

/* only reveal the buttons when they are reachable */
.address-item:hover .address-edit,
.address-item.active .address-edit,
.address-item:hover .address-remove,
.address-item.active .address-remove {
    opacity: 1;
}

.address-edit:hover,
.address-remove:hover {
    color: var(--text-color);
}

/* shown when the address list is empty */
#address-placeholder {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-dark-color);
    font-size: 0.8rem;
}

/* the form for making a new address */
.address-create {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* the name field with the domain shown after it */
.address-create-field {
    display: flex;
    align-items: center;
    background-color: var(--input-color);
    border: 1px solid var(--border-color);
    border-radius: var(--content-radius);
    padding: 0.5rem 0.6rem;
    gap: 0.1rem;
    min-width: 0;
}

/* the name the user types. a small basis keeps it from squeezing out the domain */
#new-address-input {
    flex: 1 1 4rem;
    min-width: 0;
    background: none;
    border: none;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
}

#new-address-input:focus {
    outline: none;
}

#new-address-input::placeholder {
    color: var(--text-dark-color);
    font-weight: 400;
}

/* the fixed @domain part shown after the field */
.address-create-domain {
    flex: 0 1 auto;
    color: var(--text-dark-color);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* optional note typed while creating an address */
.address-create-note {
    background-color: var(--input-color);
    border: 1px solid var(--border-color);
    border-radius: var(--content-radius);
    padding: 0.5rem 0.6rem;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.8rem;
    width: 100%;
    min-width: 0;
}

.address-create-note:focus {
    outline: none;
    border-color: var(--primary-color);
}

.address-create-note::placeholder {
    color: var(--text-dark-color);
}

/* the note of the open address, shown under it */
.current-note {
    color: var(--text-dark-color);
    font-size: 0.85rem;
    display: none;
}

.current-note a {
    color: var(--primary-hover-color);
}

/* create and random buttons under the field */
.address-create-actions {
    display: flex;
    gap: 0.5rem;
}

.address-create-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 0.5rem;
    font-size: 0.8rem;
}

/* the login page centres a single box */
.login-body {
    align-items: center;
}

.login-panel {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--container-radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    animation: fadeIn 0.4s ease-in-out;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 600;
}

.login-subtitle {
    color: var(--text-dark-color);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* wrong password and lockout messages */
.login-error {
    color: #ff8a8a;
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

.login-submit {
    width: 100%;
    justify-content: center;
    margin-top: 1.25rem;
}

/* ends the session, sits under the address list */
.logout-form {
    margin-top: 0.75rem;
}

#logout-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-dark-color);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.75rem;
    padding: 0.35rem;
    border-radius: var(--content-radius);
    transition: color 0.2s ease, background-color 0.2s ease;
}

#logout-btn:hover {
    color: var(--text-color);
    background-color: var(--secondary-color);
}

/* email action panel box */
.email-panel {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--container-radius);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.5s ease-in-out; /* plays the cool fade in animation defined at the bottom of the css */
}

/* current email text box */
.email-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--input-color);
    border-radius: var(--content-radius);
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}


/* current email text */
#email-input {
    flex-grow: 1;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1rem;
    font-family: var(--font-family);
}

/* stop it from looking weird when you click the email */
#email-input:focus {
    outline: none;
}

/* action button container */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* action buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--content-radius);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* button icons */
.btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* primary button (generate email) */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

/* hover effect */
.btn-primary:hover {
    background-color: var(--primary-hover-color);
    transform: translateY(-2px);
}

/* secondary buttons */
.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-color);
}
        
/* hover effect */
.btn-secondary:hover {
    background-color: var(--secondary-hover-color);
    transform: translateY(-2px);
}

/* inbox display box */
.inbox-section {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--container-radius);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.7s ease-in-out;
}

/* inbox box title and refresh button container */
.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* inbox box title */
.inbox-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}
 
/* refresh inbox button */
#refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.3s ease;
}
     
/* refresh inbox button icon */
#refresh-btn img {
    width: 20px;
    height: 20px;
    transition: filter 0.2s ease;
    filter: brightness(0) invert(1);
}

/* refresh button hover */
#refresh-btn:hover {
    background-color: #333;
}

/* spin effect when refreshing */
#refresh-btn.loading img {
    animation: spin 1s linear infinite;
}

/* list of emails */
#inbox-list {
    list-style: none;
}

/* placeholder when no emails present */
#inbox-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-dark-color);
}

/* single email */
.email-item {
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* dont add line if its the last one */
.email-item:last-child {
    border-bottom: none;
}

/* hover over email */
.email-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* sender and subject container */
.email-details {
    min-width: 0;
}

/* summary excluding body */
.email-summary {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
}

/* sender text */
.email-summary .sender {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* email subject text */
.email-summary .subject {
    color: var(--text-dark-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* time sent text */
.email-summary .time {
    color: var(--text-dark-color);
    font-size: 0.85rem;
    text-align: right;
}

/* the body container (closed) */
.email-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
    padding: 0 1rem;
}
 
/* email body iframe */
.email-body-iframe {
    width: 100%;
    height: 400px;
    border: none;
    border-radius: var(--content-radius);
}

/* the body container (open) */
.email-item.open .email-body {
    max-height: 1000px;
    padding-bottom: 1rem;
}

/* animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
        
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* narrow screens: stack the sidebar on top of the inbox */
@media (max-width: 850px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    /* keep a long address list from pushing the inbox off screen */
    #address-list {
        max-height: 240px;
        overflow-y: auto;
    }

    /* no hover on touch, so always show the remove button */
    .address-remove {
        opacity: 1;
    }
}

/* mobile design */
@media (max-width: 600px) {
    /* make buttons turn into icons */
    .button-text {
        display: none;
    }

    .action-buttons {
        justify-content: center;
    }
}