:root {
    --bg-dark:        #141414;
    --bg-input:       #222;
    --text-light:     #e5e5e5;
    --text-darker:    #5b5b5b;
    --text-timestamp: rgba(255,255,255,.7);

    --purple-main:    #6e20c5;
    --purple-hover:   #5518a8;
    --receive-color-border: #473555;

    --border-grey:    #454545;
    --border-dark:    #333333;
    --mid-grey:    #4a4a4a;
    --dark-grey:    #1e1e1e;
}

h1:focus {
    outline: none;
}

body {
    background: #111;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    margin: 0;
}


.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.username-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.2em;
    height: 100vh;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-dark);           /* same as .chat-area */
    padding: 0 1.5em;
    box-sizing: border-box;
}

.username-heading {
    color: var(--text-darker);
    font-size: 1.3em;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

.username-input {
    width: 100%;
    max-width: 400px;
    padding: 0.9em 1.2em;
    font-size: 1em;
    border: 1px solid var(--border-grey);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-light);
    text-align: center;
    outline: none;
    transition: box-shadow 0.15s ease-in-out;
}

    .username-input:focus {
        box-shadow: 0 0 5px rgba(99, 99, 99, 0.5);
    }

.start-chat-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-area {
    padding: 1em 1em 0.3em 1em;
    width: 800px;
    height: 80vh;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 1px solid var(--border-dark);
    border-radius: 0 0 1em 1em;
    background: var(--bg-dark);
    overflow: hidden;
}

.private-chat-title-bar {
    padding: 0 0 1rem 0;
    color: #eee;
    text-align: center;
    font-size: 1.2rem;
    border-bottom: 1px solid #444;
}

.group-chat-title-bar {
    padding: 0 0 1rem 0;
    color: white;
    text-align: center;
    font-size: 1.2rem;
    border-bottom: 1px solid #444;
}

    .group-chat-title-bar .group-subtitle {
        margin-top: 0.25rem;
        font-size: 0.9rem;
        color: #ccc;
        overflow-x: auto;
        white-space: nowrap;
        padding: 0 1rem;
        -webkit-overflow-scrolling: touch; /* smooth on mobile */
        scrollbar-width: thin;
        scrollbar-color: var(--mid-grey) var(--dark-grey);
    }

.participant-list {
    display: inline-block;
    overflow-x: auto;
    white-space: nowrap;
    gap: 1rem;
}

.group-subtitle::-webkit-scrollbar {
    height: 4px;
}

.group-subtitle::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 2px;
}

.participant {
    display: inline-block;
    margin: 0 0.3rem;
    color: var(--purple-main); /* just the default */
    font-weight: lighter; /* just the default */
}

.chat-box {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 5px;
    overflow-y: auto; /* Make scrollable */
    scrollbar-color: var(--mid-grey) var(--dark-grey);
    scrollbar-width: thin;
    max-height: calc(100% - 60px);
    max-width: 100%;
    min-width: 100%;
}

    .chat-box li:first-child {
        margin-top: auto; /* Pushes messages upwards naturally */
    }

    .chat-box::-webkit-scrollbar {
        width: 12px; /* Set any property so the above properties actually do shit */
    }

    @keyframes fadeSlideIn {
        from {
            opacity: 0;
            transform: translateY(-0.25em);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .chat-box li {
        position: relative;
        border-radius: 10px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        max-width: 65%;
        width: auto;
        text-align: left;
        word-wrap: break-word;
        font-size: 16px;
        line-height: 1.2;
        white-space: pre-wrap;
        min-height: auto;
        min-width: 2.5em;
        margin: 0 0.5em 0 0.5em;
        animation: fadeSlideIn 0.3s ease-out;
    }

    .chat-box li.formatting-image {
        padding: 0.4em 0.4em 0.7em 0.4em;
        min-width: 50%;
        max-width: 80%
    }

    .chat-box li.formatting-image.image-with-username {
        padding: 0.4em 0.4em 1.7em 0.4em; /* More padding at the bottom for time stamp, less at the top */
    }

    .chat-box li.formatting-message {
        padding: 0.4em 0.7em 0.6em 0.5em;
    }
    
    .chat-box li span::after {
        content: "";
        display: inline-block;
        width: 3.5em; /* Reserve space for timestamp */
    }

        .chat-box li span {
            max-width: 100%;
        }
        
    .message-image {
        width: 100%;
        max-height: calc(100% - 1em);
        border-radius: 0.4em;
        cursor: pointer; /* Clicky clicky biggy biggy */
        /*transition: transform 0.3s ease-out, top 0.3s ease-out, left 0.3s ease-out, width 0.3s ease-out, height 0.3s ease-out;*/
    }

        /* When clicked, scale up and center */
        .message-image.expanded-image {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 9999; /* Put it in the fore-fore-fore-foreground */
            width: 90vw;
            height: 90vh;
            object-fit: contain; /* Avoid stretching */
            border-radius: 10px;
        }

    /* Fullscreen image background overlay */
    .fullscreen-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.7);
        z-index: 9998;
    }

.sent {
    background-color: var(--purple-main);
    color: white;
    align-self: flex-end;
}


.received {
    background: transparent;
    border: 1px solid var(--receive-color-border);
    color: white;
    align-self: flex-start;
}

.group-chat-username-header {
    margin-top: 0.1em;
    margin-bottom: 0.5em;
    font-size: 0.9em;
    font-weight: bold;
}

.chat-input {
    display: flex;
    padding-top: 0.8em;
    margin-top: 0.8em;
    gap: 10px;
    border-top: 1px solid #777777;
    align-items: center;
}

.chat-input textarea {
    flex: 1; /* Takes up all available space */
    font-size: 14px;
    border-radius: 9999px;
    border: 1px solid var(--border-grey);
    resize: none;
    min-height: 30px;
    align-content: center;
    padding: 0.5em 1.5em 0.5em 1.5em;
    line-height: 1.4em;
    overflow-y: auto;
    background: var(--bg-input);
    color: var(--text-light);
}

    .chat-input textarea:focus,
    .chat-input textarea:focus-visible {
        box-shadow: 0 0 5px rgba(99, 99, 99, 0.5) !important; /* Optional glow */
        outline: none !important;
    }

.chat-input button {
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    background: transparent;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .chat-input button svg {
        stroke: #cbcbcb;
    }

.chat-input button:hover {
    background: var(--purple-hover);
}

.timestamp {
    font-size: 12px;
    color: var(--text-timestamp);
    position: absolute;
    bottom: 0.3em;
    right: 0.7em;
    text-align: right;
}

.warning-text {
    text-align: center; 
    margin: 0; 
    font-size: 0.7em; 
    color: var(--text-light)
}

.switch-container {
    display: flex;
    align-items: center;
    gap: 1em;
    margin-top: 2em;
    justify-content: center;
}

.switch-label {
    color: white;
    font-size: 1.2em;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .toggle-switch input:checked + .slider {
        background-color: var(--purple-main);
    }
    
    .toggle-switch input:checked + .slider:before {
        transform: translateX(26px);
    }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-input);
    border: 2px solid var(--purple-main);
    transition: 0.3s;
    border-radius: 34px;
}

    .slider:before {
        position: absolute;
        content: "";
        height: 26px;
        width: 26px;
        left: 2px;
        top: 2px;
        background-color: white;
        transition: 0.3s;
        border-radius: 50%;
    }

/* Tablets */
@media screen and (max-width: 1024px) {
    .chat-area {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        padding: 0;
        border: none;
    }
    
    .warning-text {
        margin-bottom: 1rem;
    }

    .private-chat-title-bar {
        padding: 1rem 0;
    }
    
    .group-chat-title-bar {
        padding: 1rem 0;
    }
    
    .chat-box {
        margin-top: 1em;
    }
    
    .chat-input {
        margin: 1em;
    }
}

/* Phones */
@media screen and (max-width: 768px) {
}

/* Home page */

.private-chat-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    text-align: center;
    gap: 2vh;
}

.start-chat-button {
    background: var(--purple-main);
    color: white;
    border: none;
    padding: 1.2em 2.5em;
    font-size: 1.2em;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.2s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: auto;
}

.start-chat-button:hover {
    background: var(--purple-hover);
}

.middle-content-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /*height: 100vh;*/
    width: 30vw;
    min-width: 20em;
    text-align: center;
    gap: 0.5vh;
}

.textbox-input {
    background: transparent;
    color: white;
    border: 2px solid var(--purple-main);
    padding: 1em;
    font-size: 1.5em;
    width: 100%;
    box-sizing: border-box; /* Make sure the width includes stuff like padding */
    text-align: center;
    border-radius: 1em;
    outline: none;
}

.username-input.textbox-input { 
    max-width: 500px; 
    text-align: center;
}

.copy-button {
    background: var(--mid-grey);
    color: white;
    border: none;
    padding: 0.8em 1.5em;
    font-size: 1em;
    border-radius: 1em;
    width: 100%;
    cursor: pointer;
    transition: background 0.2s ease-in-out;
    min-width: 150px;
}

.copy-button:hover {
    background: var(--purple-main);
}

.version-text {
    position: fixed;
    top: 10px;
    right: 10px;
    color: white;
    font-size: 1em;
}

.waiting-indicator {
    color: #ddd;
    text-align: center;
}

.waiting-indicator-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

@media (min-height: 600px) {
    .username-heading { margin-top: 3vh; }
}
