html,
body {
    height: 100%;
    /* Make html and body fill the viewport height */
    width: 100%;
    /* Make html and body fill the viewport width */
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Prevent unwanted scrollbars */
    font-family: sans-serif;
    background-color: #f0f2f5;
    display: flex;
    /* Use flexbox for body to ensure container fills it */
    flex-direction: column;
    justify-content: center;
    /* Center the container vertically (if it doesn't take 100%) */
    align-items: center;
    /* Center the container horizontally (if it doesn't takes 100%) */
}

#chat-container {
    width: 100%;
    /* Occupy 100% of the width of its parent (body) */
    height: 100%;
    /* Occupy 100% of the height of its parent (body) */
    background-color: #fff;
    border-radius: 0;
    /* Remove border-radius for true edge-to-edge look */
    box-shadow: none;
    /* Remove box-shadow for true edge-to-edge look */
    padding: 20px;
    /* Keep padding inside the container for content */
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
    /* Crucial: Include padding in width/height calculation */
}

h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

#chat-log {
    flex-grow: 1;
    /* Allow chat log to take up available vertical space */
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 4px;
    background-color: #e9ecef;
    display: flex;
    flex-direction: column;
    /* Ensure messages stack vertically */
}

.message-container {
    position: relative;
    /* Needed for align-self to work if it's a flex item of chat-log */
    display: flex;
    /* align-items: flex-start; Removed as not directly needed here, managed by message div */
    margin-bottom: 10px;
    /* Space between message containers */
}

/* Specific alignment for user/AI message containers (they are flex items of chat-log) */
.user-message-container {
    align-self: flex-end;
    /* Push the whole container to the right */
}

.ai-message-container {
    align-self: flex-start;
    /* Push the whole container to the left */
}

.message {
    padding: 8px 12px;
    border-radius: 15px;
    max-width: 70%;
    word-wrap: break-word;
    /* Ensure long words break */
    position: relative;
    /* Crucial for positioning the copy icon *inside* */
    display: inline-block;
    /* Allow padding to wrap content, but act like block */
}

.user-message {
    background-color: #007bff;
    color: white;
    /* Adjust padding to make space for copy icon on the left */
    padding-left: 30px;
    /* Increased padding */
    padding-right: 12px;
}

.ai-message {
    background-color: #6c757d;
    color: white;
    /* Adjust padding to make space for copy icon on the right */
    padding-right: 30px;
    /* Increased padding */
    padding-left: 12px;
}

/* New styles for sender label */
.sender-label {
    font-size: 0.75em;
    /* Smaller font size */
    font-weight: bold;
    opacity: 0.8;
    /* Slightly transparent */
    margin-right: 5px;
    /* Space between label and message text */
    vertical-align: middle;
    /* Align with middle of text */
}

.user-message .sender-label {
    color: rgba(255, 255, 255, 0.7);
    /* Slightly lighter for user messages */
}

.ai-message .sender-label {
    color: rgba(255, 255, 255, 0.7);
    /* Slightly lighter for AI messages */
}

/* Copy icon button styles - Gemini-like */
.copy-icon {
    position: absolute;
    /* Position relative to the .message (its parent) */
    top: 5px;
    /* Adjust vertical position */
    background: rgba(0, 0, 0, 0.2);
    /* Subtle dark background */
    border: none;
    cursor: pointer;
    padding: 3px 6px;
    /* Padding for the button itself */
    font-size: 14px;
    color: white;
    /* Icon color */
    border-radius: 5px;
    /* Slightly rounded */
    opacity: 0;
    /* Hidden by default */
    pointer-events: none;
    /* Not clickable when hidden */
    transition: opacity 0.3s ease-in-out, background-color 0.2s ease-in-out;
    /* Smooth fade and background change */
}

/* Specific positioning within the message bubble */
.user-message .copy-icon {
    left: 5px;
    /* For user message, it's on the left inside the bubble */
}

.ai-message .copy-icon {
    right: 5px;
    /* For AI message, it's on the right inside the bubble */
}

/* Show icon on hover of the message bubble */
.message:hover .copy-icon {
    opacity: 1;
    /* **Fully visible on hover** */
    pointer-events: auto;
    /* **Becomes clickable on hover** */
}

.copy-icon:hover {
    background-color: rgba(0, 0, 0, 0.4);
    /* Darker background when hovering over the icon */
}

/* message text style for enabling wrapping inside container */
.message-text {
    display: inline-block;
    white-space: pre-wrap;
    /* preserve formatting and wrap */
}

#input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    /* Align items to the bottom, useful for textarea */
}

#user-input {
    /* Styles for the textarea */
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    resize: vertical;
    /* Allow vertical resizing, but not horizontal */
    min-height: 40px;
    /* Minimum height for the textarea */
    max-height: 150px;
    /* Optional: Max height to prevent it from growing too big */
}

#image-upload {
    padding: 5px;
    /* Adjust padding for file input */
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    /* Adjust margin for better alignment with textarea */
    margin-bottom: 3px;
    /* Small adjustment to align with textarea's text line */
}

#send-button {
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 44px;
    /* Changed to more rounded */
    cursor: pointer;
    font-size: 16px;
    white-space: nowrap;
    /* Prevent button text from wrapping */
    /* Adjust margin for better alignment with textarea */
    margin-bottom: 3px;
}

#send-button:hover {
    background-color: #218838;
}

#clarify-button {
    padding: 10px 20px;
    background-color: yellow;
    color: white;
    border: none;
    border-radius: 44px;
    /* Changed to more rounded */
    cursor: pointer;
    font-size: 16px;
    white-space: nowrap;
    /* Prevent button text from wrapping */
    /* Adjust margin for better alignment with textarea */
    margin-bottom: 3px;
}

#clarify-button:hover {
    background-color: #218838;
}

/* Popup styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #fefefe;
    margin: 8% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 70%;
    max-width: none; /* or increase it if you want */
    border-radius: 10px;
    position: relative;
    font-family: Arial, sans-serif;
    box-shadow: 0 0 26px #333a;
    word-break: break-word;
}

.modal-close {
    color: #aaa;
    position: absolute;
    top: 7px;
    right: 16px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close:hover,
.modal-close:focus {
    color: #333;
}

/* Clarify Modal Formatting */
.clarify-modal-section h3 {
  margin-top: 0;
  font-size: 1.3em;
  color: #183153;
}

.clarify-modal-block {
  margin-bottom: 18px;
  background: #f9fafb;
  padding: 14px 16px;
  border-radius: 8px;
  border-left: 4px solid #a9cdf6;
  box-shadow: 0 2px 6px #2442621a;
}

.clarify-rating {
  font-size: 1.1em;
  font-weight: bold;
  margin-left: 8px;
  color: #d2691e;
  background: #fce5cd;
  border-radius: 6px;
  padding: 2px 8px;
}

.clarify-modal-description {
  color: #444;
  font-size: 0.98em;
  margin-top: 8px;
}

.clarify-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.96em;
  background: white;
}

.clarify-modal-table thead th {
  background: #edf4fa;
  color: #294461;
  font-weight: bold;
  padding: 7px;
  border-bottom: 1px solid #c9d8e6;
}

.clarify-modal-table td {
  padding: 7px;
  border-bottom: 1px solid #eef2f6;
}

.clarify-table-scroll {
  overflow-x: auto;
}

.critical {
  background: #f76960;
  color: white;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: bold;
}

.high {
  background: #f7b660;
  color: #4b2e05;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: bold;
}

.medium {
  background: #ffe387;
  color: #573a01;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: bold;
}

.low {
  background: #d7f6bb;
  color: #355721;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: bold;
}

.clarify-modal-codebox {
  background: #20263a;
  color: #f6f6e7;
  padding: 1px 1px;
  border-radius: 7px;
  font-size: 1em;
  font-family: 'Fira Mono','Menlo','Monaco',monospace;
  word-break: break-word;
  margin-top: 1px;
  margin-bottom: 1px;
  white-space: pre-line;
  box-shadow: 0 1px 4px #161b211a;
}

.impact-level {
    max-width: 130px;
    white-space: nowrap;  /* Prevent text wrapping */
    overflow: hidden;     /* Hide overflow */
    text-overflow: ellipsis;  /* Show ellipsis if the text is too long */
}

/* end modal style */

#save-button,
#copy-all-button {
    /* Styles for save and new copy all buttons */
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    white-space: nowrap;
    margin-bottom: 3px;
}

#save-button:hover,
#copy-all-button:hover {
    background-color: #0056b3;
}

#image-preview {
    max-width: 100px;
    max-height: 100px;
    margin-top: 10px;
    border-radius: 4px;
    display: block;
    /* Ensure it takes up space even when hidden for initial layout */
}

/* Feedback Message Styles */
#feedback-message {
    position: fixed;
    bottom: 80px;
    /* Above the input container */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#feedback-message.show {
    opacity: 1;
}

/* Model selection styles */
#model-selection {
    display: flex;
    flex-wrap: wrap;
    /* Allow items to wrap to the next line */
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
    /* Center the radio buttons */
    padding: 10px 0;
    background-color: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #eee;
}

#model-selection label {
    background-color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.9em;
    color: #555;
    user-select: none;
    /* Prevent text selection on labels */
}

#model-selection input[type="radio"] {
    display: none;
    /* Hide the actual radio button */
}

#model-selection input[type="radio"]:checked+label {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

#model-selection label:hover {
    background-color: #d0d0d0;
}

#model-selection input[type="radio"]:checked+label:hover {
    background-color: #0056b3;
    /* Darker blue on hover for selected */
}