/* ============================================
   BASE DESIGN SYSTEM - BLACK & WHITE THEME
   ============================================ */

/* CSS Variables - Single Source of Truth - WHITE THEME */
:root {
  /* Core Colors */
  --color-pure-black: #000000;
  --color-pure-white: #FFFFFF;
  
  /* Light Grayscale Palette for White Theme */
  --color-gray-50: #FAFAFA;   /* Light background surfaces */
  --color-gray-100: #F5F5F5;  /* Elevated surfaces */
  --color-gray-200: #E5E5E5;  /* Light borders */
  --color-gray-300: #D4D4D4;  /* Medium borders */
  --color-gray-400: #A3A3A3;  /* Placeholder text */
  --color-gray-500: #737373;  /* Muted text */
  --color-gray-600: #525252;  /* Secondary text */
  --color-gray-700: #404040;  /* Dark secondary text */
  --color-gray-800: #262626;  /* Near black for contrast */
  --color-gray-900: #171717;  /* Very dark (navigation) */
  --color-gray-950: #0A0A0A;  /* Navigation black */
  
  /* Semantic Colors - White Theme */
  --bg-primary: var(--color-pure-white);
  --bg-secondary: var(--color-gray-50);
  --bg-elevated: var(--color-gray-100);
  --bg-hover: var(--color-gray-200);
  
  --text-primary: var(--color-pure-black);
  --text-secondary: var(--color-gray-600);
  --text-muted: var(--color-gray-500);
  --text-placeholder: var(--color-gray-400);
  
  --border-default: var(--color-gray-200);
  --border-light: var(--color-gray-300);
  --border-focus: var(--color-pure-black);
  
  /* Navigation stays black */
  --nav-bg: var(--color-pure-black);
  --nav-text: var(--color-pure-white);
  --nav-text-secondary: var(--color-gray-400);
  
  /* Typography Scale */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;
  
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  
  /* Shadows (subtle, using black for depth on white) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(0, 0, 0, 0.15);
  
  /* Z-index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-tooltip: 600;
}

/* Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent page scrolling on messages page */
body.messages-page {
  overflow: hidden;
  height: 100vh;
}

/* Base Component Classes */
.btn {
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
}

.btn-primary {
  background: var(--color-pure-black);
  color: var(--color-pure-white);
}

.btn-primary:hover {
  background: var(--color-gray-800);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--color-pure-black);
  border: 1px solid var(--color-pure-black);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

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

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
select,
textarea {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: all var(--transition-base);
  width: 100%;
}

/* ULTRA AGGRESSIVE Mobile Form Optimization */
@media (max-width: 768px) {
  /* MOBILE LOGO ADJUSTMENTS */
  nav img {
    height: 2.5rem !important; /* Slightly smaller on mobile navbar */
  }
  
  .logo-text {
    font-size: 2rem !important; /* text-base for mobile */
  }
  
  /* MOBILE CONTAINER - ZERO PADDING */
  .container {
    padding: 0.125rem !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* MOBILE CARDS - FULL WIDTH */
  .card {
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    padding: var(--space-3) !important;
  }

  /* MOBILE FORM SECTIONS - px-3 py-3 space-y-5 */
  .px-8.py-8 {
    padding: var(--space-3) !important;
  }

  .space-y-9 > * + * {
    margin-top: 1.25rem !important; /* space-y-5 = 20px */
  }

  /* MOBILE FORM INPUTS - 60% SMALLER */
  .input,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  select,
  textarea {
    padding: 0.25rem 0.375rem !important;
    font-size: 0.625rem !important;
    min-height: 1.75rem !important;
    border-radius: 0.25rem !important;
    line-height: 1.1 !important;
  }

  /* MOBILE BUTTONS - 60% SMALLER */
  .btn {
    padding: 0.375rem 0.5rem !important;
    font-size: 0.625rem !important;
    width: 100% !important;
    margin-bottom: 0.25rem !important;
    min-height: 2rem !important;
  }

  /* MOBILE TYPOGRAPHY - 60% SMALLER */
  h1 { font-size: 0.875rem !important; }
  h2 { font-size: 0.75rem !important; }
  h3 { font-size: 0.6875rem !important; }

  .form-label {
    font-size: 0.625rem !important;
    margin-bottom: 0.125rem !important;
  }

  .text-sm {
    font-size: 0.5625rem !important;
  }

  /* MOBILE SPACING - TINY */
  .form-group {
    margin-bottom: 0.75rem !important;
  }

  /* PREVENT OVERFLOW */
  * {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  body, html {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-placeholder);
}

/* Utility Classes */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  background: var(--bg-secondary);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

/* Typography Utilities */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* Avatar Styles */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  border: 1px solid var(--border-default);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: var(--text-sm);
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: var(--text-lg);
}

.avatar-gray-1 {
  background: var(--color-gray-200);
  color: var(--color-pure-black);
  border: 1px solid var(--color-gray-300);
}

.avatar-gray-2 {
  background: var(--color-gray-300);
  color: var(--color-pure-black);
  border: 1px solid var(--color-gray-400);
}

.avatar-gray-3 {
  background: var(--color-gray-100);
  color: var(--color-pure-black);
  border: 1px solid var(--color-gray-300);
}

.avatar-white {
  background: var(--color-pure-white);
  color: var(--color-pure-black);
  border: 1px solid var(--color-gray-300);
}

/* Messages Page Grid Layout Fix - CRITICAL LAYOUT */
.messages-container {
  display: grid !important;
  grid-template-columns: 380px 1fr !important;
  height: calc(100vh - 64px) !important; /* 64px for sticky header height */
  overflow: hidden !important;
  position: relative;
}

.sidebar {
  width: 380px !important;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--border-default);
  background: var(--bg-secondary);
}

.sidebar-header {
  flex-shrink: 0;
  padding: 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-secondary);
}

.conversation-list {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden;
}

.chat-area {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  overflow: hidden !important;
  background: var(--bg-primary);
}

.chat-header {
  flex-shrink: 0;
  height: 70px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.messages-list {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 20px;
  background: var(--bg-primary);
}

.message-input-container {
  flex-shrink: 0;
  padding: 16px 24px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-default);
}

/* Conversation Items */
.conversation-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  transition: background 0.2s;
}

.conversation-item:hover {
  background: var(--bg-elevated);
}

.conversation-item.active {
  background: var(--bg-primary);
  border-left: 3px solid var(--color-pure-black);
  box-shadow: inset 0 0 0 1px var(--border-default);
}

/* Message Bubbles */
.message-sent {
  background: var(--color-pure-black);
  color: var(--color-pure-white);
  border-radius: 18px 18px 4px 18px;
  margin-left: auto;
  max-width: 85%;
  min-width: 80px;
}

.message-received {
  background: var(--bg-elevated);
  color: var(--color-pure-black);
  border: 1px solid var(--border-default);
  border-radius: 18px 18px 18px 4px;
  margin-right: auto;
  max-width: 85%;
  min-width: 80px;
}

.message-bubble {
  padding: 8px 12px;
  margin: 1px 0;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: none;
  white-space: normal;
  min-width: 0;
  line-height: 1.2;
  text-align: left;
  box-sizing: border-box;
}

.message-bubble p {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.2 !important;
  white-space: normal !important;
  text-align: left !important;
  box-sizing: border-box !important;
}

/* Active Navigation State */
.nav-active {
  color: var(--color-pure-white) !important;
  border-bottom: 2px solid var(--color-pure-white);
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-base);
  padding: var(--space-2) var(--space-3);
}

.nav-link:hover {
  color: var(--color-pure-white);
}

/* Form Styles */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

/* Badge Styles */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.badge-white {
  background: var(--color-pure-white);
  color: var(--color-pure-black);
  border: none;
}

/* Table Styles */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
}

.table th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--border-default);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  background: var(--bg-primary);
}

.table tr:hover td {
  background: var(--bg-hover);
}

/* Modal/Overlay Styles */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Remove all neon/lime colors */
.lime,
.lime-text,
.lime-glow,
.lime-border,
.bg-lime,
.text-lime,
.border-lime,
.ring-lime,
.focus\:ring-lime,
.hover\:text-lime,
.hover\:border-lime,
.hover\:bg-lime,
.hover\:bg-lime-light,
.bg-lime-light,
.bg-lime-dark {
  /* Reset all lime/neon colors to grayscale */
  background-color: var(--color-pure-white) !important;
  color: var(--color-pure-black) !important;
  border-color: var(--color-pure-white) !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

/* Fix specific elements */
.logo-accent {
  color: var(--color-pure-white) !important;
  text-shadow: none !important;
}

/* Animation Classes */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(10px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.fade-in {
  animation: fadeIn var(--transition-slow);
}

/* Mobile Navigation Menu Fix */
@media (max-width: 768px) {
  #mobile-menu {
    display: none !important;
    position: relative;
    z-index: 9999 !important;
    width: 100%;
    background-color: #000000 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.05) !important;
  }
  
  #mobile-menu:not(.hidden) {
    display: block !important;
  }
  
  #mobile-menu a {
    color: #d1d5db !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.375rem !important;
    transition: all 0.2s !important;
  }
  
  #mobile-menu a:hover {
    color: #ffffff !important;
    background-color: #374151 !important;
  }
  
  /* Invites page specific fixes */
  .flex.items-center.justify-between {
    align-items: flex-start !important;
  }
  
  .flex.items-center.space-x-4 {
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
  
  .flex.items-center.space-x-3 {
    align-items: center !important;
    gap: 0.5rem !important;
  }
  
  .flex.items-center.space-x-2 {
    align-items: center !important;
    gap: 0.25rem !important;
  }
}

/* Mobile Messaging Support */
@media (max-width: 768px) {
  /* MESSAGING PAGE SPECIFIC OVERRIDES */
  body.messages-page {
    overflow: hidden !important;
    height: 100vh !important;
  }
  
  body.messages-page .container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  
  /* MESSAGE BUBBLE STYLES */
  .message-sent {
    background: black !important;
    color: white !important;
    margin-left: auto !important;
    border-radius: 1rem 1rem 0.25rem 1rem !important;
  }
  
  .message-received {
    background: #E5E5EA !important;
    color: black !important;
    margin-right: auto !important;
    border-radius: 1rem 1rem 1rem 0.25rem !important;
  }
  
  /* AVATAR COLOR CLASSES */
  .avatar-white {
    background: white !important;
    color: black !important;
    border: 1px solid #e5e7eb !important;
  }
  
  .avatar-gray-1 {
    background: #f3f4f6 !important;
    color: #374151 !important;
  }
  
  .avatar-gray-2 {
    background: #e5e7eb !important;
    color: #1f2937 !important;
  }
  
  .avatar-gray-3 {
    background: #d1d5db !important;
    color: #111827 !important;
  }
  
  /* RESPONSIVE DESIGN FALLBACK */
  .messages-container {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none;
  }
  
  .sidebar.mobile-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
  }
  
  .chat-area {
    display: flex;
  }
}

/* Loading State */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-gray-600);
  border-top-color: var(--color-pure-white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Special Effects */
.white-glow {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}

.white-glow:hover {
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}