/* ================================================
   Cerebruh Shared Styles
   Used by: chat/index.html, chat/settings.html
   ================================================ */

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

:root {
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-900: #18181b;
  --emerald-500: #22c55e;
}

button, input, textarea { font-family: inherit; }
button { cursor: pointer; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: #fff;
  color: var(--zinc-900);
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--zinc-200);
  flex-shrink: 0;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left img {
  height: 28px;
  width: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.header-left .agent-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--zinc-500);
}

.header-left .agent-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald-500);
  flex-shrink: 0;
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* === Agent Display Name (Lobster) === */
.agent-display-name {
  font-family: 'Lobster', cursive;
  font-size: 2rem;
  color: var(--zinc-900);
  cursor: pointer;
  transition: color 0.15s;
}

.agent-display-name:hover {
  color: var(--zinc-600);
}

.agent-name-input {
  font-family: 'Lobster', cursive;
  font-size: 2rem;
  color: var(--zinc-900);
  border: none;
  border-bottom: 2px solid var(--zinc-300);
  background: transparent;
  text-align: center;
  outline: none;
  width: 200px;
  padding: 0 4px;
}

.agent-name-input:focus {
  border-bottom-color: var(--zinc-600);
}

/* === User Dropdown Menu === */
.user-menu-wrapper {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 10px;
  margin: -4px -10px;
  border-radius: 8px;
  border: none;
  background: none;
  transition: background 0.15s;
}

.user-menu-trigger:hover {
  background: var(--zinc-100);
}

.user-menu-trigger .chevron {
  width: 12px;
  height: 12px;
  color: var(--zinc-400);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.user-menu-trigger.open .chevron {
  transform: rotate(180deg);
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  left: -10px;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  z-index: 100;
  padding: 4px 0;
}

.user-dropdown.open {
  display: block;
  animation: dropdownIn 0.15s ease;
}

.user-dropdown::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 28px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid var(--zinc-200);
  border-top: 1px solid var(--zinc-200);
  transform: rotate(45deg);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--zinc-600);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: var(--zinc-50);
  color: var(--zinc-900);
}

.user-dropdown-item .item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--zinc-100);
  margin: 4px 0;
}

.user-dropdown-item.logout:hover {
  color: #ef4444;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary {
  background: var(--zinc-900);
  color: white;
}

.btn-primary:hover { background: var(--zinc-700); }

.btn-secondary {
  background: white;
  color: var(--zinc-600);
  border: 1px solid var(--zinc-200);
}

.btn-secondary:hover { background: var(--zinc-50); }

.btn:disabled {
  background: var(--zinc-200);
  color: var(--zinc-400);
  cursor: not-allowed;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  white-space: nowrap;
}

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 0;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-header p {
  font-size: 13px;
  color: var(--zinc-400);
  margin-top: 4px;
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--zinc-100);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-footer button {
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel {
  border: 1px solid var(--zinc-200);
  background: white;
  color: var(--zinc-600);
}

.btn-cancel:hover { background: var(--zinc-50); }

.btn-save {
  border: none;
  background: var(--zinc-900);
  color: white;
}

.btn-save:hover { background: var(--zinc-700); }
.btn-save:disabled { background: var(--zinc-200); color: var(--zinc-400); cursor: not-allowed; }

/* === Avatar Upload Modal === */
.drop-zone {
  border: 2px dashed var(--zinc-200);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--zinc-400);
  background: var(--zinc-50);
}

.drop-zone .drop-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.drop-zone .drop-text {
  font-size: 13px;
  color: var(--zinc-400);
}

.drop-zone .drop-text strong {
  color: var(--zinc-600);
}

.avatar-preview {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar-preview.active {
  display: flex;
}

.avatar-preview img {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--zinc-100);
}

.avatar-preview .change-btn {
  font-size: 13px;
  color: var(--zinc-400);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.avatar-preview .change-btn:hover { color: var(--zinc-600); }

.upload-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 8px;
  text-align: center;
}

/* === Toast Notifications === */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  pointer-events: auto;
  animation: toastIn 0.2s ease, toastOut 0.2s ease 2.8s forwards;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.toast.success { background: #22c55e; }
.toast.error { background: #ef4444; }

/* === Nav Menu (header-right) === */
.nav-menu-wrapper {
  position: relative;
}

.nav-menu-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--zinc-400);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-menu-btn:hover {
  background: var(--zinc-100);
  color: var(--zinc-900);
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  z-index: 100;
  padding: 4px 0;
}

.nav-dropdown.open {
  display: block;
  animation: dropdownIn 0.15s ease;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--zinc-600);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s;
}

.nav-dropdown-item:hover {
  background: var(--zinc-50);
  color: var(--zinc-900);
}

.nav-dropdown-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-dropdown-item.active {
  color: var(--zinc-900);
  font-weight: 500;
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes spin {
  to { transform: rotate(360deg); }
}
