/* AgencyOS Client Portal */
[x-cloak] { display: none !important; }

:root {
  --p-primary: #6366f1;
  --p-primary-dark: #4f46e5;
  --p-bg: #f6f7fb;
  --p-white: #fff;
  --p-border: #e4e4e7;
  --p-text: #18181b;
  --p-muted: #71717a;
  --p-radius: 12px;
  --p-nav-w: 230px;
}

#agencyos-portal * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#agencyos-portal { color: var(--p-text); background: var(--p-bg); min-height: 100vh; }

/* Impersonation bar */
.portal-impersonation-bar {
  background: #7c3aed; color: #fff; text-align: center;
  padding: 8px; font-size: .875rem;
}
.portal-impersonation-bar a { color: #c4b5fd; }

/* Shell */
.portal-shell { display: flex; min-height: 100vh; }

/* Navigation */
.portal-nav {
  width: var(--p-nav-w); background: var(--p-white); border-right: 1px solid var(--p-border);
  display: flex; flex-direction: column; padding: 24px 0; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.portal-logo {
  display: flex; align-items: center; gap: 10px; padding: 0 20px 24px;
  font-size: 1.1rem; font-weight: 700; color: var(--p-text);
  border-bottom: 1px solid var(--p-border);
}
.portal-nav ul { list-style: none; padding: 16px 0; flex: 1; }
.portal-nav ul li a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: var(--p-muted); text-decoration: none; font-size: .9rem; border-radius: 0;
  transition: all .15s; position: relative;
}
.portal-nav ul li.active a,
.portal-nav ul li a:hover { color: var(--p-primary); background: #f0f0ff; }
.portal-nav ul li.active a { font-weight: 600; }
.nav-badge {
  background: #ef4444; color: #fff; border-radius: 20px; font-size: .7rem;
  padding: 1px 6px; margin-left: auto; font-weight: 700;
}
.portal-nav-footer { padding: 16px 20px; border-top: 1px solid var(--p-border); }
.portal-user { display: flex; align-items: center; gap: 10px; }
.portal-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--p-primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
}

/* Main */
.portal-main { flex: 1; padding: 32px; overflow-y: auto; }

/* Cards */
.portal-card {
  background: var(--p-white); border: 1px solid var(--p-border); border-radius: var(--p-radius);
  padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 1rem; font-weight: 700; }

/* View toggle */
.view-toggle { display: flex; background: var(--p-bg); border-radius: 8px; padding: 3px; }
.view-toggle button {
  padding: 5px 14px; border: none; background: transparent; border-radius: 6px;
  font-size: .8rem; cursor: pointer; color: var(--p-muted); transition: all .15s;
}
.view-toggle button.active { background: var(--p-white); color: var(--p-text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Stats */
.portal-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px;
}
.portal-stat {
  background: var(--p-white); border: 1px solid var(--p-border); border-radius: var(--p-radius);
  padding: 18px 20px; text-align: center;
}
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--p-primary); }
.stat-lbl { font-size: .78rem; color: var(--p-muted); margin-top: 4px; }
.trend-up { color: #22c55e !important; }
.trend-down { color: #ef4444 !important; }

/* Task rows */
.portal-task-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid #f4f4f5;
}
.portal-task-row:last-child { border-bottom: none; }
.task-info { flex: 1; }
.task-title { font-size: .9rem; font-weight: 500; }
.task-title.done { text-decoration: line-through; color: var(--p-muted); }
.task-meta { font-size: .78rem; color: var(--p-muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Badges */
.portal-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 20px; font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.portal-badge-blue   { background: #eff6ff; color: #2563eb; }
.portal-badge-yellow { background: #fffbeb; color: #d97706; }
.portal-badge-green  { background: #f0fdf4; color: #16a34a; }
.portal-badge-red    { background: #fef2f2; color: #dc2626; }
.portal-badge-gray   { background: #f4f4f5; color: #52525b; }
.portal-badge-purple { background: #f5f3ff; color: #7c3aed; }

.portal-badge-warning { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; border-radius: 6px; padding: 3px 10px; font-size: .78rem; font-weight: 600; }

/* Role colors */
.role-pm         { background: #eff6ff; color: #2563eb; }
.role-designer   { background: #f5f3ff; color: #7c3aed; }
.role-developer  { background: #f0fdf4; color: #16a34a; }
.role-ads        { background: #fffbeb; color: #d97706; }
.role-copy       { background: #fff7ed; color: #c2410c; }
.role-client     { background: #fef2f2; color: #dc2626; }

/* Status colors */
.status-todo      { background: #f4f4f5; color: #52525b; }
.status-doing     { background: #eff6ff; color: #2563eb; }
.status-review    { background: #fffbeb; color: #d97706; }
.status-done      { background: #f0fdf4; color: #16a34a; }
.status-blocked   { background: #fef2f2; color: #dc2626; }
.status-active    { background: #f0fdf4; color: #16a34a; }
.status-draft     { background: #f4f4f5; color: #52525b; }
.status-paused    { background: #fffbeb; color: #d97706; }
.status-completed { background: #f0fdf4; color: #16a34a; }
.status-archived  { background: #f4f4f5; color: #52525b; }
.status-pending   { background: #fffbeb; color: #d97706; }
.status-approved  { background: #f0fdf4; color: #16a34a; }
.status-rejected  { background: #fef2f2; color: #dc2626; }
.status-launched  { background: #f0fdf4; color: #16a34a; }
.status-ready     { background: #eff6ff; color: #2563eb; }
.status-sent      { background: #f0fdf4; color: #16a34a; }

/* Buttons */
.portal-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  border-radius: 8px; font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all .15s;
}
.portal-btn-primary { background: var(--p-primary); color: #fff; }
.portal-btn-primary:hover { background: var(--p-primary-dark); color: #fff; }
.portal-btn-ghost { background: transparent; color: var(--p-muted); }
.portal-btn-ghost:hover { background: var(--p-bg); }
.portal-btn-danger { background: #fef2f2; color: #dc2626; }
.portal-btn-danger:hover { background: #fee2e2; }
.portal-btn-sm { padding: 5px 12px; font-size: .8rem; }
.portal-btn:disabled { opacity: .6; cursor: not-allowed; }

/* Forms */
.portal-form-row { margin-bottom: 16px; }
.portal-form-row label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; }
.portal-form-row input,
.portal-form-row select,
.portal-form-row textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--p-border); border-radius: 8px;
  font-size: .875rem; background: #fff; transition: border .15s;
}
.portal-form-row input:focus,
.portal-form-row select:focus,
.portal-form-row textarea:focus { outline: none; border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.portal-form-row textarea { min-height: 80px; resize: vertical; }

/* Tabs */
.portal-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--p-border); }
.portal-tabs button {
  padding: 10px 18px; border: none; background: transparent; font-size: .875rem;
  cursor: pointer; color: var(--p-muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s;
}
.portal-tabs button.active { color: var(--p-primary); border-bottom-color: var(--p-primary); font-weight: 600; }

/* Progress bar */
.progress-bar { height: 6px; background: var(--p-bg); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--p-primary); border-radius: 3px; transition: width .4s; }

/* Goal wizard */
.wizard-steps { display: flex; gap: 0; margin-bottom: 28px; }
.wizard-step {
  flex: 1; display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: var(--p-muted); padding: 10px 0;
  border-bottom: 2px solid var(--p-border);
}
.wizard-step.active { color: var(--p-primary); border-bottom-color: var(--p-primary); }
.wizard-step.done { color: #22c55e; border-bottom-color: #22c55e; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .75rem;
  flex-shrink: 0;
}

/* Goal type grid */
.goal-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.goal-type-card {
  border: 2px solid var(--p-border); border-radius: 10px; padding: 16px; cursor: pointer;
  text-align: center; transition: all .15s;
}
.goal-type-card:hover { border-color: var(--p-primary); background: #f0f0ff; }
.goal-type-card.selected { border-color: var(--p-primary); background: #f0f0ff; }
.goal-type-icon { font-size: 2rem; margin-bottom: 8px; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--p-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* Spinner */
.portal-spin {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
  .portal-nav { display: none; }
  .portal-main { padding: 16px; }
  .portal-stats { grid-template-columns: 1fr 1fr; }
}
