/* ==========================================================
   OnePage Live Chat — admin dashboard styles
   ========================================================== */
:root {
  --opc-ink: #14201f;
  --opc-primary: #17312f;
  --opc-primary-soft: #e7efee;
  --opc-accent: #3fb37f;
  --opc-bg: #f4f6f5;
  --opc-card: #ffffff;
  --opc-border: #e6eae8;
  --opc-muted: #6b7a78;
  --opc-danger: #d64545;
  --opc-radius: 14px;
  --opc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--opc-font); color: var(--opc-ink); background: var(--opc-bg);
  -webkit-font-smoothing: antialiased;
}
.opc-hidden { display: none !important; }

/* ---------- Auth screens ---------- */
.opc-auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, #1d3d3a, #0d1f1d 65%);
  padding: 24px;
}
.opc-auth-card {
  background: var(--opc-card); border-radius: 20px; padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.opc-auth-brand { text-align: center; margin-bottom: 22px; }
.opc-auth-logo { font-size: 34px; margin-bottom: 6px; }
.opc-auth-brand h1 { font-size: 20px; margin: 0 0 4px; }
.opc-auth-brand p { font-size: 13px; color: var(--opc-muted); margin: 0; }
.opc-auth-error { color: var(--opc-danger); font-size: 12.5px; min-height: 16px; margin: 6px 0 0; }

/* ---------- Shared form bits ---------- */
.opc-field { margin-bottom: 14px; }
.opc-field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--opc-ink); }
.opc-field input, .opc-field textarea {
  width: 100%; border: 1px solid var(--opc-border); border-radius: 10px; padding: 10px 12px;
  font-family: var(--opc-font); font-size: 13.5px; background: #fbfcfc; color: var(--opc-ink);
}
.opc-field input:focus, .opc-field textarea:focus { outline: none; border-color: var(--opc-primary); background: #fff; }
.opc-field-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.opc-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.opc-hint { font-size: 11.5px; color: var(--opc-muted); margin: 6px 0 0; }

.opc-btn-primary {
  background: var(--opc-primary); color: #fff; border: none; border-radius: 10px; padding: 11px 18px;
  font-weight: 700; font-size: 13.5px; cursor: pointer; width: 100%;
}
.opc-btn-primary:hover { opacity: 0.92; }
.opc-btn-ghost {
  background: var(--opc-primary-soft); color: var(--opc-primary); border: none; border-radius: 9px;
  padding: 8px 14px; font-weight: 600; font-size: 12.5px; cursor: pointer;
}
.opc-btn-ghost:hover { background: #dbe6e4; }
.opc-btn-small { padding: 6px 10px; font-size: 12px; }

/* ---------- Dashboard shell ---------- */
.opc-dashboard { display: none; height: 100vh; flex-direction: column; }
.opc-dashboard.opc-active { display: flex; }

.opc-topbar {
  height: 60px; background: var(--opc-card); border-bottom: 1px solid var(--opc-border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; flex-shrink: 0;
}
.opc-topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.opc-topbar-logo { font-size: 20px; }
.opc-topbar-actions { display: flex; gap: 8px; }

.opc-dashboard-body { flex: 1; display: flex; min-height: 0; }

/* ---------- Sidebar ---------- */
.opc-sidebar { width: 320px; background: var(--opc-card); border-right: 1px solid var(--opc-border); display: flex; flex-direction: column; flex-shrink: 0; }
.opc-sidebar-tabs { display: flex; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--opc-border); }
.opc-tab { background: none; border: none; border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--opc-muted); cursor: pointer; }
.opc-tab:hover { background: var(--opc-bg); }
.opc-tab-active { background: var(--opc-primary); color: #fff; }
.opc-convo-list { flex: 1; overflow-y: auto; }

.opc-convo-item {
  display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--opc-border);
  cursor: pointer; align-items: flex-start; position: relative;
}
.opc-convo-item:hover { background: var(--opc-bg); }
.opc-convo-item.opc-active { background: var(--opc-primary-soft); }
.opc-convo-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--opc-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  flex-shrink: 0; position: relative;
}
.opc-online-dot {
  position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--opc-card); background: #c9cdd1;
}
.opc-online-dot.opc-online { background: var(--opc-accent); }
.opc-convo-info { flex: 1; min-width: 0; }
.opc-convo-name-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.opc-convo-name { font-weight: 700; font-size: 13.5px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opc-convo-time { font-size: 10.5px; color: var(--opc-muted); flex-shrink: 0; }
.opc-convo-preview { font-size: 12px; color: var(--opc-muted); margin: 3px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opc-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--opc-accent); position: absolute; top: 14px; right: 12px; }
.opc-empty-list { text-align: center; color: var(--opc-muted); font-size: 13px; padding: 40px 20px; }

/* ---------- Chat main ---------- */
.opc-chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.opc-chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--opc-muted); font-size: 14px; }
.opc-chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.opc-chat-panel-header { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--opc-border); background: var(--opc-card); }
.opc-chat-panel-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--opc-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; position: relative; flex-shrink: 0; }
.opc-chat-panel-info { flex: 1; min-width: 0; }
.opc-chat-panel-info h3 { margin: 0; font-size: 14.5px; }
.opc-chat-panel-info p { margin: 2px 0 0; font-size: 12px; color: var(--opc-muted); }

.opc-chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 4px; background: var(--opc-bg); position: relative; }
.opc-day-divider { text-align: center; font-size: 11px; color: var(--opc-muted); margin: 14px 0 8px; }
.opc-day-divider span { background: var(--opc-border); padding: 4px 12px; border-radius: 999px; }

.opc-msg-group { display: flex; flex-direction: column; max-width: 60%; margin-bottom: 10px; }
.opc-msg-group.opc-mine { align-self: flex-end; align-items: flex-end; }
.opc-msg-group.opc-theirs { align-self: flex-start; align-items: flex-start; }
.opc-msg-group.opc-system { align-self: center; align-items: center; max-width: 90%; }
.opc-msg-bubble { padding: 9px 14px; border-radius: 15px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; margin-bottom: 3px; }
.opc-mine .opc-msg-bubble { background: var(--opc-primary); color: #fff; border-bottom-right-radius: 4px; }
.opc-theirs .opc-msg-bubble { background: #fff; color: var(--opc-ink); border: 1px solid var(--opc-border); border-bottom-left-radius: 4px; }
.opc-system .opc-msg-bubble { background: #fff8d6; border: 1px dashed #e9d98a; color: #7a6300; font-size: 12px; }
.opc-msg-time { font-size: 10.5px; color: var(--opc-muted); padding: 0 4px; }
.opc-msg-attachment-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,0.06); text-decoration: none; color: inherit; font-size: 12.5px; }
.opc-mine .opc-msg-attachment-link { background: rgba(255,255,255,0.2); color: #fff; }
.opc-msg-image { max-width: 220px; max-height: 220px; border-radius: 10px; display: block; object-fit: cover; }

.opc-jump-latest {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  background: var(--opc-primary); color: #fff; border: none; border-radius: 999px; padding: 6px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 20px rgba(0,0,0,0.25); display: none;
}

.opc-chat-composer { border-top: 1px solid var(--opc-border); background: var(--opc-card); padding: 12px 20px; }
.opc-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.opc-composer-row textarea {
  flex: 1; border: 1px solid var(--opc-border); border-radius: 12px; padding: 10px 14px; resize: none;
  max-height: 90px; font-family: var(--opc-font); font-size: 13.5px;
}
.opc-composer-row textarea:focus { outline: none; border-color: var(--opc-primary); }
.opc-icon-btn, .opc-send-btn {
  border: none; width: 40px; height: 40px; border-radius: 10px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; font-size: 16px;
}
.opc-icon-btn { background: var(--opc-bg); }
.opc-icon-btn:hover { background: #e7ebe9; }
.opc-send-btn { background: var(--opc-primary); color: #fff; }
.opc-file-chip { display: none; align-items: center; gap: 6px; background: var(--opc-bg); border-radius: 8px; padding: 5px 9px; font-size: 11.5px; margin-bottom: 8px; }
.opc-file-chip.opc-active { display: inline-flex; }
.opc-file-chip button { background: none; border: none; cursor: pointer; color: var(--opc-danger); font-weight: 700; }

/* ---------- Modals ---------- */
.opc-modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 19, 0.55); display: flex;
  align-items: center; justify-content: center; z-index: 10000; padding: 20px;
}
.opc-modal {
  background: var(--opc-card); border-radius: 16px; width: 100%; max-width: 480px;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
}
.opc-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--opc-border); }
.opc-modal-header h2 { margin: 0; font-size: 16px; }
.opc-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--opc-muted); }
.opc-modal-body { padding: 20px 22px; overflow-y: auto; }
.opc-modal-footer { padding: 16px 22px; border-top: 1px solid var(--opc-border); display: flex; justify-content: flex-end; gap: 8px; }
.opc-modal-footer .opc-btn-primary { width: auto; }

.opc-settings-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.opc-settings-avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; background: var(--opc-bg); border: 2px solid var(--opc-border); }

.opc-code-box {
  width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px;
  border: 1px solid var(--opc-border); border-radius: 10px; padding: 12px; background: #0d1f1d; color: #d7e6e3;
  resize: vertical; margin-bottom: 10px;
}

@media (max-width: 860px) {
  .opc-sidebar { width: 260px; }
  .opc-msg-group { max-width: 80%; }
}
