
/* CSS reset and base variables */
:root {
  --color-primary: #111827;
  --color-surface: #ffffff;
  --color-background: #f8fafc;
  --color-text-main: #1f2937;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-accent: #0f172a;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background-color: var(--color-background); color: var(--color-text-main); line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* Auth */
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: #f8fafc; }
.auth-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; padding: 40px; width: 100%; max-width: 440px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05); }
.auth-logo { font-size: 2rem; font-weight: 700; color: var(--color-primary); margin-bottom: 0.5rem; letter-spacing: -0.025em; }
.auth-subtitle { color: var(--color-text-muted); font-size: 1.125rem; font-weight: 400; margin-bottom: 2.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; color: #334155; text-align: left; }
.form-input { width: 100%; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; font-family: inherit; }

/* App Layout */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: #f8fafc;
}

.app-sidebar {
  width: 256px;
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.app-sidebar-header {
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  height: 64px;
}

.app-sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: #64748b;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  margin-bottom: 4px;
  transition: all 0.2s;
}

.nav-link:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.nav-link.active {
  background-color: #e0e7ff;
  color: #4338ca;
  font-weight: 600;
}

.nav-icon {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Main Content */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #f8fafc;
}

.app-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 32px;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Typography & Titles */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-shrink: 0;
  min-height: 36px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  text-decoration: none;
  transition: all 0.2s;
  justify-content: center;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
}
.btn-primary:hover:not(:disabled) { background-color: #1d4ed8; }

.btn-secondary {
  background-color: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover:not(:disabled) { background-color: #f8fafc; border-color: #94a3b8; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(100%);
}

/* Inputs & Forms */
.input {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #0f172a;
  outline: none;
  background-color: #fff;
}
.input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.input:disabled {
  background-color: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

/* Toolbars */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}

/* Tables */
.table-container {
  flex: 1;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  position: relative;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background-color: #f8fafc;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  z-index: 10;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
}

/* Badges */
.badge {
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-block;
}
.badge-verified { background: #dcfce7; color: #166534; }
.badge-unmatched { background: #f1f5f9; color: #475569; }
.badge-suggested { background: #fef9c3; color: #854d0e; }
.badge-needs_audit { background: #fee2e2; color: #991b1b; }
.badge-review { background: #fef08a; color: #854d0e; }
.badge-default { background: #e0e7ff; color: #4338ca; }

/* States & Cards */
.loading-state, .empty-state {
  padding: 64px 24px;
  text-align: center;
  color: #64748b;
}

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Legal Intel Specific */
.legal-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.active-subnav {
  background-color: #e2e8f0;
  border-color: #94a3b8;
  font-weight: 600;
}

/* Responsive Sanity */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .app-sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #e2e8f0; }
  .app-sidebar-nav { display: flex; flex-wrap: wrap; padding: 8px; gap: 8px; overflow-x: auto; }
  .nav-link { margin-bottom: 0; white-space: nowrap; }
  .app-content { padding: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .input, .toolbar .btn { width: 100%; margin-left: 0 !important; }
  .legal-nav { justify-content: center; }
}

/* Shell & Progress States */
.progress-state {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  color: var(--color-text-muted);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin: auto;
  max-width: 600px;
}
.progress-state h1 { color: var(--color-primary); margin-bottom: 16px; font-size: 1.5rem; }
.system-owner-only { color: #d97706; }

/* Sticky Table Columns */
.sticky-col-1 {
  position: sticky !important;
  left: 0 !important;
  z-index: 5;
  background-color: inherit;
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
  box-sizing: border-box;
}
th.sticky-col-1 {
  z-index: 20;
  background-color: #f8fafc;
}
td.sticky-col-1 {
  background-color: #fff;
}

.sticky-col-2 {
  position: sticky !important;
  left: 100px !important;
  z-index: 5;
  background-color: inherit;
  box-shadow: inset -1px 0 0 #e2e8f0;
}
th.sticky-col-2 {
  z-index: 20;
  background-color: #f8fafc;
}
td.sticky-col-2 {
  background-color: #fff;
}

/* Ensure hovered rows keep solid backgrounds for sticky cells */
tbody tr:hover td.sticky-col-1,
tbody tr:hover td.sticky-col-2 {
  background-color: #f1f5f9;
}
tbody tr:hover {
  background-color: #f1f5f9;
}

@media (max-width: 768px) {
  .sticky-col-2 {
    position: static !important;
    left: auto !important;
    box-shadow: none !important;
  }
}
