@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Material Design 3 Color Tokens */
    --md-sys-color-primary: #0B57D0;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #D3E3FD;
    --md-sys-color-on-primary-container: #041E49;
    --md-sys-color-secondary: #006D39;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #C3EED5;
    --md-sys-color-on-secondary-container: #00210E;
    --md-sys-color-surface: #F8F9FA;
    --md-sys-color-surface-container: #F0F4F9;
    --md-sys-color-on-surface: #1B1B1F;
    --md-sys-color-surface-variant: #E1E2EC;
    --md-sys-color-on-surface-variant: #44474E;
    --md-sys-color-outline: #74777F;
    --md-sys-color-error: #BA1A1A;

    /* Spacing & Borders */
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 16px;
    --md-sys-shape-corner-large: 24px;
    --md-sys-shape-corner-extra-large: 32px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* --- Typography --- */
h1 {
    font-size: 2.5rem;
    font-weight: 500;
}

h2 {
    font-size: 1.5rem;
    font-weight: 500;
}

p {
    font-size: 1rem;
    line-height: 1.5;
}

/* --- Buttons --- */
.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 100px;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.1, 0.1, 0, 1);
    gap: 8px;
}

.md-btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.md-btn-primary:hover {
    box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

.md-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background-color: transparent;
    border: 0px solid #d4d4d4;
    color: var(--md-sys-coloron-surface-variant);
}

.md-btn-icon:hover {
    background-color: rgba(68, 71, 78, 0.08);
}

/* --- Input Fields --- */
.md-input-container {
    width: 100%;
    margin-bottom: 24px;
}

.md-input {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: transparent;
    font-family: inherit;
    font-size: 1rem;
    color: var(--md-sys-color-on-surface);
    transition: border-color 0.2s;
}

.md-input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
}

/* --- Login Page --- */
#username-page {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 0% 0%, rgba(11, 87, 208, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(0, 109, 57, 0.05) 0%, transparent 50%);
}

.login-card {
    background-color: var(--md-sys-color-surface-container);
    padding: 48px;
    border-radius: var(--md-sys-shape-corner-extra-large);
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.6s cubic-bezier(0.2, 0, 0, 1);
}

.login-card img {
    margin-bottom: 24px;
    height: 64px;
}

.login-card h1 {
    margin-bottom: 8px;
    color: var(--md-sys-color-on-surface);
}

.login-card p {
    margin-bottom: 40px;
    color: var(--md-sys-color-on-surface-variant);
}

/* --- Chat Page Layout --- */
#chat-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    background-color: var(--md-sys-color-surface);
}

/* Sidebar */
.chat-sidebar {
    width: 320px;
    background-color: var(--md-sys-color-surface-container);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--md-sys-color-surface-variant);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.sidebar-header {
    padding: 16px 24px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: pointer;
    transition: background-color 0.2s;
    gap: 16px;
    margin-bottom: 4px;
}

.chat-item:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.chat-item.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--md-sys-color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--md-sys-color-surface);
    position: relative;
}

.chat-header {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
    z-index: 10;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Message Area */
#messageArea {
    flex: 1;
    padding: 24px 24px 0px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    background-image: url('https://cloud.classwalla.com/0/2026/Mar/18/13/23/54/bg.png');
    background-position: center;
    background-repeat: repeat;
    background-size: auto;
    background-attachment: fixed;
}

.message {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.chat-messages-header {
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 7pt;
    padding: 10px;
    display: flex;
    flex-direction: column;
    margin: auto;
    position: fixed;
    top: 0px;
    z-index: 1;
    right:0px;
}

.chat-messages-header-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 8px 15px;
    border-radius: 10px;
    display:flex;
    flex-direction:column;
    align-items:center;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    font-size: 1rem;
    position: relative;
    box-shadow: 0px 1px 1px 0px #00000024;
}

.message.received .message-bubble {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-bottom-right-radius: 4px;
}

#search-container {
    display: flex;
    align-items: center;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: 100px;
    padding: 0 12px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 91%;
    background-color: white;
    height: 50px;
    top: 10px;
    box-shadow: 1px 1px 2px 0px #00000012;
}

#search-btn {
    position:relative;
    z-index: 1;
}

.message-info {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    padding: 4px 10px 5px 0px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.message.sent .message-info {
    justify-content: flex-end;
}

/* Input Area */
.chat-input-area {
    padding: 10px;
    background-image: url('https://cloud.classwalla.com/0/2026/Mar/18/13/23/54/bg.png');
    background-position: auto;
    background-repeat: repeat;
    background-size: cover;
    background-attachment: fixed;
}

.input-container {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-extra-large);
    display: flex;
    align-items: center;
    padding: 5px;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.input-container input {
    flex: 1;
    border: none;
    background: transparent;
    padding-left: 10px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--md-sys-color-on-surface);
}

.input-container input:focus {
    outline: none;
}

.delete_message_btn {
    padding: 0px !important;
    display: flex;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    top: 0px !important;
    background-color: #fff0f0 !important;
    align-items: center;
    justify-content: center;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Mobile Responsive --- */
@media screen and (max-width: 768px) {
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }

    .chat-sidebar.open {
        transform: translateX(0);
        box-shadow: 16px 0 32px rgba(0, 0, 0, 0.1);
    }

    .message {
        max-width: 85%;
    }
}