{% extends "ui/templates/base/layout.html" %}
{% block content %}
{% include "modules/consultants/templates/consultants/_consultant_tabs.html" %}
<div class="space-y-6">
  <div class="flex flex-wrap items-start justify-between gap-4">
    <div>
      <h2 class="text-xl font-semibold text-slate-900">Edit Consultant Workspace</h2>
      <p class="text-sm text-slate-500">Update your workspace display details. Plan, billing, subscription and limits are controlled by the firm/admin.</p>
    </div>
    <a href="/consultant/workspace" class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Back to Workspace</a>
  </div>

  {% if errors %}
  <div class="rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700">
    <ul class="list-disc pl-5">
      {% for error in errors %}<li>{{ error }}</li>{% endfor %}
    </ul>
  </div>
  {% endif %}

  <div class="grid gap-4 md:grid-cols-4">
    <div class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
      <div class="text-xs uppercase tracking-wide text-slate-500">Plan</div>
      <div class="mt-2 text-lg font-semibold text-slate-900">{{ workspace.plan_code.replace('_',' ').title() if workspace and workspace.plan_code else 'Starter' }}</div>
    </div>
    <div class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
      <div class="text-xs uppercase tracking-wide text-slate-500">Subscription</div>
      <div class="mt-2 text-lg font-semibold text-slate-900">{{ workspace.subscription_status.replace('_',' ').title() if workspace and workspace.subscription_status else 'Trial' }}</div>
    </div>
    <div class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
      <div class="text-xs uppercase tracking-wide text-slate-500">Billing</div>
      <div class="mt-2 text-lg font-semibold text-slate-900">{{ workspace.billing_cycle.replace('_',' ').title() if workspace and workspace.billing_cycle else 'Manual' }}</div>
    </div>
    <div class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
      <div class="text-xs uppercase tracking-wide text-slate-500">Client Limit</div>
      <div class="mt-2 text-lg font-semibold text-slate-900">{{ workspace.max_managed_clients if workspace else 25 }}</div>
    </div>
  </div>

  <form method="post" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
    <input type="hidden" name="csrf_token" value="{{ csrf_token }}">

    <div class="grid gap-4 md:grid-cols-2">
      <div>
        <label class="text-sm font-medium text-slate-700">Workspace Name</label>
        <input name="workspace_name" value="{{ workspace.workspace_name if workspace else '' }}" required class="mt-1 w-full rounded-xl border border-slate-300 px-3 py-2 text-sm focus:border-slate-900 focus:outline-none">
      </div>
      <div>
        <label class="text-sm font-medium text-slate-700">Workspace Code</label>
        <input value="{{ workspace.workspace_code if workspace else '-' }}" disabled class="mt-1 w-full rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-500">
      </div>
    </div>

    <div class="mt-5 rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800">
      <div class="font-semibold">Admin-controlled fields</div>
      <p class="mt-1">Workspace type, plan, subscription status, billing cycle, client/user limits, feature switches and active status cannot be changed from the consultant portal.</p>
    </div>

    <div class="mt-5">
      <label class="text-sm font-medium text-slate-700">Remarks</label>
      <textarea name="remarks" rows="4" class="mt-1 w-full rounded-xl border border-slate-300 px-3 py-2 text-sm focus:border-slate-900 focus:outline-none">{{ workspace.remarks if workspace and workspace.remarks else '' }}</textarea>
    </div>

    <div class="mt-6 flex gap-2">
      <button class="rounded-xl bg-slate-900 px-4 py-2 text-sm font-semibold text-white hover:bg-slate-800">Save Workspace</button>
      <a href="/consultant/workspace" class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Cancel</a>
    </div>
  </form>
</div>
{% endblock %}
