/* ============================================================
   Techpool Shared Layout — App Shell, Sidebar, Components
   ============================================================ */

/* ── App Shell ── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--tp-sidebar-width);
  background: var(--tp-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--tp-normal) var(--tp-ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--tp-3);
  padding: var(--tp-5) var(--tp-5) var(--tp-4);
}

.sidebar-brand-logo {
  width: 28px;
  height: 28px;
  background: var(--tp-red);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: var(--tp-text-md);
  font-weight: 700;
  color: white;
  letter-spacing: -0.01em;
}
.sidebar-brand-name span { color: var(--tp-red); }

/* Module switcher */
.module-switcher {
  display: flex;
  gap: 2px;
  padding: 0 var(--tp-3) var(--tp-3);
  margin-bottom: var(--tp-2);
}

.module-switcher a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--tp-1);
  padding: var(--tp-2) var(--tp-2);
  border-radius: var(--tp-radius);
  font-size: var(--tp-text-xs);
  font-weight: 500;
  color: var(--tp-sidebar-text);
  transition: all var(--tp-fast);
  white-space: nowrap;
}

.module-switcher a:hover {
  background: var(--tp-sidebar-hover);
  color: var(--tp-sidebar-text-active);
}

.module-switcher a.active {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-weight: 600;
}

.mod-icon { font-size: 14px; }

/* Sidebar nav */
.sidebar-nav { flex: 1; padding: 0 var(--tp-3); }

.sidebar-section-label {
  font-size: var(--tp-text-xs);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--tp-4) var(--tp-3) var(--tp-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--tp-3);
  padding: var(--tp-2) var(--tp-3);
  border-radius: var(--tp-radius);
  font-size: var(--tp-text-sm);
  font-weight: 450;
  color: var(--tp-sidebar-text);
  transition: all var(--tp-fast);
  margin-bottom: 1px;
  position: relative;
}

.sidebar-link:hover {
  background: var(--tp-sidebar-hover);
  color: var(--tp-sidebar-text-active);
}

.sidebar-link.active {
  background: rgba(245, 15, 60, 0.08);
  color: white;
  font-weight: 500;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--tp-red);
  border-radius: 0 2px 2px 0;
}

.sidebar-link-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link-badge {
  margin-left: auto;
  background: var(--tp-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--tp-radius-full);
  min-width: 18px;
  text-align: center;
}

/* Sidebar user */
.sidebar-user {
  padding: var(--tp-4) var(--tp-5);
  border-top: 1px solid var(--tp-sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--tp-3);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--tp-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: var(--tp-text-sm);
  font-weight: 600;
  color: white;
}

.sidebar-user-role {
  font-size: var(--tp-text-xs);
  color: var(--tp-sidebar-text);
}

/* Mode indicator */
.sidebar-mode {
  padding: var(--tp-3) var(--tp-5);
  border-top: 1px solid var(--tp-sidebar-border);
}

.sidebar-mode-label {
  font-size: var(--tp-text-xs);
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: var(--tp-1);
}

.sidebar-mode-value {
  font-size: var(--tp-text-sm);
  color: white;
  font-weight: 500;
}

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

/* Topbar */
.topbar {
  height: var(--tp-topbar-h);
  background: white;
  border-bottom: 1px solid var(--tp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--tp-6);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--tp-2);
  font-size: var(--tp-text-sm);
}

.topbar-breadcrumb a {
  color: var(--tp-text-muted);
  transition: color var(--tp-fast);
}
.topbar-breadcrumb a:hover { color: var(--tp-red); }

.topbar-breadcrumb-sep { color: var(--tp-border); }
.topbar-breadcrumb-current { color: var(--tp-text); font-weight: 500; }

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

.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--tp-2);
  padding: var(--tp-2) var(--tp-3);
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  font-size: var(--tp-text-sm);
  color: var(--tp-text-muted);
  cursor: pointer;
  min-width: 200px;
}

.topbar-search kbd {
  margin-left: auto;
  background: white;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  padding: 0 4px;
  font-size: 10px;
  font-family: var(--tp-mono);
}

/* Page */
.page {
  padding: var(--tp-6);
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--tp-6);
  flex-wrap: wrap;
  gap: var(--tp-4);
}

.page-title {
  font-size: var(--tp-text-2xl);
  font-weight: 700;
  color: var(--tp-text);
  letter-spacing: -0.02em;
}

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

/* ── Cards ── */
.card {
  background: var(--tp-card);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-lg);
  overflow: hidden;
  transition: box-shadow var(--tp-normal) var(--tp-ease);
}

.card:hover { box-shadow: var(--tp-shadow); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--tp-4) var(--tp-5);
  border-bottom: 1px solid var(--tp-border-light);
}

.card-title {
  font-size: var(--tp-text-md);
  font-weight: 600;
  color: var(--tp-text);
}

.card-body { padding: var(--tp-4) var(--tp-5); }
.card-footer { padding: var(--tp-3) var(--tp-5); border-top: 1px solid var(--tp-border-light); }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--tp-4);
  margin-bottom: var(--tp-6);
}

.stat-card {
  background: white;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-lg);
  padding: var(--tp-4) var(--tp-5);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--tp-red);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--tp-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: var(--tp-3);
}

.stat-label {
  font-size: var(--tp-text-xs);
  font-weight: 500;
  color: var(--tp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: var(--tp-text-2xl);
  font-weight: 700;
  color: var(--tp-text);
  margin-top: var(--tp-1);
}

.stat-change {
  font-size: var(--tp-text-xs);
  color: var(--tp-text-muted);
  margin-top: var(--tp-1);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tp-2);
  padding: var(--tp-2) var(--tp-4);
  border-radius: var(--tp-radius);
  font-size: var(--tp-text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--tp-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--tp-red);
  color: white;
  border-color: var(--tp-red);
}
.btn-primary:hover { background: var(--tp-red-hover); }

.btn-secondary {
  background: var(--tp-bg);
  color: var(--tp-text);
  border-color: var(--tp-border);
}
.btn-secondary:hover { background: var(--tp-border-light); }

.btn-outline {
  background: transparent;
  color: var(--tp-text);
  border-color: var(--tp-border);
}
.btn-outline:hover { background: var(--tp-bg); }

.btn-ghost {
  background: transparent;
  color: var(--tp-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--tp-bg); color: var(--tp-text); }

.btn-sm { padding: var(--tp-1) var(--tp-3); font-size: var(--tp-text-xs); }
.btn-lg { padding: var(--tp-3) var(--tp-6); font-size: var(--tp-text-base); }
.btn-icon { padding: var(--tp-2); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--tp-1);
  padding: 2px 8px;
  border-radius: var(--tp-radius-full);
  font-size: var(--tp-text-xs);
  font-weight: 600;
  line-height: 1.4;
}

.badge-success { background: var(--tp-success-bg); color: var(--tp-success); }
.badge-warning { background: var(--tp-warning-bg); color: var(--tp-warning); }
.badge-danger { background: var(--tp-danger-bg); color: var(--tp-danger); }
.badge-info { background: var(--tp-info-bg); color: var(--tp-info); }
.badge-neutral { background: var(--tp-bg); color: var(--tp-text-muted); }

/* Privacy badges */
.badge-stakeholder { background: rgba(34, 197, 94, 0.1); color: var(--tp-stakeholder); }
.badge-team { background: rgba(59, 130, 246, 0.1); color: var(--tp-team); }
.badge-personal { background: rgba(136, 136, 153, 0.1); color: var(--tp-personal); }

/* ── Progress ── */
.progress {
  height: 6px;
  background: var(--tp-bg);
  border-radius: var(--tp-radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--tp-red);
  border-radius: var(--tp-radius-full);
  transition: width var(--tp-normal) var(--tp-ease);
}

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

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

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

th {
  font-size: var(--tp-text-xs);
  font-weight: 600;
  color: var(--tp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: var(--tp-3) var(--tp-4);
  border-bottom: 1px solid var(--tp-border);
}

td {
  font-size: var(--tp-text-sm);
  padding: var(--tp-3) var(--tp-4);
  border-bottom: 1px solid var(--tp-border-light);
  vertical-align: middle;
}

tr:hover td { background: rgba(0,0,0,0.01); }

/* ── Avatar ── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tp-radius);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: var(--tp-1);
  border-bottom: 1px solid var(--tp-border);
  margin-bottom: var(--tp-5);
}

.tab {
  padding: var(--tp-3) var(--tp-4);
  font-size: var(--tp-text-sm);
  font-weight: 500;
  color: var(--tp-text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--tp-fast);
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--tp-text); }
.tab.active { color: var(--tp-red); border-bottom-color: var(--tp-red); font-weight: 600; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--tp-12) var(--tp-6);
  color: var(--tp-text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: var(--tp-4); opacity: 0.4; }
.empty-state-title { font-size: var(--tp-text-lg); font-weight: 600; color: var(--tp-text); margin-bottom: var(--tp-2); }
.empty-state-desc { font-size: var(--tp-text-sm); max-width: 360px; margin: 0 auto; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--tp-fast);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: white;
  border-radius: var(--tp-radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--tp-shadow-lg);
  transform: translateY(8px);
  transition: transform var(--tp-normal) var(--tp-ease);
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--tp-5);
  border-bottom: 1px solid var(--tp-border-light);
}

.modal-title { font-size: var(--tp-text-lg); font-weight: 600; }

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--tp-bg);
  border-radius: var(--tp-radius);
  font-size: 16px;
  color: var(--tp-text-muted);
  cursor: pointer;
}

.modal-body { padding: var(--tp-5); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--tp-3);
  padding: var(--tp-4) var(--tp-5);
  border-top: 1px solid var(--tp-border-light);
}

/* ── Form fields ── */
.form-group { margin-bottom: var(--tp-4); }

.form-label {
  display: block;
  font-size: var(--tp-text-xs);
  font-weight: 600;
  color: var(--tp-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--tp-2);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--tp-2) var(--tp-3);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  font-size: var(--tp-text-sm);
  color: var(--tp-text);
  background: white;
  transition: border-color var(--tp-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--tp-red);
  box-shadow: 0 0 0 3px var(--tp-red-light);
}

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

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: var(--tp-6);
  right: var(--tp-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--tp-2);
}

.toast {
  padding: var(--tp-3) var(--tp-5);
  background: var(--tp-sidebar-bg);
  color: white;
  border-radius: var(--tp-radius);
  font-size: var(--tp-text-sm);
  font-weight: 500;
  box-shadow: var(--tp-shadow-lg);
  animation: slideUp 0.3s var(--tp-ease);
  display: flex;
  align-items: center;
  gap: var(--tp-3);
}

.toast.success { border-left: 3px solid var(--tp-success); }
.toast.warning { border-left: 3px solid var(--tp-warning); }
.toast.error { border-left: 3px solid var(--tp-danger); }
.toast.info { border-left: 3px solid var(--tp-info); }

/* ── Utilities ── */
.text-sm { font-size: var(--tp-text-sm); }
.text-xs { font-size: var(--tp-text-xs); }
.text-muted { color: var(--tp-text-muted); }
.text-secondary { color: var(--tp-text-secondary); }
.text-success { color: var(--tp-success); }
.text-danger { color: var(--tp-danger); }
.text-right { text-align: right; }
.font-mono { font-family: var(--tp-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: var(--tp-1); }
.mt-2 { margin-top: var(--tp-2); }
.mt-4 { margin-top: var(--tp-4); }
.mt-6 { margin-top: var(--tp-6); }
.mb-2 { margin-bottom: var(--tp-2); }
.mb-4 { margin-bottom: var(--tp-4); }
.gap-2 { gap: var(--tp-2); }
.gap-3 { gap: var(--tp-3); }
.gap-4 { gap: var(--tp-4); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ── Animations ── */
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Mobile sidebar ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 110;
  width: 36px;
  height: 36px;
  background: white;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--tp-text);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-toggle { display: flex; }
  .sidebar-overlay.active { display: block; }

  .main { margin-left: 0; }

  .topbar { padding-left: 56px; }

  .page { padding: var(--tp-4); }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .topbar-search { display: none; }
}

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