:root {
    --primary-color: #7b2cbf;
    --secondary-color: #14213d;
    --accent-color: #4cc9f0;
    --background-color: #0a0a0a;
    --text-color: #e0e0e0;
}

html {
    height: 100%; /* Ensure html takes full height */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: var(--background-color);
    background-image: linear-gradient(rgba(10, 10, 10, 0.65), rgba(10, 10, 10, 0.45)), url('../img/gandalf-web-bg2-exp.webp');
    background-repeat: repeat;
    background-size: 600px;
    color: var(--text-color);
    min-height: 100vh; /* Keep min-height for desktop */
    height: 100%; /* Ensure body takes full height */
    overflow: hidden; /* Keep hidden for desktop? Revisit if needed */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.chat-header {
    position: relative;
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.8), rgba(20, 33, 61, 0.8)), url('../img/gandalf-web-header-4-exp.webp');
    background-size: cover;
    background-position: center;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(76, 201, 240, 0.3);
}

.chat-header h1 {
    margin: 0;
    font-size: 2.5em;
    background: linear-gradient(to right, var(--accent-color), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chat-header-subtitle {
    padding: 0 50px; /* Add padding to prevent overlap with header actions */
    position: relative; /* Allow relative positioning */
    bottom: 5px;      /* Move up slightly */
}

.chat-container {
    background-color: rgba(20, 33, 61, 0.7);
    background-image: linear-gradient(
        rgba(20, 33, 61, 0.95),
        rgba(20, 33, 61, 0.98)
    ), url('../img/gandalf-web-bg3-exp4.webp');
    background-repeat: repeat;
    background-size: 600px;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 30px rgba(123, 44, 191, 0.2);
}

.chat-messages {
    height: 60vh;
    overflow-y: auto;
    padding: 20px;
    margin-bottom: 20px;
}

.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 10px;
    max-width: 80%;
}

.message.user {
    background-color: var(--primary-color);
    margin-left: auto;
}

.message.system {
    /* background-color: var(--secondary-color); */
    margin-right: auto;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: rgba(20, 33, 61, 0.9);
    border-radius: 10px;
}

#user-input {
    flex: 1;
    padding: 10px 10px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    resize: none;
    max-height: 70px; /* Limit height to ~2 lines before scroll */
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
    font-size: inherit;
    box-sizing: border-box;
}

#send-button {
    background: var(--accent-color);
    border: none;
    border-radius: 5px;
    padding: 0 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#send-button:hover {
    background: var(--primary-color);
}

.send-icon {
    color: var(--background-color);
    font-size: 1.2em;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.header-actions {
    position: absolute;
    bottom: 10px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.x-icon svg {
    fill: var(--accent-color);
    transition: fill 0.3s ease;
    width: 24px;
    height: 24px;
}

.x-icon:hover svg {
    fill: #ffffff;
}

.login-button {
    background: var(--accent-color);
    color: var(--background-color);
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-button:hover {
    background: #ffffff;
    color: var(--background-color);
}

/* Mobile-specific styles */
@media only screen and (max-width: 768px) {
    body {
        /* position: fixed; */ /* Removed fixed positioning */
        width: 100%;
        /* height: 100%; */ /* Already set outside MQ */
        min-height: 0; /* Override desktop min-height */
        overflow: hidden; /* Keep hidden on mobile to prevent body scroll */
    }

    .container {
        height: 100%; /* Ensure container fills body height */
        padding: 10px;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent container itself from scrolling */
        /* position: fixed; */ /* Removed fixed positioning */
        /* inset: 0; */ /* Removed inset as it depends on fixed */
        box-sizing: border-box; /* Add box-sizing for better height calculation */
    }

    .chat-header {
        flex-shrink: 0;
        margin-bottom: 15px;
        padding: 8px;
        position: relative;
        background: linear-gradient(135deg, 
            rgba(123, 44, 191, 0.8),
            rgba(20, 33, 61, 0.8)
        ), url('../img/gandalf-web-header-4-exp.webp');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
    }

    .chat-header h1 {
        font-size: 1.2em;
        font-weight: bold;
    }

    .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
        background-color: rgba(20, 33, 61, 0.7);
        background-image: linear-gradient(
            rgba(20, 33, 61, 0.95),
            rgba(20, 33, 61, 0.98)
        ), url('../img/gandalf-web-bg3-exp4.webp');
        background-repeat: repeat;
        background-size: 600px;
        padding: 5px;
    }

    .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px;
        margin-bottom: 10px;
    }

    .message {
        max-width: 90%;
        padding: 10px;
    }

    .chat-input-container {
        flex-shrink: 0;
        width: 100%;
        box-sizing: border-box;
        padding: 8px;
        background: rgba(20, 33, 61, 0.95);
        z-index: 100;
    }

    #user-input {
        padding: 12px;
        font-size: 16px; /* Prevent iOS auto-zoom */
    }

    .header-actions {
        position: absolute;
        bottom: 12px;
        right: 8px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: flex-end;
    }

    .login-button {
        order: 2;
        padding: 4px 10px;
        font-size: 0.85em;
        margin-top: 0;
    }

    .x-icon {
        order: 1;
        display: flex;
        padding-top: 4px;
    }

    .x-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* Even smaller screens */
@media only screen and (max-width: 480px) {
    .chat-header h1 {
        font-size: 1.1em;
    }

    .container {
        padding: 5px;
    }

    .message {
        max-width: 95%;
        padding: 8px;
    }

    .header-actions {
        bottom: 10px;
    }

    .login-button {
        padding: 3px 8px;
        font-size: 0.8em;
    }

    #user-input {
        font-size: 16px; /* Ensure prevention on smaller screens too */
    }
}

/* === Login Page Specific Styles === */

body.login-page-body { /* Style the body for login page */
    /* Background is handled globally now */
}

.login-wrapper {
    display: flex; justify-content: center; align-items: center; 
    min-height: 100vh; padding: 20px; box-sizing: border-box;
}

.login-center-box {
    max-width: 650px; /* Increased from 550px */
    width: 90%;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    padding: 2.5rem 3rem;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Start: Copied background styles from .chat-container */
    background-color: rgba(20, 33, 61, 0.7);
    background-image: linear-gradient(
        rgba(20, 33, 61, 0.95),
        rgba(20, 33, 61, 0.98)
    ), url('../img/gandalf-web-bg3-exp4.webp');
    background-repeat: repeat;
    background-size: 600px;
    /* End: Copied background styles */
    text-align: center;
    position: relative;
    color: #ffffff;
}

.login-center-box h1 {
    font-family: var(--font-logo, 'Orbitron', sans-serif); font-size: 2.0rem; font-weight: 600; 
    color: var(--header-text-color, #e0e0ff); letter-spacing: 0.5px; margin-top: 0; margin-bottom: 0.75em; 
}
.login-center-box .login-subtitle {
    font-size: 1rem; color: var(--text-secondary-color, #cccccc); margin-bottom: 2em; 
}
.login-center-box #react-wallet-adapter-root { margin-bottom: 1em; }

.wallet-adapter-button-trigger {
    padding: 12px 30px !important; font-size: 1rem !important; 
    background-color: var(--primary-button-bg, #512da8) !important; 
    color: var(--primary-button-text, #ffffff) !important;
    border: none !important; border-radius: 6px !important; cursor: pointer;
    transition: background-color 0.2s ease;
}
.wallet-adapter-button-trigger:hover { background-color: var(--primary-button-hover-bg, #673ab7) !important; }

.login-center-box .status-message {
    min-height: 1.2em; margin-top: 0.5em; margin-bottom: 2em; 
    color: var(--text-secondary-color, #cccccc); font-style: italic;
}
.login-center-box .login-info-box {
     background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.1);
     border-radius: 6px; padding: 1.2em 1.8em; max-width: 100%;
     width: auto; margin: 2em auto; box-sizing: border-box; text-align: left;
}
.login-center-box .login-info-box .info-box-title{ color: #ffffff; font-weight: 600; margin-top: 0; margin-bottom: 1em; }
.login-center-box .login-info-box ul { color: #cccccc; list-style: disc; padding-left: 20px; margin: 0; }
.login-center-box .login-info-box li { margin-bottom: 0.6em; }
.login-center-box .login-info-box li:last-child { margin-bottom: 0; }

.login-center-box .back-link {
    display: block; margin: 1.5em auto 0 auto; color: var(--link-color, #a7a7ff); 
    text-decoration: none; font-size: 0.9em; transition: color 0.2s ease;
}
.login-center-box .back-link:hover { color: var(--link-hover-color, #ffffff); text-decoration: underline; }

/* === End Login Page Specific Styles === */

/* === Cookie Banner Styles === */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: rgba(20, 20, 20, 0.9); /* Dark, slightly transparent background */
  color: #f0f0f0; /* Light text color */
  padding: 15px 20px;
  text-align: center;
  font-family: 'Times New Roman', serif; /* Font reminiscent of ancient scrolls */
  font-size: 1rem; /* Increased font size */
  z-index: 1000;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.3);
  transition: bottom 0.5s ease-in-out;
}

#cookie-banner p {
  margin: 0;
  display: inline-block; /* Keep text and button on same line */
}

#cookie-banner button {
  background: none;
  border: none;
  color: #aaa; /* Muted color for close button */
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  margin-left: 15px;
  padding: 0 5px;
  line-height: 1; /* Align button vertically */
  vertical-align: middle;
}

#cookie-banner button:hover {
  color: #fff; /* White on hover */
}

/* Class to hide the banner */
#cookie-banner.hidden {
  bottom: -100px; /* Slide it off screen */
}
/* === End Cookie Banner Styles === */