:root {
  --gcl-green: #1a7a4c;
  --gcl-green-light: #28a06a;
  --gcl-green-pale: #e8f5ee;
  --gcl-dark: #1a1a2e;
  --gcl-gray: #f4f5f7;
  --gcl-border: #e0e0e0;
  --gcl-text: #2d2d2d;
  --gcl-text-light: #6b7280;
  --gcl-white: #ffffff;
  --gcl-red: #e74c3c;
  --gcl-yellow: #f39c12;
  --gcl-blue: #3498db;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gcl-gray);
  color: var(--gcl-text);
  line-height: 1.5;
}

/* ═══════ CHAT PAGE ═══════ */
.chat-container {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gcl-white);
  box-shadow: var(--shadow-lg);
}

.chat-header {
  background: var(--gcl-green);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-logo {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.chat-header-info h1 {
  font-size: 16px;
  font-weight: 600;
}

.chat-header-info p {
  font-size: 12px;
  opacity: 0.85;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f0f2f5;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.45;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.bot {
  background: var(--gcl-white);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.message.user {
  background: var(--gcl-green-pale);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message .time {
  font-size: 11px;
  color: var(--gcl-text-light);
  margin-top: 4px;
  text-align: right;
}

.typing-indicator {
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--gcl-white);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  display: none;
}

.typing-indicator span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--gcl-text-light);
  border-radius: 50%;
  margin: 0 1px;
  animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.chat-input-area {
  padding: 12px 16px;
  background: var(--gcl-white);
  border-top: 1px solid var(--gcl-border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gcl-border);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area input:focus {
  border-color: var(--gcl-green);
}

.chat-input-area button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
}

.btn-send {
  background: var(--gcl-green);
  color: white;
}

.btn-send:hover { background: var(--gcl-green-light); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-upload {
  background: var(--gcl-gray);
  color: var(--gcl-text-light);
}

.btn-upload:hover { background: var(--gcl-border); }

#file-input { display: none; }

.upload-toast {
  background: var(--gcl-green-pale);
  color: var(--gcl-green);
  padding: 8px 14px;
  font-size: 13px;
  text-align: center;
  display: none;
}

/* ═══════ LAWYER PORTAL ═══════ */
.portal-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  background: var(--gcl-dark);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.portal-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.portal-header .badge {
  font-size: 12px;
  background: var(--gcl-green);
  padding: 4px 10px;
  border-radius: 12px;
}

.portal-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Stats bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 24px;
  background: var(--gcl-white);
  border-bottom: 1px solid var(--gcl-border);
}

.stat-card {
  padding: 12px 16px;
  background: var(--gcl-gray);
  border-radius: var(--radius);
  text-align: center;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gcl-green);
}

.stat-card .label {
  font-size: 12px;
  color: var(--gcl-text-light);
  margin-top: 2px;
}

/* Sidebar (conversation list) */
.sidebar {
  width: 380px;
  border-right: 1px solid var(--gcl-border);
  background: var(--gcl-white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gcl-border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sidebar-filters input,
.sidebar-filters select {
  padding: 6px 10px;
  border: 1px solid var(--gcl-border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.sidebar-filters input { flex: 1; min-width: 120px; }

.conv-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

.conv-item:hover { background: var(--gcl-gray); }
.conv-item.active { background: var(--gcl-green-pale); border-left: 3px solid var(--gcl-green); }

.conv-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conv-item-header .name {
  font-weight: 600;
  font-size: 14px;
}

.conv-item-header .time {
  font-size: 11px;
  color: var(--gcl-text-light);
}

.conv-item-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gcl-gray);
  color: var(--gcl-text-light);
}

.tag.service { background: #e8f4fd; color: var(--gcl-blue); }
.tag.active { background: var(--gcl-green-pale); color: var(--gcl-green); }
.tag.escalated { background: #fdecea; color: var(--gcl-red); }
.tag.completed { background: #f0f0f0; color: #888; }

/* Detail panel */
.detail-panel {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.detail-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gcl-text-light);
  font-size: 15px;
}

.detail-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--gcl-border);
  min-width: 0;
}

.detail-chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gcl-border);
  background: var(--gcl-white);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-chat-header h2 {
  font-size: 15px;
}

.status-controls select {
  padding: 4px 8px;
  border: 1px solid var(--gcl-border);
  border-radius: 6px;
  font-size: 12px;
}

.detail-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f0f2f5;
}

.detail-messages .message {
  max-width: 75%;
  font-size: 13px;
}

.detail-messages .message.lawyer {
  background: #fff3cd;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.detail-messages .message .role-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gcl-text-light);
  margin-bottom: 2px;
}

/* Info sidebar */
.detail-info {
  width: 320px;
  overflow-y: auto;
  background: var(--gcl-white);
  padding: 16px;
  flex-shrink: 0;
}

.info-section {
  margin-bottom: 20px;
}

.info-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gcl-text-light);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gcl-border);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.info-row .label { color: var(--gcl-text-light); }
.info-row .value { font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }

.doc-card {
  background: var(--gcl-gray);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.doc-card .doc-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.doc-card .doc-name a {
  color: var(--gcl-green);
  font-size: 12px;
  text-decoration: none;
}

.doc-card .doc-category {
  font-size: 11px;
  color: var(--gcl-blue);
  margin-bottom: 4px;
}

.doc-card .doc-desc {
  font-size: 12px;
  color: var(--gcl-text-light);
}

.notes-list {
  max-height: 200px;
  overflow-y: auto;
}

.note-item {
  background: var(--gcl-gray);
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}

.note-item .note-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gcl-text-light);
  margin-bottom: 4px;
}

.note-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-form input,
.note-form textarea {
  padding: 6px 10px;
  border: 1px solid var(--gcl-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.note-form textarea { resize: vertical; min-height: 60px; }

.note-form button {
  padding: 6px 12px;
  background: var(--gcl-green);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.note-form button:hover { background: var(--gcl-green-light); }

.assessment-item {
  font-size: 13px;
  padding: 3px 0;
}

.assessment-item .q { color: var(--gcl-text-light); }
.assessment-item .a { font-weight: 500; }

@media (max-width: 900px) {
  .sidebar { width: 100%; }
  .detail-panel { display: none; }
  .detail-info { display: none; }
  .portal-body { flex-direction: column; }
}
