/* === Universal Reset === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === Base Reset & Body === */
body {
  font-family: system-ui, sans-serif;
  background: #f4f6f8;
  margin: 2rem;
  color: #222;
}

/* === Header Styles === */
header {
  margin-bottom: 2rem;
  text-align: center;
}

header h1 {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  color: #333;
}

.subtitle {
  font-size: 1rem;
  color: #666;
  max-width: 600px;
  margin: 0 auto;
}

/* === Info Section === */
.info-section {
  margin-bottom: 2rem;
}

.info-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 1.5rem;
}

.info-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #333;
}

.info-card p {
  color: #666;
  line-height: 1.5;
}

/* === Session List Styles === */
#session-list-container {
  margin-bottom: 2rem;
}

.loading-state, .empty-state, .error-state {
  text-align: center;
  padding: 2rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.empty-state p, .error-state p {
  margin-bottom: 0.5rem;
  color: #666;
}

.search-container {
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.date-picker-container {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-picker-container label {
  font-weight: 500;
  color: #555;
}

.date-input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  color: #333;
}

.date-group {
  margin-bottom: 2rem;
}

.date-header {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
  color: #555;
}

.session-list {
  list-style: none;
  padding: 0;
}

.session-item {
  margin-bottom: 0.5rem;
}

.session-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: #333;
  transition: background-color 0.2s ease;
}

.session-link:hover {
  background-color: #f0f7ff;
}

.session-time {
  font-weight: 500;
}

.session-info {
  display: flex;
  gap: 0.5rem;
}

.session-model, .session-provider {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #f0f0f0;
  color: #666;
}

.session-model {
  background: #e7f0fa;
  color: #0066cc;
}

.session-provider {
  background: #e6f4ea;
  color: #28a745;
}

/* New styles for the updated session list UI */
.session-link {
  position: relative;
  display: block;
  padding: 1rem;
}

.session-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.sender-name {
  font-weight: bold;
  color: #333;
  margin-bottom: 0.25rem;
}

.message-text {
  color: #555;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.session-footer {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #777;
}

.session-id-small,
.session-time-small {
  position: static; /* remove absolute positioning */
  font-size: 0.75rem;
  color: #777;
}

.empty-message {
  font-style: italic;
  color: #999;
  margin-bottom: 0.5rem;
}

/* === Footer === */
footer {
  text-align: center;
  padding-top: 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid #eee;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.footer-links a {
  color: #0066cc;
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.separator {
  color: #ddd;
}

/* === Container === */
#entry-viewer {
  max-width: 700px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
}

/* === Entry Content === */
#entry-container {
  margin-bottom: 1.5rem;
}

/* === Section Labels (e.g. Time, New Messages) === */
#entry-container > div > strong {
  font-size: 1rem;
  display: inline-block;
  margin-bottom: 0.25rem;
}

/* === Message List === */
ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* === Message Block === */
li[data-role] {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-left: 4px solid #ccc;
  border-radius: 6px;
  background: #f9f9f9;
  font-size: 0.92rem;
  line-height: 1.25;
}

/* === Role Label === */
.role-label {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
}

/* === Message Body === */
.message-body {
  line-height: 1.25;
}

/* === Role-specific colors === */
li[data-role="user"] {
  background: #e6f4ea;
  border-left-color: #28a745;
}

li[data-role="assistant"] {
  background: #e7f0fa;
  border-left-color: #007bff;
}

li[data-role="system"] {
  background: #f5f5f5;
  border-left-color: #888;
}

li[data-role="tool"] {
  background: #fff4e5;
  border-left-color: #e67e22;
}

.tool-call {
  background: #f0f0f0;
  padding: 0.5em;
  margin: 0.5em 0;
  border-left: 3px solid #888;
  font-family: monospace;
}

/* === Navigation Buttons === */
button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #e9ecef;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover:not(:disabled) {
  background: #dee2e6;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

li[data-role="assistant"] .role-label { color: blue; }
li[data-role="user"] .role-label { color: green; }
li[data-role="system"] .role-label { color: gray; }
li[data-role="tool"] .role-label { color: purple; }

.tool-call-label {
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.tool-response {
  margin: 0.5em 0;
}

.tool-response-body {
  background: #f0f0f0;
  padding: 0.5em;
  border-left: 3px solid #888;
  font-family: monospace;
  white-space: pre-wrap;
}

.context-section {
  margin-top: 1rem;
}

.toggle-context {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  text-align: left;
}

.context-list {
  margin-top: 0.5rem;
}

li.context-message,
li.context-message * {
  font-size: 0.7rem !important;
  line-height: 1.25;
  opacity: 0.85;
}

/* === Navigation Buttons (Updated for Back + Refresh) === */
#nav-buttons {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

#nav-buttons button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #e9ecef;
  cursor: pointer;
  transition: background 0.2s ease;
}

#nav-buttons button:hover:not(:disabled) {
  background: #dee2e6;
}

#nav-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Optional: differentiate home/refresh if you like */
#back-btn {
  background-color: #f8f9fa;
}

#refresh-btn {
  background-color: #fff3cd;
  border-color: #ffeeba;
}