/* =========================================================
   AethexFlow 0031 — Organization Management + Fluid Theme
   Smooth edges · fluid motion · editable layout · pro grade
   ========================================================= */

:root {
  --afx-radius-sm: 10px;
  --afx-radius: 14px;
  --afx-radius-lg: 20px;
  --afx-radius-xl: 28px;
  --afx-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --afx-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --afx-shadow: 0 8px 32px rgba(0,0,0,0.28);
  --afx-shadow-soft: 0 4px 20px rgba(0,0,0,0.18);
  --afx-glow: 0 0 40px rgba(255,59,63,0.12);
  --afx-border: rgba(255,255,255,0.08);
  --afx-border-strong: rgba(255,255,255,0.14);
  --afx-surface: rgba(17,17,22,0.72);
  --afx-surface-2: rgba(24,24,30,0.85);
  --afx-muted: #8b8f9a;
  --afx-text: #f4f5f7;
  --afx-red: #ff3b3f;
  --afx-red-soft: rgba(255,59,63,0.12);
  --afx-green: #36d399;
  --afx-blue: #5b8def;
  --afx-purple: #a78bfa;
  --afx-sidebar-w: 272px;
}

html[data-theme="light"] {
  --afx-border: rgba(15,20,30,0.08);
  --afx-border-strong: rgba(15,20,30,0.14);
  --afx-surface: rgba(255,255,255,0.78);
  --afx-surface-2: rgba(248,249,252,0.95);
  --afx-muted: #5f6877;
  --afx-text: #151821;
  --afx-shadow: 0 8px 32px rgba(15,20,30,0.08);
  --afx-shadow-soft: 0 4px 16px rgba(15,20,30,0.06);
  --afx-glow: 0 0 40px rgba(255,59,63,0.08);
}

/* ---- Fluid global polish ---- */
body {
  --sidebar-w: var(--afx-sidebar-w);
}

#app-sidebar {
  width: var(--afx-sidebar-w) !important;
  border-radius: 0;
  border-right: 1px solid var(--afx-border);
  transition: width 0.28s var(--afx-ease), transform 0.28s var(--afx-ease);
}

.glass, .glass-card, .afx16-store-card, .afx16-home-card,
#settings-drawer, .afx-org-panel, .afx-org-card {
  border-radius: var(--afx-radius-lg) !important;
  border-color: var(--afx-border) !important;
  transition:
    transform 0.25s var(--afx-ease),
    box-shadow 0.25s var(--afx-ease),
    background 0.22s ease,
    border-color 0.22s ease !important;
}

.glass-card:hover, .afx16-store-card:hover, .afx16-home-card:hover,
.afx-org-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--afx-shadow-soft), var(--afx-glow);
  border-color: var(--afx-border-strong) !important;
}

/* Smooth edges everywhere */
input, textarea, select, button, .nav-btn, .cat-btn,
.afx-chip, .afx-btn, .afx-field {
  border-radius: var(--afx-radius) !important;
}

/* Nav */
#app-sidebar .nav-btn {
  border-radius: 12px !important;
  transition: background 0.2s var(--afx-ease), color 0.18s ease, transform 0.15s ease, box-shadow 0.2s ease !important;
  letter-spacing: 0.01em;
}
#app-sidebar .nav-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
#app-sidebar .nav-btn:active { transform: scale(0.975); }
#app-sidebar .nav-btn.active {
  background: var(--afx-red-soft) !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(255,59,63,0.2);
}
#app-sidebar .nav-btn.active i { color: var(--afx-red) !important; }
#app-sidebar .nav-btn:focus-visible {
  outline: 2px solid rgba(255,59,63,0.5);
  outline-offset: 2px;
}

html[data-theme="light"] #app-sidebar .nav-btn { color: #5f6877; }
html[data-theme="light"] #app-sidebar .nav-btn:hover { background: rgba(20,24,32,0.045); color: #16181d; }
html[data-theme="light"] #app-sidebar .nav-btn.active {
  background: rgba(255,59,63,0.1) !important;
  color: #c81e2c !important;
  box-shadow: inset 0 0 0 1px rgba(255,59,63,0.14);
}
html[data-theme="light"] #app-sidebar .nav-btn.active i { color: #e32636 !important; }

/* Section labels */
.sidebar-label {
  letter-spacing: 0.12em !important;
  margin-top: 14px !important;
}
.sidebar-label:first-child { margin-top: 0 !important; }

/* ---- Organization panels ---- */
.afx-org-view {
  max-width: 1100px;
  margin: 0 auto;
  animation: afx-fade-up 0.4s var(--afx-ease) both;
}

@keyframes afx-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.afx-org-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.afx-org-hero h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.afx-org-hero p {
  color: var(--afx-muted);
  font-size: 0.9rem;
  margin: 0;
  max-width: 520px;
  line-height: 1.5;
}

.afx-org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.afx-org-card {
  background: var(--afx-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--afx-border);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.afx-org-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,59,63,0.04), transparent 55%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.afx-org-card:hover::before { opacity: 1; }

.afx-org-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--afx-red-soft);
  color: var(--afx-red);
  font-size: 16px;
  flex-shrink: 0;
}
.afx-org-card-icon.blue { background: rgba(91,141,239,0.12); color: var(--afx-blue); }
.afx-org-card-icon.green { background: rgba(54,211,153,0.12); color: var(--afx-green); }
.afx-org-card-icon.purple { background: rgba(167,139,250,0.12); color: var(--afx-purple); }

.afx-org-card h3 {
  font-size: 0.98rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
}
.afx-org-card p {
  font-size: 0.8rem;
  color: var(--afx-muted);
  margin: 0;
  line-height: 1.45;
  flex: 1;
}

.afx-org-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.afx-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 550;
  border: 1px solid var(--afx-border);
  background: rgba(255,255,255,0.03);
  color: var(--afx-muted);
}
html[data-theme="light"] .afx-chip { background: rgba(15,20,30,0.03); }
.afx-chip.live { color: var(--afx-green); border-color: rgba(54,211,153,0.25); background: rgba(54,211,153,0.08); }
.afx-chip.warn { color: #f59e0b; border-color: rgba(245,158,11,0.25); background: rgba(245,158,11,0.08); }

/* Buttons */
.afx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}
.afx-btn:active { transform: scale(0.97); }
.afx-btn-primary {
  background: var(--afx-red);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255,59,63,0.25);
}
.afx-btn-primary:hover { background: #ff5154; }
.afx-btn-ghost {
  background: rgba(255,255,255,0.04);
  border-color: var(--afx-border);
  color: var(--afx-text);
}
.afx-btn-ghost:hover { background: rgba(255,255,255,0.08); border-color: var(--afx-border-strong); }
html[data-theme="light"] .afx-btn-ghost { background: rgba(15,20,30,0.03); }

/* Forms / Studio */
.afx-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) {
  .afx-form-grid { grid-template-columns: 1fr; }
}
.afx-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--afx-muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.afx-field input,
.afx-field textarea,
.afx-field select {
  width: 100%;
  padding: 11px 13px;
  background: var(--afx-surface-2);
  border: 1px solid var(--afx-border);
  color: var(--afx-text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.afx-field input:focus,
.afx-field textarea:focus,
.afx-field select:focus {
  border-color: rgba(255,59,63,0.45);
  box-shadow: 0 0 0 3px rgba(255,59,63,0.12);
}
.afx-field textarea { min-height: 96px; resize: vertical; }

/* Team members */
.afx-member {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--afx-surface);
  border: 1px solid var(--afx-border);
  border-radius: var(--afx-radius) !important;
  transition: border-color 0.2s ease, transform 0.2s var(--afx-ease);
}
.afx-member:hover { border-color: var(--afx-border-strong); transform: translateX(2px); }
.afx-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: linear-gradient(135deg, rgba(255,59,63,0.25), rgba(167,139,250,0.25));
  color: #fff;
  flex-shrink: 0;
}
.afx-member-info { flex: 1; min-width: 0; }
.afx-member-info strong { display: block; font-size: 0.9rem; }
.afx-member-info span { font-size: 0.75rem; color: var(--afx-muted); }

/* Setup checklist */
.afx-check-list { display: flex; flex-direction: column; gap: 10px; }
.afx-check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--afx-surface);
  border: 1px solid var(--afx-border);
  border-radius: var(--afx-radius) !important;
}
.afx-check-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}
.afx-check-dot.ok { background: rgba(54,211,153,0.15); color: var(--afx-green); }
.afx-check-dot.pending { background: rgba(245,158,11,0.12); color: #f59e0b; }
.afx-check-dot.miss { background: rgba(255,59,63,0.12); color: var(--afx-red); }

/* Editable layout handle */
.afx-layout-edit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--afx-surface);
  border: 1px dashed var(--afx-border-strong);
  border-radius: var(--afx-radius) !important;
  font-size: 12px;
  color: var(--afx-muted);
}
.afx-layout-edit-bar.active {
  border-style: solid;
  border-color: rgba(255,59,63,0.35);
  background: var(--afx-red-soft);
  color: var(--afx-text);
}
.afx-org-card[draggable="true"] { cursor: grab; }
.afx-org-card[draggable="true"]:active { cursor: grabbing; }
.afx-org-card.drag-over {
  outline: 2px dashed rgba(255,59,63,0.45);
  outline-offset: 3px;
}

/* Updates timeline */
.afx-timeline { position: relative; padding-left: 22px; }
.afx-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, var(--afx-red), transparent);
  border-radius: 2px;
  opacity: 0.35;
}
.afx-timeline-item {
  position: relative;
  padding: 0 0 20px 0;
}
.afx-timeline-item::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--afx-red);
  box-shadow: 0 0 0 3px var(--afx-red-soft);
}
.afx-timeline-item h4 { margin: 0 0 4px; font-size: 0.92rem; font-weight: 650; }
.afx-timeline-item p { margin: 0; font-size: 0.8rem; color: var(--afx-muted); line-height: 1.45; }
.afx-timeline-item time { font-size: 11px; color: var(--afx-muted); opacity: 0.8; }

/* Fluid ambient orb */
.bg-orb {
  animation: afx-orb-float 18s ease-in-out infinite alternate !important;
  filter: blur(80px);
  opacity: 0.55;
}
@keyframes afx-orb-float {
  0% { transform: translate(0,0) scale(1); }
  50% { transform: translate(4%, 3%) scale(1.06); }
  100% { transform: translate(-3%, 5%) scale(0.97); }
}

/* Mobile bottom nav — keep 5–6 items usable */
@media (max-width: 767px) {
  #app-sidebar .nav-btn { width: 16.66% !important; }
  #app-sidebar .sidebar-label { display: none !important; }
}

/* Reduce motion */
body.reduce-motion .glass-card:hover,
body.reduce-motion .afx16-store-card:hover,
body.reduce-motion .afx16-home-card:hover,
body.reduce-motion .afx-org-card:hover {
  transform: none !important;
}
body.reduce-motion .bg-orb { animation: none !important; }
