:root {
    --primary-color: #3498db;
    --primary-light: #ebf5ff;
    --secondary-color: #2980b9;
    --background-color: #f8fafc;
}

/* Accessibility helper */
.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

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

* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    height: 100vh;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
}

/* Header Buttons - use flex layout within header rather than absolute positioning */
.chat-header {
    background-color: var(--primary-color);
    padding: 12px 16px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* Ensure header link (Yoshibook text) appears white and not underlined */
.header-link,
.chat-header h2 a {
    color: white !important;
    text-decoration: none !important;
    outline: none;
}

/* Keep hover/focus/visited also white and not underlined */
.header-link:hover,
.chat-header h2 a:hover,
.header-link:focus,
.chat-header h2 a:focus,
.header-link:visited,
.chat-header h2 a:visited {
    color: white !important;
    text-decoration: none !important;
    opacity: 0.95;
}

.auth-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.auth-btn {
    padding: 6px 12px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.18s ease;
    outline: none;
    font-size: 0.95rem;
}

.login-btn {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid rgba(255,255,255,0.12);
}

.signup-btn {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.auth-btn:hover, .auth-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* CHAT CONTAINER: full page layout (no corner shrink) */
.chat-container {
    margin: 0;
    width: 100%;
    height: 100vh;
    background-color: white;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Slight header style tweak */
.chat-container .chat-header {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    padding: 12px 18px;
}

/* Messages area: allow scrolling and comfortable padding */
.chat-messages {
    flex: 1;
    padding: 20px;
    background-color: var(--background-color);
    overflow-y: auto;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* message bubbles */
/* Layout changed to CSS grid: left column is message content, right column is fixed timestamp.
   This prevents the message text from flowing underneath the timestamp. */
.message {
    max-width: 78%;
    /* padding: top right bottom left */
    padding: 10px 14px 14px 14px;
    margin: 0;
    border-radius: 14px;
    position: relative;
    animation: messageAppear 0.24s ease;
    word-break: break-word;
    align-self: flex-start;
    background-clip: padding-box;

    display: grid;
    grid-template-columns: 1fr auto; /* flexible text column + auto-width timestamp column */
    grid-column-gap: 12px;
}

/* Keep the enter animation */
@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background-color: var(--primary-color);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 6px;
    align-self: flex-end;
}

.message.other {
    background-color: #e8f5e9;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    align-self: flex-start;
}

/* child elements take the left grid column by default */
.message .username {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.88rem;
    grid-column: 1 / 2; /* explicit: stay in left column */
}

.message .message-text {
    white-space: pre-wrap;
    font-size: 0.95rem;
    margin: 0;
    grid-column: 1 / 2; /* left column */
}

/* timestamp sits in the right column and is bottom-aligned */
.message .timestamp {
    grid-column: 2 / 3; /* right column */
    align-self: end;     /* bottom align the timestamp */
    justify-self: end;   /* right-align inside column */
    font-size: 0.72rem;
    opacity: 0.85;
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
    color: rgba(0,0,0,0.6);
}

/* timestamp color adjustment for user messages */
.message.user .timestamp {
    color: rgba(255,255,255,0.85);
}

/* delete button: keep top-right but nudge left slightly so it doesn't collide with timestamp on narrow messages */
.delete-btn {
    position: absolute;
    top: 6px;
    right: 36px; /* nudged left slightly from earlier 6px to avoid collisions */
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
}

.message.other .delete-btn {
    color: rgba(0,0,0,0.6);
}

.delete-btn:hover {
    color: rgba(255,0,0,0.9);
}

/* input area */
.chat-input {
    padding: 12px;
    background-color: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #eee;
    border-radius: 25px;
    transition: border-color 0.18s ease;
    font-size: 1rem;
}

.chat-input input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.chat-input button {
    padding: 10px 18px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 22px;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.chat-input button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: modalFade 0.18s ease;
}

@keyframes modalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    padding: 24px;
    border-radius: 12px;
    width: 92%;
    max-width: 420px;
    animation: modalSlide 0.18s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

@keyframes modalSlide {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-content input {
    padding: 10px;
    border: 2px solid #eee;
    border-radius: 6px;
    font-size: 16px;
}

.modal-content input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.modal-content button {
    background-color: var(--primary-color);
    color: white;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.18s ease;
}

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

/* notification */
.notification {
    position: fixed;
    top: 16px;
    right: 16px;
    background-color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    z-index: 1300;
    opacity: 0;
    transform: translateY(-6px);
    transition: all 0.18s ease;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* homepage / hero (kept for the home page file that references this CSS) */
.home-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--primary-light);
}

.home-content {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.home-content h1 {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 2rem;
}

.enter-chat-btn {
    background-color: var(--primary-light);
    color: var(--primary-color);
    padding: 1.2rem 2rem;
    border: 3px solid var(--primary-color);
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 1rem 0;
}

.enter-chat-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(52, 152, 219, 0.15);
}

.btn-arrow {
    transition: transform 0.18s ease;
}

.enter-chat-btn:hover .btn-arrow {
    transform: translateX(5px);
}

.mascot-container {
    margin-top: 3rem;
    position: relative;
}

.mascot-image {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.12));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* small screens: responsive layout */
@media (max-width: 640px) {
    .message { 
        max-width: 92%;
        grid-template-columns: 1fr auto; /* keep timestamp column even on narrow screens */
    }
    .chat-messages { padding: 12px; }
}
