/* DebrisData.com Client Portal — UI styles */
:root {
  --navy: #0c1a2e;
  --navy-mid: #152a45;
  --navy-light: #1e3a5f;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #14b8a6;
  --slate: #64748b;
  --slate-light: #94a3b8;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --white: #ffffff;
  --text: #1e293b;
  --text-muted: #475569;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --sidebar-w: 240px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; }

/* ========== LOGIN ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-mid) 60%, var(--navy-light) 100%);
  padding: 1.5rem;
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgb(0 0 0 / 0.2);
  width: 100%;
  max-width: 400px;
  padding: 2.25rem;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
  justify-content: center;
}

.login-logo .mark {
  width: 40px;
  height: 40px;
  background: var(--teal);
  color: var(--white);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo .text {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--navy);
}

.login-logo .domain { color: var(--teal); font-weight: 500; }

.login-card h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  margin-bottom: 0.35rem;
}

.login-sub {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}

.form-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

.form-row-between a {
  color: var(--teal);
  font-weight: 500;
}

.form-row-between a:hover { text-decoration: underline; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

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

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

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

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

.btn-ghost {
  background: transparent;
  color: var(--slate);
  border: none;
  padding: 0.4rem 0.6rem;
}

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

.btn-full { width: 100%; }

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.login-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--slate);
}

.login-footer a { color: var(--teal); }

/* ========== APP SHELL ========== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .mark {
  width: 32px;
  height: 32px;
  background: var(--teal);
  color: var(--white);
  font-weight: 700;
  font-size: 0.7rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand .text {
  font-weight: 700;
  font-size: 0.95rem;
}

.sidebar-brand .sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 0.5rem 0.75rem 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}

.nav-link.active {
  background: rgba(13,148,136,0.25);
  color: var(--white);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--white);
}

.user-meta .name {
  font-weight: 600;
  color: var(--white);
  font-size: 0.85rem;
}

.user-meta .org {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

/* Main content */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content {
  padding: 1.75rem;
  flex: 1;
}

/* Cards & surfaces */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
}

.card-body { padding: 1.25rem; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.stat-meta {
  font-size: 0.75rem;
  color: var(--slate-light);
  margin-top: 0.2rem;
}

/* Project table / list */
.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

table.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

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

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

.project-name {
  font-weight: 600;
  color: var(--navy);
}

.project-name:hover { color: var(--teal); }

.project-meta {
  font-size: 0.8rem;
  color: var(--slate);
  margin-top: 0.15rem;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-received { background: var(--info-bg); color: var(--info); }
.badge-review { background: var(--warning-bg); color: var(--warning); }
.badge-questions { background: #fef3c7; color: #b45309; }
.badge-ready { background: var(--success-bg); color: var(--success); }
.badge-closed { background: var(--gray-100); color: var(--slate); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--slate);
}

.empty-state h3 {
  font-size: 1.05rem;
  color: var(--navy);
  margin-bottom: 0.4rem;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 360px;
  margin: 0 auto 1.25rem;
}

/* Project workspace */
.project-header {
  margin-bottom: 1.5rem;
}

.project-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.35rem;
}

.project-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--slate);
}

.project-header .meta span strong {
  color: var(--text);
  font-weight: 500;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

/* Document categories */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.category-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}

.category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
}

.category-head h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-count {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--gray-200);
  color: var(--slate);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.category-body {
  padding: 0.5rem 0;
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.1rem;
  font-size: 0.875rem;
  transition: background 0.1s;
}

.doc-row:hover { background: var(--gray-50); }

.doc-icon {
  width: 32px;
  height: 32px;
  background: var(--gray-100);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate);
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
}

.doc-info { flex: 1; min-width: 0; }

.doc-name {
  font-weight: 500;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 0.75rem;
  color: var(--slate);
}

.doc-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  text-align: center;
  background: var(--gray-50);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--teal);
  background: rgba(13,148,136,0.04);
}

.upload-zone h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.upload-zone p {
  font-size: 0.8rem;
  color: var(--slate);
}

.upload-zone .hint {
  font-size: 0.75rem;
  color: var(--slate-light);
  margin-top: 0.5rem;
}

/* Sidebar panel (status / activity) */
.side-panel .card { margin-bottom: 1rem; }

.status-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 28px;
  bottom: -4px;
  width: 2px;
  background: var(--gray-200);
}

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-200);
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
}

.timeline-item.done .timeline-dot { background: var(--teal); }
.timeline-item.current .timeline-dot {
  background: var(--white);
  border: 3px solid var(--teal);
}

.timeline-content h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}

.timeline-content p {
  font-size: 0.75rem;
  color: var(--slate);
}

/* Notes / activity */
.note-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.85rem;
}

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

.note-item .author {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.8rem;
}

.note-item .time {
  font-size: 0.75rem;
  color: var(--slate-light);
}

.note-item p {
  margin-top: 0.25rem;
  color: var(--text-muted);
}

/* Demo banner */
.demo-banner {
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  padding: 0.45rem 1rem;
}

.demo-banner a {
  color: #b45309;
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0; }

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

  .content { padding: 1.15rem; }

  .topbar { padding: 0.75rem 1.15rem; }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
}

/* Flash toasts */
.portal-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: 360px;
  padding: 0.85rem 1.15rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgb(0 0 0 / 0.15);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.portal-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.portal-toast-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.portal-toast-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.portal-toast-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #075985;
}

/* Inline alerts on login */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1.15rem;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

/* Note form */
.note-form textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}
.note-form textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}

.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
}
.form-group select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}

/* How to upload note */
.upload-howto {
  background: var(--info-bg, #f0f9ff);
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.15rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: left;
}
.upload-howto strong {
  display: block;
  color: var(--navy);
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}
.upload-howto ol {
  margin: 0 0 0.5rem 1.15rem;
  padding: 0;
  line-height: 1.55;
}
.upload-howto li {
  margin-bottom: 0.25rem;
}
.upload-howto-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--slate);
}
