/* ================================================
   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-800: #27272a;
  --zinc-900: #18181b;
  --zinc-950: #09090b;
  --emerald-500: #22c55e;

  /* Semantic colors (light mode default) */
  --bg-primary: #ffffff;
  --bg-secondary: var(--zinc-50);
  --bg-tertiary: var(--zinc-100);
  --bg-hover: var(--zinc-100);
  --text-primary: var(--zinc-900);
  --text-secondary: var(--zinc-600);
  --text-tertiary: var(--zinc-500);
  --text-muted: var(--zinc-400);
  --border-primary: var(--zinc-200);
  --border-secondary: var(--zinc-100);
  --shadow-color: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: var(--zinc-900);
  --bg-secondary: var(--zinc-800);
  --bg-tertiary: var(--zinc-700);
  --bg-hover: var(--zinc-700);
  --text-primary: var(--zinc-50);
  --text-secondary: var(--zinc-300);
  --text-tertiary: var(--zinc-400);
  --text-muted: var(--zinc-500);
  --border-primary: var(--zinc-700);
  --border-secondary: var(--zinc-800);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-primary);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

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

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

.header-center .agent-display-name {
  font-family: 'Lobster', cursive;
  font-weight: 400;
  font-size: 3rem;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
}

.header-center .agent-display-name:hover {
  color: var(--text-secondary);
}

.header-center .agent-name-input {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 2px 8px;
  outline: none;
  text-align: center;
  width: 160px;
}

.header-center .agent-name-input:focus {
  border-color: var(--text-tertiary);
}

.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-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* === 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(--bg-hover);
}

.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: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  box-shadow: var(--shadow-md), var(--shadow-sm);
  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: var(--bg-primary);
  border-left: 1px solid var(--border-primary);
  border-top: 1px solid var(--border-primary);
  transform: rotate(45deg);
}

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

.user-dropdown-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

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

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

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

/* === Nav Dropdown Menu (Right side menu) === */
.nav-menu-wrapper {
  position: relative;
}

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

.nav-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.nav-menu-btn.open {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 180px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  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::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 12px;
  width: 10px;
  height: 10px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-primary);
  border-top: 1px solid var(--border-primary);
  transform: rotate(45deg);
}

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

.nav-dropdown-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.nav-dropdown-item.active {
  color: var(--text-primary);
  font-weight: 500;
  background-color: transparent;
}
.nav-dropdown-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-dropdown-divider {
  height: 1px;
  background: var(--border-secondary);
  margin: 4px 0;
}

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

.nav-dropdown-version {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-secondary);
  margin-top: 4px;
  font-family: monospace;
  cursor: default;
}

/* === Usage Meter === */
.usage-meter {
  display: flex;
  align-items: center;
  text-decoration: none;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.usage-meter:hover {
  background: var(--bg-hover);
}

.usage-bar {
  width: 48px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s, background 0.3s;
  background: var(--text-muted);
}

.usage-bar-fill.green {
  background: var(--emerald-500);
}

.usage-bar-fill.yellow {
  background: #eab308;
}

.usage-bar-fill.red {
  background: #ef4444;
}

/* === Sound Toggle === */
.sound-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: all 0.15s;
}

.sound-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.sound-toggle.sound-off {
  color: var(--text-muted);
  opacity: 0.6;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: 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: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

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

.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: var(--bg-primary);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px var(--shadow-color);
  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(--text-muted);
  margin-top: 4px;
}

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-secondary);
  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(--border-primary);
  background: var(--bg-primary);
  color: var(--text-secondary);
}

.btn-cancel:hover { background: var(--bg-secondary); }

.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(--border-primary);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--text-muted);
  background: var(--bg-secondary);
}

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

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

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

.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(--border-primary);
}

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

.avatar-preview .change-btn:hover { color: var(--text-secondary); }

.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; }

/* === 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); }
}
