/**
 * NullLink Pulse Theme
 * Modern, clean design system inspired by the Pulse messaging reference
 * Version: 1.0
 */

/* ================================
   FONTS
   ================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ================================
   CSS CUSTOM PROPERTIES
   ================================ */
:root {
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Border Radius */
  --radius: 1rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-3xl: calc(var(--radius) + 12px);
  --radius-full: 9999px;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  
  /* Light Theme Colors (default) - Darker text for readability */
  --background: #f8fafb;
  --foreground: #1f2937;
  
  --panel: #ffffff;
  --panel-foreground: #1f2937;
  
  --card: #ffffff;
  --card-foreground: #1f2937;
  
  --primary: #0d9488;
  --primary-foreground: #ffffff;
  --primary-hover: #0f766e;
  
  --secondary: #f3f4f6;
  --secondary-foreground: #1f2937;
  
  --muted: #f9fafb;
  --muted-foreground: #374151;
  
  --accent: #f0fdfa;
  --accent-foreground: #0f766e;
  
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  
  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #0d9488;
  
  /* Chat bubbles */
  --bubble-out: #ccfbf1;
  --bubble-out-foreground: #134e4a;
  --bubble-in: #ffffff;
  --bubble-in-foreground: #1f2937;
  
  /* Status */
  --online: #22c55e;
  --offline: #9ca3af;
  --away: #f59e0b;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --shadow-panel: 0 20px 60px -25px rgba(0, 0, 0, 0.15);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* Dark Theme */
.dark, 
[data-theme="dark"],
html.dark-mode {
  --background: oklch(0.19 0.02 200);
  --foreground: oklch(0.95 0.008 180);
  
  --panel: oklch(0.23 0.022 200);
  --panel-foreground: oklch(0.95 0.008 180);
  
  --card: oklch(0.24 0.022 200);
  --card-foreground: oklch(0.95 0.008 180);
  
  --primary: oklch(0.7 0.12 175);
  --primary-foreground: oklch(0.18 0.03 195);
  --primary-hover: oklch(0.75 0.13 175);
  
  --secondary: oklch(0.28 0.025 200);
  --secondary-foreground: oklch(0.95 0.008 180);
  
  --muted: oklch(0.28 0.025 200);
  --muted-foreground: oklch(0.68 0.02 190);
  
  --accent: oklch(0.32 0.04 185);
  --accent-foreground: oklch(0.95 0.008 180);
  
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 14%);
  --ring: oklch(0.7 0.12 175);
  
  --bubble-out: oklch(0.42 0.08 172);
  --bubble-out-foreground: oklch(0.97 0.01 175);
  --bubble-in: oklch(0.28 0.025 200);
  --bubble-in-foreground: oklch(0.95 0.008 180);
  
  --online: oklch(0.75 0.17 150);
  
  --shadow-panel: 0 20px 60px -25px oklch(0 0 0 / 0.6);
}

/* ================================
   BASE STYLES
   ================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ================================
   TYPOGRAPHY
   ================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--foreground);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  color: var(--muted-foreground);
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* ================================
   LAYOUT UTILITIES
   ================================ */
.pulse-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.pulse-flex {
  display: flex;
}

.pulse-flex-col {
  flex-direction: column;
}

.pulse-flex-1 {
  flex: 1;
}

.pulse-items-center {
  align-items: center;
}

.pulse-justify-center {
  justify-content: center;
}

.pulse-justify-between {
  justify-content: space-between;
}

.pulse-gap-2 { gap: var(--space-2); }
.pulse-gap-3 { gap: var(--space-3); }
.pulse-gap-4 { gap: var(--space-4); }
.pulse-gap-6 { gap: var(--space-6); }

/* ================================
   BUTTONS
   ================================ */
.pulse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.pulse-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pulse-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.pulse-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px oklch(0.55 0.11 185 / 0.3);
}

.pulse-btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.pulse-btn-secondary:hover:not(:disabled) {
  background: var(--accent);
}

.pulse-btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.pulse-btn-ghost:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-foreground);
}

.pulse-btn-danger {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.pulse-btn-icon {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: var(--radius-full);
}

.pulse-btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8rem;
}

.pulse-btn-lg {
  padding: 1rem 1.75rem;
  font-size: 1rem;
}

/* ================================
   INPUTS
   ================================ */
.pulse-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  background: var(--secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-2xl);
  color: var(--foreground);
  outline: none;
  transition: all var(--transition-fast);
}

.pulse-input::placeholder {
  color: var(--muted-foreground);
}

.pulse-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px oklch(0.55 0.11 185 / 0.15);
}

.pulse-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.pulse-input-group .pulse-input {
  padding-left: 2.75rem;
}

.pulse-input-group .pulse-input-icon {
  position: absolute;
  left: 1rem;
  color: var(--muted-foreground);
  pointer-events: none;
}

.pulse-textarea {
  min-height: 6rem;
  resize: vertical;
}

.pulse-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
}

/* ================================
   CARDS
   ================================ */
.pulse-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.pulse-card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.pulse-card-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.pulse-card-body {
  padding: var(--space-5) var(--space-6);
}

.pulse-card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--secondary);
}

/* ================================
   AVATARS
   ================================ */
.pulse-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.pulse-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pulse-avatar-sm {
  width: 36px;
  height: 36px;
  font-size: 0.8rem;
}

.pulse-avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.25rem;
}

.pulse-avatar-online::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: var(--online);
  border: 2px solid var(--panel);
  border-radius: var(--radius-full);
}

/* ================================
   BADGES
   ================================ */
.pulse-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-foreground);
}

.pulse-badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.pulse-badge-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

/* ================================
   CHAT BUBBLES
   ================================ */
.pulse-message {
  max-width: 68%;
  padding: 0.625rem 1rem;
  border-radius: var(--radius-2xl);
  font-size: 0.9375rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}

.pulse-message-out {
  background: var(--bubble-out);
  color: var(--bubble-out-foreground);
  border-bottom-right-radius: var(--radius-sm);
  margin-left: auto;
}

.pulse-message-in {
  background: var(--bubble-in);
  color: var(--bubble-in-foreground);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

.pulse-message-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.7;
}

.pulse-message-read {
  display: inline-flex;
}

/* ================================
   NAVIGATION
   ================================ */
.pulse-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.pulse-nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  text-decoration: none;
}

.pulse-nav-logo svg {
  width: 32px;
  height: 32px;
}

.pulse-nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-8);
}

.pulse-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  border-radius: var(--radius-xl);
  transition: all var(--transition-fast);
}

.pulse-nav-link:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.pulse-nav-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.pulse-nav-link-icon {
  font-size: 1.125rem;
}

.pulse-nav-spacer {
  flex: 1;
}

.pulse-nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ================================
   SIDEBAR RAIL
   ================================ */
.pulse-rail {
  width: 64px;
  background: var(--secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-5) 0;
  gap: var(--space-2);
}

.pulse-rail-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xl);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pulse-rail-item:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.pulse-rail-item.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ================================
   LISTS
   ================================ */
.pulse-list {
  display: flex;
  flex-direction: column;
}

.pulse-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2xl);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pulse-list-item:hover {
  background: var(--secondary);
}

.pulse-list-item.active {
  background: var(--accent);
}

.pulse-list-item-content {
  flex: 1;
  min-width: 0;
}

.pulse-list-item-title {
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pulse-list-item-subtitle {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pulse-list-item-meta {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* ================================
   SCROLLBAR
   ================================ */
.pulse-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.pulse-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.pulse-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.pulse-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

.pulse-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* ================================
   CHAT CANVAS BACKGROUND
   ================================ */
.pulse-chat-canvas {
  background-color: var(--background);
  background-image:
    radial-gradient(oklch(0.55 0.11 185 / 0.07) 1px, transparent 1px),
    radial-gradient(oklch(0.55 0.11 185 / 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}

/* ================================
   FORMS
   ================================ */
.pulse-form-group {
  margin-bottom: var(--space-5);
}

.pulse-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.pulse-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.pulse-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ================================
   TABS
   ================================ */
.pulse-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--secondary);
  border-radius: var(--radius-xl);
}

.pulse-tab {
  flex: 1;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pulse-tab:hover {
  color: var(--foreground);
}

.pulse-tab.active {
  background: var(--panel);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

/* ================================
   TABLES
   ================================ */
.pulse-table {
  width: 100%;
  border-collapse: collapse;
}

.pulse-table th,
.pulse-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.pulse-table th {
  font-weight: 600;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pulse-table tbody tr:hover {
  background: var(--secondary);
}

/* ================================
   MODALS
   ================================ */
.pulse-modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: var(--space-6);
}

.pulse-modal {
  background: var(--panel);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-panel);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.pulse-modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pulse-modal-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.pulse-modal-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pulse-modal-close:hover {
  background: var(--accent);
  color: var(--foreground);
}

.pulse-modal-body {
  padding: var(--space-6);
}

.pulse-modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ================================
   ALERTS
   ================================ */
.pulse-alert {
  padding: var(--space-4);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.pulse-alert-info {
  background: oklch(0.9 0.05 220);
  color: oklch(0.35 0.1 220);
}

.pulse-alert-success {
  background: oklch(0.9 0.05 150);
  color: oklch(0.35 0.1 150);
}

.pulse-alert-warning {
  background: oklch(0.9 0.08 85);
  color: oklch(0.4 0.12 85);
}

.pulse-alert-error {
  background: oklch(0.9 0.08 25);
  color: oklch(0.4 0.15 25);
}

/* ================================
   LOADING
   ================================ */
.pulse-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: pulse-spin 0.8s linear infinite;
}

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

.pulse-skeleton {
  background: linear-gradient(90deg, var(--secondary) 25%, var(--accent) 50%, var(--secondary) 75%);
  background-size: 200% 100%;
  animation: pulse-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes pulse-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ================================
   RESPONSIVE UTILITIES
   ================================ */
.pulse-hidden { display: none !important; }

@media (min-width: 640px) {
  .pulse-sm\:flex { display: flex !important; }
  .pulse-sm\:hidden { display: none !important; }
}

@media (min-width: 768px) {
  .pulse-md\:flex { display: flex !important; }
  .pulse-md\:hidden { display: none !important; }
}

@media (min-width: 1024px) {
  .pulse-lg\:flex { display: flex !important; }
  .pulse-lg\:hidden { display: none !important; }
}

/* ================================
   ACCESSIBILITY
   ================================ */
.pulse-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ================================
   PAGE LAYOUTS
   ================================ */
.pulse-page {
  min-height: 100vh;
  padding-top: 64px; /* nav height */
}

.pulse-page-header {
  padding: var(--space-8) 0;
  text-align: center;
}

.pulse-page-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: var(--space-2);
}

.pulse-page-subtitle {
  color: var(--muted-foreground);
  font-size: 1.125rem;
}

/* Two-panel layout (sidebar + main) */
.pulse-layout-split {
  display: flex;
  height: calc(100vh - 64px);
}

.pulse-layout-sidebar {
  width: 320px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.pulse-layout-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 768px) {
  .pulse-layout-sidebar {
    width: 100%;
    position: absolute;
    z-index: 100;
  }
  
  .pulse-layout-sidebar.hidden {
    display: none;
  }
}
