/* ==========================================================================
   POST BLUEPRINT — main.css
   Global reset, CSS variables, typography, layout, header/nav
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --color-brand-dark:   #0f2340;
  --color-brand-mid:    #1e3a5f;
  --color-brand-light:  #2d5a8e;
  --color-accent:       #c97d2e;
  --color-accent-hover: #b06a20;

  /* Surface */
  --color-bg:           #f1f5f9;
  --color-surface:      #ffffff;
  --color-surface-alt:  #f8fafc;
  --color-border:       #e2e8f0;
  --color-border-dark:  #cbd5e1;

  /* Text */
  --color-text-primary:   #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted:     #94a3b8;
  --color-text-inverse:   #ffffff;

  /* Status */
  --color-success:      #16a34a;
  --color-success-bg:   #dcfce7;
  --color-warning:      #d97706;
  --color-warning-bg:   #fef3c7;
  --color-danger:       #dc2626;
  --color-danger-bg:    #fee2e2;
  --color-info:         #2563eb;
  --color-info-bg:      #dbeafe;

  /* Phase badge colors */
  --phase-early-lead:         #6b7280;
  --phase-early-lead-bg:      #f3f4f6;
  --phase-sales-opp:          #2563eb;
  --phase-sales-opp-bg:       #dbeafe;
  --phase-sold-preprod:       #7c3aed;
  --phase-sold-preprod-bg:    #ede9fe;
  --phase-open-construction:  #16a34a;
  --phase-open-construction-bg: #dcfce7;
  --phase-completed:          #64748b;
  --phase-completed-bg:       #f1f5f9;

  /* Holder badge colors */
  --holder-sales:     #2563eb;
  --holder-sales-bg:  #dbeafe;
  --holder-design:    #ea580c;   /* orange — per BRD */
  --holder-design-bg: #ffedd5;
  --holder-permitting:    #0891b2;
  --holder-permitting-bg: #cffafe;
  --holder-estimating:    #d97706;
  --holder-estimating-bg: #fef3c7;
  --holder-pm:    #16a34a;
  --holder-pm-bg: #dcfce7;

  /* Layout */
  --nav-height:       60px;
  --sidebar-width:    260px;
  --content-max:      1400px;

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', monospace;
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   10px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
  --shadow-md: 0 2px 8px rgb(0 0 0 / 0.10);
  --shadow-lg: 0 4px 20px rgb(0 0 0 / 0.12);

  /* Transition */
  --transition: 150ms ease;
}

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

html {
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--color-brand-light);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

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

ul, ol { list-style: none; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* --------------------------------------------------------------------------
   App shell layout
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  padding: var(--sp-6);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Top navigation
   -------------------------------------------------------------------------- */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--color-brand-dark);
  border-bottom: 1px solid rgba(255 255 255 / 0.08);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-6);
  box-shadow: var(--shadow-md);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo img {
  height: 28px;
  width: auto;
}

.nav-logo-text {
  color: var(--color-text-inverse);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex: 1;
}

.nav-link {
  color: rgba(255 255 255 / 0.75);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255 255 255 / 0.10);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.nav-spacer { flex: 1; }

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

.nav-meeting-btn {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  transition: background var(--transition);
  border: none;
  cursor: pointer;
}
.nav-meeting-btn:hover { background: var(--color-accent-hover); }

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: rgba(255 255 255 / 0.80);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-md);
  transition: background var(--transition);
}
.nav-user:hover { background: rgba(255 255 255 / 0.10); }

/* --------------------------------------------------------------------------
   Page sections
   -------------------------------------------------------------------------- */
.page-header {
  margin-bottom: var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--sp-1);
}

/* --------------------------------------------------------------------------
   Utility classes
   -------------------------------------------------------------------------- */
.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;
}

.text-muted    { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-sm       { font-size: var(--text-sm); }
.text-xs       { font-size: var(--text-xs); }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-2         { gap: var(--sp-2); }
.gap-3         { gap: var(--sp-3); }
.gap-4         { gap: var(--sp-4); }

.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }

/* --------------------------------------------------------------------------
   Loading / error states
   -------------------------------------------------------------------------- */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-brand-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--sp-12) auto;
}

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

.error-message {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  color: var(--color-danger);
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--text-sm);
}
.error-message:empty { display: none; }

/* --------------------------------------------------------------------------
   Toast notifications
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
  pointer-events: auto;
  max-width: 360px;
}

.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-danger); }
.toast.warning { background: var(--color-warning); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* --------------------------------------------------------------------------
   Centered auth pages (login, access-pending)
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-brand-dark);
  padding: var(--sp-6);
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--sp-10) var(--sp-12);
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  margin: 0 auto var(--sp-8);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.hidden { display: none; }

.auth-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--sp-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--sp-8);
  line-height: 1.6;
}
