
/* Responsive overrides at end to win cascade */
@media (max-width: 900px) {
  /* Hide left pane on tablets/phones */
  .chat-sidebar { display: none !important; }

  /* Right pane takes full width */
  .chat-main { flex: 1; }

  /* Single-column bubble layout */
  .message.assistant .message-content,
  .message.user .message-content {
    width: 86%;
    margin-left: 7%;
  }

  /* Slightly reduce top spacing under header on shorter screens */
  .chat-messages { padding-top: 6vh; }

  /* Tighter input spacing */
  .chat-input { gap: 3%; padding: 3% 4%; }

  /* Font sizing for tablets and down */
  body { font-size: 0.98rem; }
  .header-title { font-size: 0.9rem; }
  .chat-input input, .chat-input button { font-size: 0.9rem; }
  .typing-indicator .typing-text { font-size: 0.95rem; }
}

@media (max-width: 520px) {
  .message.assistant .message-content,
  .message.user .message-content {
    width: 92%;
    margin-left: 4%;
  }

  /* Keep loading text readable */
  .typing-indicator .typing-text { opacity: 0.9; }

  /* Smaller phones font sizing */
  body { font-size: 0.94rem; }
  .message-text { font-size: 0.96rem; line-height: 1.45; }
  .chat-input input, .chat-input button { font-size: 0.88rem; }
  .header-title { font-size: 0.85rem; }
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: url('/bandascreen-gray.png') center center / contain no-repeat fixed;
    background-color: #0f1419;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.top-header {
    background: #0f1419;
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    border-radius: 16px 16px 0 0;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.chat-container {
    background: transparent;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    margin-top: 0;
    border-top: none;
}

.chat-sidebar {
    width: 400px;
    background: linear-gradient(180deg, #2d1b3d 0%, #1a0e28 100%);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    border-top-left-radius: 0;
}

.librarian-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 70%, transparent 100%);
    color: white;
    padding: 32px 24px 24px;
    text-align: center;
}

.sidebar-footer h2 {
    font-size: 24px;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.sidebar-footer p {
    font-size: 14px;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #f4f1e8;
    background-image: url('/conan_blank_page.png');
    background-repeat: no-repeat;
    background-size: cover;           /* avoid stretching */
    background-position: 0 -0.5%;
    border-top-right-radius: 0;
    margin-top: 0;
    border-top: none;
}



.chat-header {
    display: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.btn-logout {
    padding: 8px 16px;
    background: #4a0000;
    color: white;
    border: 1px solid #6b0000;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #660000;
}

.chat-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.chat-header p {
    opacity: 0.9;
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-top: calc(85vh * 0.095);
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: none;
    border-top: none;
}

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

.message.assistant {
    padding-right: 0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    font-size: 32px;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    display: none;
}

/* Reserve a percentage column for the user avatar so the bubble's visible edge aligns */
.message.user .message-avatar {
    flex: 0 0 4%;
}
/* Tint the user avatar: replace the emoji with a small dusty-red dot */
.message.user .message-avatar span {
    display: inline-block;
    width: 14px;
    height: 14px;
    background: #6b0000;
    border-radius: 50%;
    line-height: 14px;
    text-indent: -9999px; /* hide the emoji glyph */
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

.message-content {
    /* Width controlled by specific message type rules */
}

.message.user {
    flex-direction: row;
    gap: 1.5%;
}

.message.user .message-content {
    background: rgba(107, 0, 0, 0.7); /* dusty red ~70% opacity */
    color: white;        /* white text */
    padding: 12px 16px;
    border-radius: 16px 16px 4px 16px;
    width: 60%;
    max-width: none;
    margin-left: calc(13.6% - (4% + 1.5%));
    box-shadow: none;
    border: none;
}

.message.assistant .message-content {
    background: transparent;
    padding: 12px 16px;
    border-radius: 16px 16px 16px 4px;
    width: 60%;
    margin-left: 13.6%;
    box-shadow: none;
    border: none;
    max-height: calc(85vh * 0.63);
    overflow-y: auto;
}

.message-text {
    line-height: 1.5;
}

.message-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 12px;
    opacity: 0.7;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span:not(.typing-text) {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Soft blinking status text for loading indicator */
.typing-indicator {
    align-items: center;
}
.typing-indicator .typing-text {
    opacity: 0.85;
    animation: softBlink 1.6s ease-in-out infinite;
    display: inline-block;
    background: transparent;
    border-radius: 0;
    width: auto;
    height: auto;
    transform: none;
    white-space: nowrap; /* stay on one line */
}

@keyframes softBlink {
    0% { opacity: 0.55; }
    50% { opacity: 1; }
    100% { opacity: 0.55; }
}

.chat-input {
    padding: 24px;
    border-top: none;
    background: transparent;
    display: flex;
    gap: 12px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(139, 115, 85, 0.15);
    background: linear-gradient(135deg, #f4f1e8 0%, #f9f6ed 50%, #f4f1e8 100%);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    box-shadow: 0 2px 8px rgba(139, 115, 85, 0.12);
    transition: box-shadow 0.2s;
}

.chat-input input:focus {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-input button {
    padding: 12px 32px;
    background: #4a0000;
    color: white;
    border: 1px solid #6b0000;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, opacity 0.2s;
}

.chat-input button:hover:not(:disabled) {
    background: #660000;
    transform: translateY(-2px);
}

.chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
