:root {
  --bg-color: #f1f5f9;
  --sidebar-bg: #1e293b;
  --text-main: #334155;
  --text-light: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --border: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: var(--bg-color); color: var(--text-main); }

.hidden { display: none !important; }

/* Login Screen */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
#dashboard-screen { display: flex; align-items: stretch; justify-content: flex-start; }

.login-box {
  background: white; padding: 3rem; border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1); text-align: center; width: 400px;
}
.login-box h2 { margin-bottom: 0.5rem; color: #0f172a; }
.login-box p { color: var(--text-light); margin-bottom: 2rem; }
.login-box input {
  width: 100%; padding: 0.75rem; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 1rem; font-size: 1rem;
}
.login-box button {
  width: 100%; padding: 0.75rem; background: var(--primary); color: white;
  border: none; border-radius: 6px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.error-text { color: var(--danger); margin-top: 1rem; font-size: 0.9rem; min-height: 20px; }

/* Dashboard */
.sidebar {
  width: 250px; background: var(--sidebar-bg); color: white; padding: 2rem 0;
}
.sidebar .logo { font-size: 1.5rem; font-weight: 700; padding: 0 2rem 2rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar .logo span { color: var(--primary); }
.nav-menu { list-style: none; margin-top: 2rem; }
.nav-menu li { padding: 1rem 2rem; cursor: pointer; color: #cbd5e1; transition: 0.2s; }
.nav-menu li:hover, .nav-menu li.active { background: rgba(255,255,255,0.05); color: white; border-left: 4px solid var(--primary); }

.main-content { flex: 1; padding: 2rem 4rem; overflow-y: auto; }
.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.top-header h2 { color: #0f172a; }

.primary-btn {
  background: var(--primary); color: white; border: none; padding: 0.6rem 1.2rem;
  border-radius: 6px; cursor: pointer; font-weight: 500; transition: 0.2s;
}
.primary-btn:hover { background: var(--primary-hover); }

/* Table */
.table-container { background: white; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.data-table th { background: #f8fafc; font-weight: 600; color: #475569; }
.action-btn { background: none; border: none; cursor: pointer; color: var(--danger); font-weight: 500; }
.action-btn:hover { text-decoration: underline; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; width: 500px; border-radius: 8px; overflow: hidden; }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.form-group input, .form-group textarea { width: 100%; padding: 0.75rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.modal-footer { padding: 1.5rem; border-top: 1px solid var(--border); text-align: right; background: #f8fafc; }

/* Chat Management */
.chat-container { display: flex; height: calc(100vh - 150px); background: white; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); overflow: hidden; }
.chat-sidebar { width: 300px; border-right: 1px solid var(--border); background: #f8fafc; display: flex; flex-direction: column; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-list-item { padding: 1rem; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; transition: 0.2s; }
.chat-list-item:hover, .chat-list-item.active { background: white; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; margin-right: 1rem; flex-shrink: 0; }
.chat-info { flex: 1; overflow: hidden; }
.chat-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-preview { font-size: 0.85rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-main { flex: 1; display: flex; flex-direction: column; background: white; }
.chat-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-light); background: #f8fafc; }

.chat-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 1.1rem; background: #f8fafc; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.msg-wrapper { display: flex; max-width: 80%; }
.msg-wrapper.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-wrapper.theirs { align-self: flex-start; }
.msg-bubble { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.95rem; line-height: 1.4; word-break: break-word; }
.msg-wrapper.mine .msg-bubble { background: var(--primary); color: white; border-top-right-radius: 0; }
.msg-wrapper.theirs .msg-bubble { background: #f1f5f9; color: var(--text-main); border-top-left-radius: 0; }

.chat-input-area { padding: 1rem; border-top: 1px solid var(--border); display: flex; gap: 1rem; background: white; }
.chat-input-area textarea { flex: 1; height: 60px; padding: 0.75rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; resize: none; }
.chat-input-area button { align-self: flex-end; }

/* Detail Modal Styles */
.post-title-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s, text-decoration 0.2s;
}
.post-title-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.detail-field {
  margin-bottom: 1.25rem;
}
.detail-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.detail-value {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.5;
}
.detail-value.font-semibold {
  font-weight: 600;
  font-size: 1.15rem;
  color: #0f172a;
}
.desc-value {
  white-space: pre-wrap;
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
}
.detail-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.tag-badge {
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
}

