/* =====================================================
   BRAND CUSTOMIZATION
   ===================================================== */
:root {
  --brand-primary: #38bdf8;
  --brand-primary-hover: #0ea5e9;
  --brand-secondary: #8b5cf6;
  --font-display: 'Nunito Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Status Colors - Clients */
  --status-prospect: #6b7280;
  --status-qualifying: #f59e0b;
  --status-proposal: #3b82f6;
  --status-active: #10b981;
  --status-completed: #06b6d4;
  --status-churned: #ef4444;

  /* Status Colors - Projects */
  --status-planned: #6b7280;
  --status-in-progress: #38bdf8;
  --status-in_progress: #38bdf8;
  --status-review: #f59e0b;
  --status-delivered: #10b981;
  --status-on-hold: #8b5cf6;
  --status-on_hold: #8b5cf6;
  --status-cancelled: #ef4444;

  /* Status Colors - Deliverables */
  --status-pending: #6b7280;
  --status-blocked: #ef4444;

  /* Type badges */
  --status-full_build: #3b82f6;
  --status-prototype: #8b5cf6;
  --status-maintenance: #f59e0b;
  --status-consulting: #10b981;
  --status-other: #6b7280;
}

/* =====================================================
   SPACING SYSTEM
   ===================================================== */
:root {
  --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;
  --space-20: 80px;
}

/* =====================================================
   TYPE SCALE
   ===================================================== */
:root {
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
}

/* =====================================================
   DARK THEME (DEFAULT)
   ===================================================== */
:root,
[data-theme="dark"] {
  --bg-primary: #0a0e1a;
  --bg-secondary: #151924;
  --bg-tertiary: #1e2436;
  --text-primary: #e8eaed;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #2d3548;
  --border-hover: #3d4558;
  --shadow: rgba(0, 0, 0, 0.3);
  --accent: var(--brand-primary);
  --accent-hover: var(--brand-primary-hover);
}

/* =====================================================
   LIGHT THEME
   ===================================================== */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow: rgba(0, 0, 0, 0.1);
  --accent: var(--brand-primary-hover);
  --accent-hover: #0284c7;
}

/* =====================================================
   GLOBAL RESET & BASE STYLES
   ===================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

/* =====================================================
   TYPOGRAPHY
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-3);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

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

/* =====================================================
   NAVIGATION & HEADER
   ===================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: var(--text-3xl);
  margin: 0;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.5;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

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

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

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

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: var(--space-1);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-xl);
  line-height: 1;
  transition: color 0.2s ease;
}

.btn-icon:hover {
  color: var(--text-primary);
}

/* =====================================================
   THEME TOGGLE
   ===================================================== */
.theme-toggle {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.2s ease;
  font-size: var(--text-lg);
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.theme-icon::before {
  content: '☀';
}

[data-theme="light"] .theme-icon::before {
  content: '☾';
}

/* =====================================================
   CARDS & GRIDS
   ===================================================== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-5);
  box-shadow: 0 1px 3px var(--shadow);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--text-primary);
}

.quick-nav {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.nav-link {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.clients-grid,
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.client-card,
.project-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-5);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px var(--shadow);
}

.client-card:hover,
.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.client-header,
.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-3);
}

.client-header h3,
.project-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
}

.client-info,
.project-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.client-info p,
.project-info p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.contact {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.date {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.client-name {
  font-weight: 500;
  color: var(--text-primary);
}

.detail-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-6);
  margin-bottom: var(--space-8);
  box-shadow: 0 1px 3px var(--shadow);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.detail-header h1 {
  margin: 0;
  font-size: var(--text-3xl);
}

.badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.detail-item.detail-full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: var(--text-base);
  color: var(--text-primary);
}

.detail-notes {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s ease;
}

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

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

textarea {
  resize: vertical;
  min-height: 80px;
}

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

.form-error {
  color: #ef4444;
  font-size: var(--text-sm);
  margin-top: var(--space-2);
  min-height: var(--space-5);
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 12px;
  white-space: nowrap;
}

.badge-prospect { background: var(--status-prospect); color: white; }
.badge-qualifying { background: var(--status-qualifying); color: white; }
.badge-proposal { background: var(--status-proposal); color: white; }
.badge-active { background: var(--status-active); color: white; }
.badge-completed { background: var(--status-completed); color: white; }
.badge-churned { background: var(--status-churned); color: white; }

.badge-planned { background: var(--status-planned); color: white; }
.badge-in_progress,
.badge-in-progress { background: var(--status-in-progress); color: white; }
.badge-review { background: var(--status-review); color: white; }
.badge-delivered { background: var(--status-delivered); color: white; }
.badge-on_hold,
.badge-on-hold { background: var(--status-on-hold); color: white; }
.badge-cancelled { background: var(--status-cancelled); color: white; }

.badge-pending { background: var(--status-pending); color: white; }
.badge-delivered { background: var(--status-delivered); color: white; }
.badge-blocked { background: var(--status-blocked); color: white; }

.badge-full_build { background: var(--status-full_build); color: white; }
.badge-prototype { background: var(--status-prototype); color: white; }
.badge-maintenance { background: var(--status-maintenance); color: white; }
.badge-consulting { background: var(--status-consulting); color: white; }
.badge-other { background: var(--status-other); color: white; }

/* =====================================================
   LOADING & EMPTY STATES
   ===================================================== */
.loading-state,
.empty-state,
.error-state {
  text-align: center;
  padding: var(--space-12);
  color: var(--text-muted);
}

.error-state {
  color: #ef4444;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: var(--space-4);
}

.modal-overlay.show {
  opacity: 1;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-form h2 {
  margin-top: 0;
  margin-bottom: var(--space-6);
}

/* =====================================================
   LOGIN
   ===================================================== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 20px var(--shadow);
}

.login-form h1 {
  text-align: center;
  margin-bottom: var(--space-2);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}

/* =====================================================
   SECTIONS
   ===================================================== */
.section {
  margin-bottom: var(--space-8);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.section-header h2 {
  margin: 0;
}

/* =====================================================
   ACTIVITY FEED
   ===================================================== */
.activity-feed {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-5);
  box-shadow: 0 1px 3px var(--shadow);
}

.activity-feed h2 {
  margin-top: 0;
  margin-bottom: var(--space-4);
  font-size: var(--text-xl);
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

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

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.activity-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* =====================================================
   BUDGET PROGRESS
   ===================================================== */
.budget-section {
  margin-bottom: var(--space-5);
}

.budget-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

.budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  transition: width 0.3s ease;
}

.budget-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* =====================================================
   DELIVERABLES
   ===================================================== */
.deliverables-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.deliverable-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.2s ease;
}

.deliverable-item:hover {
  border-color: var(--border-hover);
}

.deliverable-content {
  flex: 1;
}

.deliverable-content h4 {
  margin: 0 0 var(--space-2) 0;
  font-size: var(--text-base);
  font-weight: 600;
}

.deliverable-notes {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.deliverable-meta {
  display: flex;
  gap: var(--space-4);
}

.deliverable-actions {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.deliverable-status {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.deliverable-status:hover {
  opacity: 0.8;
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 20px var(--shadow);
  z-index: 3000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  font-size: var(--text-sm);
  font-weight: 500;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left: 4px solid var(--status-active);
}

.toast-error {
  border-left: 4px solid var(--status-churned);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  .container {
    padding: var(--space-4);
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .stat-cards {
    grid-template-columns: 1fr;
  }

  .clients-grid,
  .projects-grid {
    grid-template-columns: 1fr;
  }

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .quick-nav {
    flex-direction: column;
  }

  .modal-content {
    max-height: 95vh;
  }

  .deliverable-item {
    flex-direction: column;
    gap: var(--space-3);
  }

  .deliverable-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  :root {
    font-size: 14px;
  }

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

  .theme-toggle {
    top: var(--space-3);
    right: var(--space-3);
    width: 36px;
    height: 36px;
  }
}
