/* Call Flow App – Light (Xelion) theme
   - Primary accent: #FF5D15
   - Font: Urbanist (fallbacks)
   Add this to your HTML <head> to load Urbanist:
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Urbanist:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
*/

:root{
  /* Brand */
  --primary: #FF5D15;
  --primary-2: #ff7a3f;

  /* Neutrals */
  --bg: #f6f7f9;
  --panel: #f5f5f5;
  --card: #ffffff;

  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15,23,42,.10);

  /* Buttons */
  --btn: rgba(15,23,42,.06);
  --btn2: rgba(15,23,42,.10);

  /* Focus glow */
  --focus-ring: rgba(255,93,21,.28);
  --focus-border: rgba(255,93,21,.65);

  /* Status */
  --ok: #16a34a;
  --warn: #FF5D15;
  --inactive: #94a3b8;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: "Urbanist", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Links */
a{ color: var(--primary); text-decoration:none; }
a:hover{ text-decoration:underline; }

/* App Shell */
.app-shell header{
  position: sticky;
  top: 0;
  background: rgba(246,247,249,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.app-main{
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* Cards */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15,23,42,.06);
}

.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 12px;
  border-bottom: 1px solid var(--line);
}

.card-title{
  font-weight: 800;
  letter-spacing: .2px;
}

/* Section titles (small caps feel) */
.section-title{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Table -> “rows as cards” */
.table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  font-size: 14px;
}

.table thead th{
  text-align:left;
  color: rgba(15,23,42,.65);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 0 10px 6px 10px;
}

.table tbody td{
  padding: 12px 10px;
  background: #ffffff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.table tbody tr td:first-child{
  border-left: 1px solid var(--line);
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
}

.table tbody tr td:last-child{
  border-right: 1px solid var(--line);
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
}

.table tbody tr{
  box-shadow: 0 6px 18px rgba(15,23,42,.06);
  transform: translateY(0);
  transition: box-shadow .12s ease, transform .12s ease, background .12s ease;
}

.table tbody tr:hover{
  box-shadow: 0 10px 24px rgba(15,23,42,.10);
  transform: translateY(-1px);
}

/* Inputs */
.input{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.16);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.input:focus{
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Password masking hint (applies when you add the attribute in HTML)
   input[type="password"] { font-family: inherit; }
*/

/* Buttons */
.btn{
  border: 1px solid rgba(15,23,42,.14);
  background: #ffffff;
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 6px 14px rgba(15,23,42,.06);
  transition: transform .06s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

.btn:hover{
  background: rgba(15,23,42,.03);
  box-shadow: 0 10px 18px rgba(15,23,42,.08);
}

.btn:active{
  transform: translateY(1px);
}

.btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary{
  background: var(--primary);
  border-color: rgba(0,0,0,.08);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(255,93,21,.18);
}

.btn-primary:hover{
  background: var(--primary-2);
}

.btn-danger{
  background: rgba(239,68,68,.10);
  border-color: rgba(239,68,68,.22);
  color: #7f1d1d;
}

.btn-danger:hover{
  background: rgba(239,68,68,.16);
}

/* Canvas layout */
.canvas-column{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

/* Toolbar */
.toolbar{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Tool pills (draggable) */
.tool-pill{
  display:flex;
  gap: 8px;
  align-items:center;
  border: 1px solid rgba(15,23,42,.14);
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: grab;
  user-select:none;
  font-size: 13px;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
}
.tool-pill:active{ cursor: grabbing; }

.dot{
  width:10px;
  height:10px;
  border-radius: 999px;
}

/* Canvas wrapper */
.flow-canvas-wrapper{
  position: relative;
  height: calc(100vh - 190px);
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15,23,42,.06);
}

/* Zoom controls */
.zoom-controls{
  position:absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display:flex;
  gap: 8px;
  align-items:center;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255,255,255,.90);
  border: 1px solid rgba(15,23,42,.12);
  box-shadow: 0 10px 24px rgba(15,23,42,.08);
}

.flow-canvas{
  position: absolute;
  inset: 0;
  overflow: auto;
}

.flow-content{
  position: relative;
  width: 3000px;
  height: 2200px;
}

/* Faint grid */
.flow-content::before{
  content:"";
  position:absolute;
  inset:0;
  background-image:
    linear-gradient(to right, rgba(15,23,42,.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15,23,42,.06) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: .55;
  pointer-events:none;
}

/* Nodes */
.flow-node{
  position:absolute;
  padding:0;
  border-radius:14px;
  border:1px solid var(--node-border, rgba(15,23,42,.14));
  background:var(--node-bg, rgba(255,93,21,.10));
  color:var(--text);
  box-shadow:0 10px 22px rgba(15,23,42,.10);
  cursor:grab;
  user-select:none;
  z-index:2;
}

.flow-node.selected{
  outline:3px solid var(--focus-ring);
}

.flow-node-body{
  width:100%;
  height:100%;
  padding:10px;
  border-radius:inherit;
  overflow:hidden;
}

.flow-node-header{
  display:flex;
  align-items:flex-start;
}

.flow-node-title{
  width:100%;
  min-width:0;
  font-weight:800;
  font-size:13px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.flow-node[data-type="note"] .flow-node-title{
  white-space:normal;
  overflow-wrap:anywhere;
  word-break:break-word;
  text-overflow:clip;
  line-height:1.35;
}

.flow-node-strategy,
.flow-node-sub{
  line-height:1.35;
  color:rgba(15,23,42,.72);
  overflow:hidden;
  overflow-wrap:anywhere;
}

.flow-node-strategy{
  margin-top:6px;
  font-size:10px;
  font-weight:700;
  white-space:normal;
}

.flow-node-sub{
  margin-top:6px;
  font-size:10px;
  white-space:pre-line;
}

.flow-node-details{
  white-space:normal;
}

.flow-node-detail + .flow-node-detail{
  margin-top:2px;
}

.flow-node-detail-label{
  font-weight:800;
}

.flow-node[data-type="voicemail"] .flow-node-sub{
  font-size:10px;
}

.flow-node-resize{
  position:absolute;
  right:-1px;
  bottom:-1px;
  z-index:8;
  display:grid;
  place-items:center;
  width:24px;
  height:24px;
  padding:0 1px 1px 0;
  border:0;
  border-radius:10px 0 13px 0;
  background:rgba(255,255,255,.92);
  color:rgba(15,23,42,.70);
  font:700 15px/1 system-ui,sans-serif;
  cursor:nwse-resize;
  opacity:0;
  transition:opacity .12s ease, background .12s ease;
}

.flow-node:hover .flow-node-resize,
.flow-node.selected .flow-node-resize,
.flow-node-resize:focus-visible{
  opacity:1;
}

.flow-node-resize:hover{
  background:#ffffff;
  color:var(--primary);
}

/* Ports */
.flow-node-port{
  position:absolute;
  width:12px;
  height:12px;
  border-radius:999px;
  background:#ffffff;
  border:2px solid rgba(255,93,21,.55);
  cursor:pointer;
  box-shadow:0 6px 14px rgba(15,23,42,.10);
  z-index:9;
}


.flow-node-port--top{ top:-7px; left:calc(50% - 6px); }
.flow-node-port--right{ right:-7px; top:calc(50% - 6px); }
.flow-node-port--bottom{ bottom:-7px; left:calc(50% - 6px); }
.flow-node-port--left{ left:-7px; top:calc(50% - 6px); }


/* SVG connectors */
.flow-connections{
  z-index: 1;
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  overflow: visible;
}

.conn{
  fill:none;
  stroke: rgba(15,23,42,.45);
  stroke-width: 2.0;
}

.conn.selected{
  stroke: rgba(255,93,21,.95);
  stroke-width: 2.6;
}

.conn-hit{
  fill:none;
  stroke: rgba(255,255,255,0);
  stroke-width: 18;
  cursor: pointer;
}

/* Waypoints */
.wp rect{
  fill: rgba(255,93,21,.95);
  stroke: rgba(0,0,0,.12);
  stroke-width: 1;
  rx: 3;
  ry: 3;
}
.wp-hit{
  fill: rgba(255,255,255,0);
  stroke: rgba(255,255,255,0);
  stroke-width: 1;
}

/* Properties panel helpers */
.hint{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

/* AA grid */
.aa-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.aa-row{
  display:grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items:center;
}

.aa-digit{
  font-size: 12px;
  color: rgba(15,23,42,.65);
}

.aa-full{
  grid-column: 1 / -1;
}

.aa-check{
  display:flex;
  gap: 8px;
  align-items:center;
  color: rgba(15,23,42,.72);
  font-size: 12px;
}

/* Radio cards */
.radio-group{
  display:grid;
  gap: 8px;
}

.radio-item{
  display:flex;
  gap: 8px;
  align-items:flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.12);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
}

.radio-item strong{
  display:block;
  font-size: 12px;
  color: rgba(15,23,42,.90);
  font-weight: 800;
}

.radio-item span{
  display:block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}

/* Status pills (optional use)
   <span class="pill pill-ok">OK</span>
*/
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.04);
  color: rgba(15,23,42,.75);
}

.pill-ok{
  background: rgba(22,163,74,.10);
  border-color: rgba(22,163,74,.22);
  color: rgba(22,163,74,.95);
}

.pill-warn{
  background: rgba(255,93,21,.12);
  border-color: rgba(255,93,21,.26);
  color: rgba(255,93,21,.95);
}

.pill-inactive{
  background: rgba(148,163,184,.18);
  border-color: rgba(148,163,184,.32);
  color: rgba(71,85,105,.95);
}

/* Monospace helper for IDs/tokens/debug */
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Debug blocks */
pre, code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

pre{
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  padding: 12px;
  overflow:auto;
  color: rgba(15,23,42,.90);
}

/* Rounded application tooltips */
.app-tooltip{
  position:fixed;
  z-index:10000;
  max-width:260px;
  padding:7px 10px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:9px;
  background:#111827;
  color:#ffffff;
  box-shadow:0 10px 24px rgba(15,23,42,.24);
  font-size:11px;
  font-weight:700;
  line-height:1.35;
  text-align:center;
  white-space:normal;
  pointer-events:none;
  transform:translate(-50%,calc(-100% - 8px));
}

.app-tooltip.is-below{
  transform:translate(-50%,8px);
}

/* Accessibility */
:focus-visible{
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== Improved application layout and states ===== */
.app-header{
  padding:12px 16px;
}

.app-header-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  width:100%;
  max-width:1800px;
  margin:0 auto;
}

.brand{
  color:var(--text);
  font-weight:800;
  font-size:17px;
  letter-spacing:.1px;
}

.brand:hover,
.btn:hover{
  text-decoration:none;
}

.app-nav{
  display:flex;
  gap:8px;
}

.app-main{
  width:100%;
  max-width:1800px;
}

.help-panel{
  width:100%;
  margin:16px 0 32px;
  scroll-margin-top:76px;
}

.help-panel-card{
  width:100%;
  padding:12px;
  background:#ffffff;
  border:1px solid #d1d5db;
  border-radius:16px;
  box-shadow:0 10px 30px rgba(15,23,42,.08);
}

.help-panel-details{
  display:block;
  width:100%;
  margin:0;
  border:1px solid var(--line);
  border-radius:12px;
  background:#ffffff;
  overflow:hidden;
}

.help-panel-summary{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  width:100%;
  min-height:64px;
  padding:12px 14px;
  background:#f8fafc;
  cursor:pointer;
  list-style:none;
}

.help-panel-summary::-webkit-details-marker{
  display:none;
}

.help-panel-summary::marker{
  content:"";
}

.help-panel-summary:hover{
  background:#f1f5f9;
}

.help-panel-details[open] > .help-panel-summary{
  border-bottom:1px solid var(--line);
}

.help-panel-summary-text{
  display:grid;
  gap:2px;
  min-width:0;
}

.help-panel-title{
  color:var(--text);
  font-size:15px;
  font-weight:800;
}

.help-panel-subtitle{
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
}

.help-panel-toggle{
  flex:0 0 auto;
  color:var(--primary);
  background:#ffffff;
}

.help-panel-content{
  width:100%;
  padding:20px;
  background:#ffffff;
}

.help-panel-content h2{
  margin:0 0 8px;
  color:var(--text);
  font-size:18px;
  font-weight:800;
}

.help-panel-content > p{
  margin:0 0 16px;
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

.help-topic-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}

.help-topic-card{
  padding:14px 16px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#f8fafc;
}

.help-topic-card h3{
  margin:0 0 8px;
  color:var(--text);
  font-size:13px;
  font-weight:800;
}

.help-topic-card ul{
  margin:0 0 0 18px;
  padding:0;
}

.help-topic-card li{
  margin:4px 0;
  color:var(--text);
  font-size:13px;
  line-height:1.45;
}


.sr-only{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

.notice{
  padding:11px 14px;
  border:1px solid;
  border-radius:12px;
  font-size:13px;
  line-height:1.4;
}

.notice-error{
  color:#991b1b;
  background:#fef2f2;
  border-color:#fecaca;
}

.notice-success{
  color:#166534;
  background:#f0fdf4;
  border-color:#bbf7d0;
}

.editor-page{
  display:grid;
  gap:10px;
}

.editor-layout{
  display:grid;
  grid-template-columns:minmax(0,1fr) 370px;
  gap:16px;
  width:100%;
  min-width:0;
}

.properties-card{
  align-self:start;
  position:sticky;
  top:74px;
  max-height:calc(100vh - 90px);
  min-width:0;
}

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

.properties-heading{
  display:flex;
  width:100%;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.properties-heading .card-title{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.save-state{
  flex:0 0 auto;
  color:var(--ok);
  font-size:11px;
  font-weight:700;
}

.save-state.is-dirty{
  color:#b45309;
}

.editor-actions{
  display:flex;
  width:100%;
  gap:6px;
  flex-wrap:wrap;
}

.properties-body{
  max-height:calc(100vh - 190px);
  padding:12px;
  overflow:auto;
}

.btn-compact{
  min-height:34px;
  padding:7px 10px;
  font-size:12px;
}

.loading-card,
.error-card{
  padding:24px;
}

.error-card{
  display:grid;
  justify-items:start;
  gap:14px;
}

.flow-list-card{
  width:100%;
}

.flow-list-header{
  align-items:flex-start;
}

.card-subtitle{
  margin-top:3px;
  color:var(--muted);
  font-size:13px;
}

.create-flow-form{
  display:grid;
  grid-template-columns:repeat(4,minmax(150px,1fr)) auto;
  gap:8px;
  width:min(1120px,78%);
}


.table-wrap{
  width:100%;
  overflow:auto;
  padding:0 12px 12px;
}

.table-link{
  padding:0;
  border:0;
  background:transparent;
  color:var(--primary);
  cursor:pointer;
  font:inherit;
  font-weight:800;
  text-align:left;
}

.table-link:hover{
  text-decoration:underline;
}

.table-actions{
  display:flex;
  justify-content:flex-end;
  gap:6px;
  white-space:nowrap;
}

.muted-cell{
  max-width:360px;
  color:var(--muted);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.empty-state{
  display:grid;
  justify-items:center;
  gap:4px;
  padding:42px 20px;
  color:var(--muted);
  text-align:center;
}

.empty-state strong{
  color:var(--text);
  font-size:16px;
}

.tool-pill{
  appearance:none;
  color:var(--text);
  font-family:inherit;
}

.flow-node:active{
  cursor:grabbing;
}

.flow-canvas-wrapper{
  min-width:0;
}

.user-editor{
  display:grid;
  gap:8px;
}

.user-add-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:8px;
  align-items:center;
}

.user-add-button{
  min-height:40px;
}

.user-list{
  display:grid;
  gap:6px;
}

.user-list-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) 32px;
  gap:8px;
  align-items:center;
  min-height:38px;
  padding:6px 6px 6px 10px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#ffffff;
}

.user-list-row span{
  min-width:0;
  overflow-wrap:anywhere;
}

.user-remove-button{
  display:grid;
  place-items:center;
  width:30px;
  height:30px;
  padding:0;
  border:1px solid rgba(239,68,68,.25);
  border-radius:8px;
  background:rgba(239,68,68,.08);
  color:#991b1b;
  font-size:20px;
  line-height:1;
  cursor:pointer;
}

.user-remove-button:hover{
  background:rgba(239,68,68,.16);
}

@media (max-width:1200px){
  .editor-layout{
    grid-template-columns:minmax(0,1fr) 330px;
  }

  .create-flow-form{
    width:100%;
  }

  .flow-list-header{
    flex-direction:column;
  }
}

@media (max-width:920px){
  .editor-layout{
    grid-template-columns:1fr;
  }

  .properties-card{
    position:static;
    max-height:none;
  }

  .properties-body{
    max-height:none;
  }

  .flow-canvas-wrapper{
    height:65vh;
    min-height:480px;
  }

  .create-flow-form{
    grid-template-columns:1fr;
  }

  .help-topic-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width:640px){
  .app-main{
    padding:10px;
  }

  .app-header{
    padding:10px;
  }

  .card-header{
    padding:10px;
  }

  .toolbar{
    flex-wrap:nowrap;
    overflow-x:auto;
    padding-bottom:4px;
  }

  .tool-pill{
    flex:0 0 auto;
  }

  .zoom-controls{
    right:6px;
    top:6px;
    gap:4px;
    padding:5px;
  }

  .import-json-panel,
  .help-panel-summary{
    align-items:stretch;
    flex-direction:column;
  }

  .import-json-panel .btn,
  .help-panel-toggle{
    width:100%;
    justify-content:center;
  }
}
