/* Mpowerr OS — custom styles (Tailwind via CDN) */

:root {
  --os-bg: #f4f5f7;
  --os-sidebar: #ffffff;
  --os-border: #e8eaed;
  --os-text: #1a1d23;
  --os-muted: #6b7280;
  --os-accent: #2563eb;
  --os-radius: 14px;
  --os-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);

  /* Mpowerr brand blues */
  --mp-dark: #1e3a8a;
  --mp-dark-text: #1e3a8a;
  --mp-dark-bg: #e8eefc;
  --mp-dark-border: #a8bceb;
  --mp-light: #3b82f6;
  --mp-light-text: #2563eb;
  --mp-light-bg: #eff6ff;
  --mp-light-border: #bfdbfe;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--os-bg);
  color: var(--os-text);
  -webkit-font-smoothing: antialiased;
}

/* Shell */
.os-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.22s ease;
}

.os-shell.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

.os-sidebar {
  background: var(--os-sidebar);
  border-right: 1px solid var(--os-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
  transition: opacity 0.18s ease, transform 0.22s ease;
}

.os-shell.sidebar-collapsed .os-sidebar {
  opacity: 0;
  pointer-events: none;
  border-right-color: transparent;
  transform: translateX(-8px);
}

.os-brand {
  padding: 1.1rem 0.9rem 1rem 1.15rem;
  border-bottom: 1px solid var(--os-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.os-brand-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.os-brand-text {
  min-width: 0;
}

.sidebar-close-btn,
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--os-border);
  background: #fff;
  border-radius: 10px;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-close-btn:hover,
.sidebar-toggle:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #d1d5db;
}

.sidebar-close-btn {
  border-color: transparent;
  background: transparent;
}

.sidebar-close-btn:hover {
  background: #f3f4f6;
}

.os-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
}

.os-brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.os-brand p {
  margin: 0.1rem 0 0;
  font-size: 0.7rem;
  color: var(--os-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.os-nav-label {
  padding: 1rem 1.25rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--os-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.os-team-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.75rem 1rem;
}

.os-member {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.8rem;
  border: none;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.os-member:hover {
  background: #f3f4f6;
}

.os-member.is-active {
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #dbeafe;
}

.os-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.os-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  object-position: center top;
  background: #e5e7eb;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #e5e7eb;
}

.os-online {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
}

.os-member-meta {
  min-width: 0;
}

.os-member-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--os-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.os-member-sub {
  font-size: 0.72rem;
  color: var(--os-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.os-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.os-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.75rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--os-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.os-topbar h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.os-topbar span {
  font-size: 0.8rem;
  color: var(--os-muted);
}

.os-content {
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: none;
}

/* Detail: profile left + mandates right */
.detail-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.detail-profile {
  position: sticky;
  top: 5.25rem;
}

.profile-card {
  background: #fff;
  border: 1px solid var(--os-border);
  border-radius: 18px;
  box-shadow: var(--os-shadow);
  padding: 1.35rem;
}

.profile-photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: 1.1rem;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  object-fit: cover;
  object-position: center top;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.profile-online {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #22c55e;
  border: 3px solid #fff;
}

.profile-info h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.profile-role {
  margin: 0.25rem 0 0;
  color: var(--os-muted);
  font-size: 0.9rem;
}

.profile-block {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.profile-block-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
  margin-bottom: 0.55rem;
}

.profile-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.profile-list li {
  font-size: 0.86rem;
  font-weight: 600;
  color: #334155;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  line-height: 1.3;
}

.profile-list.primary li {
  background: var(--mp-dark-bg);
  border-color: var(--mp-dark-border);
  color: var(--mp-dark-text);
}

.profile-list.secondary li {
  background: var(--mp-light-bg);
  border-color: var(--mp-light-border);
  color: var(--mp-light-text);
}

.profile-empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--os-muted);
  font-style: italic;
}

.detail-mandates .section-head {
  margin: 0 0 0.85rem;
}

.mandate-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mandate-section-head {
  margin-bottom: 0.75rem;
}

.mandate-section-head h4 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--os-muted);
}

.mandate-section.is-primary .mandate-section-head h4 {
  color: var(--mp-dark);
}

.mandate-section.is-secondary .mandate-section-head h4 {
  color: var(--mp-light);
}

.mandate-grid.is-empty,
.mandate-grid.section-drag-over {
  min-height: 88px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
}

.mandate-grid.section-drag-over {
  border-color: var(--mp-light-border);
  background: var(--mp-light-bg);
}

.mandate-section.is-primary .mandate-grid.section-drag-over {
  border-color: var(--mp-dark-border);
  background: var(--mp-dark-bg);
}

.mandate-drop-hint {
  display: grid;
  place-items: center;
  min-height: 88px;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #374151;
}

.pill.primary {
  background: var(--mp-dark-bg);
  color: var(--mp-dark-text);
}

.pill.secondary {
  background: var(--mp-light-bg);
  color: var(--mp-light-text);
}

/* Section */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.85rem;
}

.section-head h4 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--os-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--os-border);
  background: #fff;
  color: var(--os-text);
  border-radius: 10px;
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--os-muted);
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
}

.btn-ghost:hover {
  background: #f3f4f6;
  color: var(--os-text);
}

.btn-danger {
  color: #dc2626;
}

.btn-danger:hover {
  background: #fef2f2;
  color: #b91c1c;
}

/* Mandate cards — boxed grid */
.mandate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.mandate-card {
  background: #fff;
  border: 1px solid var(--os-border);
  border-radius: 16px;
  box-shadow: var(--os-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  border-top: 3px solid #cbd5e1;
  transition: box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  cursor: grab;
}

.mandate-card:hover {
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}

.mandate-card:active {
  cursor: grabbing;
}

.mandate-card.is-dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.mandate-card.drag-over {
  box-shadow: 0 0 0 2px #93c5fd, 0 8px 24px rgba(37, 99, 235, 0.12);
}

.mandate-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #94a3b8;
  border-radius: 8px;
  cursor: grab;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.mandate-drag-handle:hover {
  background: #f1f5f9;
  color: #64748b;
}

/* Two-tone system: Primary = rose, Secondary = blue */
.mandate-card.is-primary {
  border-top-color: var(--mp-dark);
}

.mandate-card.is-secondary {
  border-top-color: var(--mp-light);
}

.mandate-card.is-primary .mandate-dot {
  background: var(--mp-dark);
}

.mandate-card.is-secondary .mandate-dot {
  background: var(--mp-light);
}

.mandate-card.is-primary .sub-box {
  background: var(--mp-dark-bg);
  color: var(--mp-dark-text);
  border-color: var(--mp-dark-border);
}

.mandate-card.is-secondary .sub-box {
  background: var(--mp-light-bg);
  color: var(--mp-light-text);
  border-color: var(--mp-light-border);
}

.mandate-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.75rem;
}

.mandate-card:not(.is-collapsed) .mandate-card-head {
  border-bottom: 1px solid #f1f5f9;
}

.mandate-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}

.mandate-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
}

.mandate-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
  margin-top: 0.35rem;
  background: #94a3b8;
}

.mandate-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.mandate-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
}

.mandate-body {
  padding: 1rem 1.1rem 1.15rem;
  flex: 1;
}

.mandate-card.is-collapsed .mandate-body {
  display: none;
}

.mandate-card.is-collapsed {
  min-height: 0;
}

.tag-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.55rem;
}

.sub-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  border: 1px solid transparent;
  min-height: 48px;
}

.sub-box .tag-label {
  flex: 1;
}

.sub-box .tag-edit-btns {
  display: none;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.mandate-card.is-editing .sub-box .tag-edit-btns {
  display: inline-flex;
}

.tag-btn {
  border: none;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  padding: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: inherit;
  opacity: 0.85;
  font-size: 0.75rem;
  line-height: 1;
}

.tag-btn:hover {
  opacity: 1;
  background: #fff;
}

.empty-tags {
  font-size: 0.85rem;
  color: var(--os-muted);
  font-style: italic;
  margin: 0;
}

.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--os-border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #111827;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.modal-head {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--os-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h5 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.15rem;
}

.modal-body label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--os-muted);
  margin-bottom: 0.35rem;
}

.modal-body input,
.modal-body select {
  width: 100%;
  border: 1px solid var(--os-border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 0.9rem;
  background: #fff;
}

.modal-body input:focus,
.modal-body select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-foot {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--os-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Empty / loading */
.state-panel {
  background: #fff;
  border: 1px dashed var(--os-border);
  border-radius: var(--os-radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--os-muted);
}

.state-panel h3 {
  margin: 0 0 0.35rem;
  color: var(--os-text);
  font-size: 1rem;
}

/* Mobile */
.mobile-toggle {
  display: none;
  border: 1px solid var(--os-border);
  background: #fff;
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
}

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

@media (max-width: 900px) {
  .os-shell {
    grid-template-columns: 1fr;
  }

  .os-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .os-shell.sidebar-collapsed .os-sidebar {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-105%);
  }

  .os-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.08);
    opacity: 1;
  }

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

  .os-content {
    padding: 1rem;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-profile {
    position: static;
  }

  .profile-photo-wrap {
    max-width: 200px;
  }

  .mandate-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 35;
  }

  .sidebar-backdrop.is-open {
    display: block;
  }
}

/* Avatar color fallbacks */
.avatar-c1 { background: linear-gradient(135deg, #1e40af, #3b82f6); }
.avatar-c2 { background: linear-gradient(135deg, #065f46, #10b981); }
.avatar-c3 { background: linear-gradient(135deg, #5b21b6, #8b5cf6); }
.avatar-c4 { background: linear-gradient(135deg, #9a3412, #f97316); }
.avatar-c5 { background: linear-gradient(135deg, #9f1239, #fb7185); }
.avatar-c6 { background: linear-gradient(135deg, #155e75, #22d3ee); }
.avatar-c7 { background: linear-gradient(135deg, #3730a3, #818cf8); }
