/* TBEX - The Brick Exchange
   Starling-inspired clean banking design */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  /* Primary Colors */
  --primary: #0D9488;        /* Teal - trust, stability */
  --primary-dark: #0F766E;
  --primary-light: #14B8A6;
  --primary-50: #F0FDFA;
  --primary-100: #CCFBF1;

  /* Neutral Colors */
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Semantic Colors */
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;

  /* 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;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

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

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

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

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

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

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

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: var(--space-6) 0;
}

/* ============================================
   NAVIGATION
   ============================================ */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--gray-900);
}

.navbar-brand svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  color: var(--gray-600);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

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

.navbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

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

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

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

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* Stat Cards */
.stat-card {
  padding: var(--space-5);
}

.stat-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-top: var(--space-1);
}

.stat-sublabel {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

.stat-card.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
}

.stat-card.primary .stat-label,
.stat-card.primary .stat-value,
.stat-card.primary .stat-sublabel {
  color: var(--white);
}

.stat-card.primary .stat-label {
  opacity: 0.8;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--gray-900);
}

.btn-danger {
  background: var(--error);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: #DC2626;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-base);
}

.btn-block {
  width: 100%;
}

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

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  background: var(--white);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.form-input::placeholder {
  color: var(--gray-400);
}

.form-input:disabled {
  background: var(--gray-100);
  cursor: not-allowed;
}

.form-input.error {
  border-color: var(--error);
}

.form-error {
  font-size: var(--font-size-sm);
  color: var(--error);
  margin-top: var(--space-2);
}

.form-hint {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-top: var(--space-2);
}

/* Range Slider */
.form-range {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  outline: none;
  -webkit-appearance: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-md);
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-md);
}

/* ============================================
   BADGES & TAGS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-primary {
  background: var(--primary-100);
  color: var(--primary-dark);
}

.badge-success {
  background: var(--success-light);
  color: #047857;
}

.badge-warning {
  background: var(--warning-light);
  color: #B45309;
}

.badge-error {
  background: var(--error-light);
  color: #B91C1C;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* Status badges for projects */
.status-draft { background: var(--gray-100); color: var(--gray-600); }
.status-funding { background: var(--info-light); color: #1D4ED8; }
.status-funded { background: var(--primary-100); color: var(--primary-dark); }
.status-in_progress { background: var(--warning-light); color: #B45309; }
.status-for_sale { background: #FDF4FF; color: #A21CAF; }
.status-sold { background: #ECFDF5; color: #047857; }
.status-completed { background: var(--success-light); color: #047857; }
.status-cancelled { background: var(--error-light); color: #B91C1C; }

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress {
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar.success {
  background: var(--success);
}

/* ============================================
   TABLES
   ============================================ */
.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.table td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

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

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  padding: var(--space-4);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-logo svg {
  width: 48px;
  height: 48px;
  color: var(--primary);
  margin: 0 auto var(--space-4);
}

.auth-logo h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--gray-900);
}

.auth-logo p {
  color: var(--gray-500);
  margin-top: var(--space-2);
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-6);
  color: var(--gray-500);
}

.auth-footer a {
  font-weight: 500;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 2fr 1fr;
  }
}

/* ============================================
   PROJECT CARDS
   ============================================ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-6);
}

.project-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.project-card-image {
  height: 180px;
  background: var(--gray-200);
  background-size: cover;
  background-position: center;
  position: relative;
}

.project-card-badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
}

.project-card-return {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: rgba(0,0,0,0.7);
  color: var(--white);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

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

.project-card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
}

.project-card-location {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-bottom: var(--space-4);
}

.project-card-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.project-card-stat {
  text-align: center;
}

.project-card-stat-value {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
}

.project-card-stat-label {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
}

.project-card-progress {
  margin-bottom: var(--space-4);
}

.project-card-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-2);
}

.project-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--gray-500);
}

/* ============================================
   INVESTMENT LIST
   ============================================ */
.investment-list {
  display: flex;
  flex-direction: column;
}

.investment-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition-fast);
}

.investment-item:last-child {
  border-bottom: none;
}

.investment-item:hover {
  background: var(--gray-50);
}

.investment-image {
  width: 80px;
  height: 60px;
  border-radius: var(--radius-md);
  background: var(--gray-200);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.investment-details {
  flex: 1;
  min-width: 0;
}

.investment-title {
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.investment-meta {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
}

.investment-update {
  font-size: var(--font-size-sm);
  color: var(--gray-600);
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: var(--gray-50);
  border-radius: var(--radius-md);
}

.investment-stats {
  text-align: right;
  flex-shrink: 0;
}

.investment-amount {
  font-weight: 600;
  color: var(--gray-900);
}

.investment-return {
  font-size: var(--font-size-sm);
  color: var(--success);
}

/* ============================================
   ACTIVITY FEED
   ============================================ */
.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: var(--font-size-sm);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon.deposit { background: var(--success-light); color: var(--success); }
.activity-icon.investment { background: var(--primary-100); color: var(--primary); }
.activity-icon.return { background: var(--success-light); color: var(--success); }

.activity-content {
  flex: 1;
}

.activity-text {
  color: var(--gray-700);
}

.activity-time {
  color: var(--gray-400);
  font-size: var(--font-size-xs);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

.alert-success {
  background: var(--success-light);
  color: #047857;
}

.alert-error {
  background: var(--error-light);
  color: #B91C1C;
}

.alert-warning {
  background: var(--warning-light);
  color: #B45309;
}

.alert-info {
  background: var(--info-light);
  color: #1D4ED8;
}

/* ============================================
   LOADING
   ============================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

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

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--gray-500);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--font-size-lg);
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

/* ============================================
   SOCIAL FUND BANNER
   ============================================ */
.social-banner {
  background: linear-gradient(135deg, #FDF4FF 0%, #FAE8FF 100%);
  border: 1px solid #F0ABFC;
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.social-banner-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.social-banner-icon {
  width: 40px;
  height: 40px;
  background: #A855F7;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
}

.social-banner-text h4 {
  font-weight: 600;
  color: #7E22CE;
}

.social-banner-text p {
  font-size: var(--font-size-sm);
  color: #9333EA;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .navbar-nav {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: var(--space-6);
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: var(--font-size-sm); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
