/* ============================================================
   AutoAI Labs — Infrastructure Management Portal
   Design: Sidebar + Header + Content layout
   Same design tokens as main site (--fire, --blue, etc.)
   ============================================================ */

/* ---------- LAYOUT ---------- */
.infra-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

/* ---------- SIDEBAR ---------- */
.infra-sidebar {
  width: 220px;
  min-height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.3s var(--ease);
}
.infra-sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--text);
}
.infra-sidebar__logo img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.infra-sidebar__logo-accent {
  background: var(--grad-fire);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.infra-sidebar__nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.infra-sidebar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  margin: 2px 8px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-family: inherit;
}
.infra-sidebar__item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.infra-sidebar__item.active {
  background: rgba(255, 140, 0, 0.08);
  color: var(--fire);
  border-left: 3px solid var(--fire);
  padding-left: 17px;
}
.infra-sidebar__icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.infra-sidebar__badge {
  margin-left: auto;
  background: rgba(255, 140, 0, 0.2);
  color: var(--fire);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.infra-sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}
.infra-sidebar__section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 20px 4px;
}
.infra-sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- MAIN AREA ---------- */
.infra-main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- HEADER ---------- */
.infra-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.infra-header__left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.infra-header__title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.infra-header__tenant-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}
.infra-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.infra-header__user {
  font-size: 0.82rem;
  color: var(--text-dim);
}
.infra-header__role {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 140, 0, 0.15);
  color: var(--fire);
}
.infra-header__logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.infra-header__logout:hover {
  border-color: var(--fire);
  color: var(--fire);
}

/* ---------- CONTENT ---------- */
.infra-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ---------- KPI CARDS ---------- */
.infra-kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.infra-kpi {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  flex: 1;
  min-width: 140px;
  transition: border-color 0.2s;
}
.infra-kpi:hover {
  border-color: rgba(255, 140, 0, 0.2);
}
.infra-kpi__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.infra-kpi__value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-head);
}
.infra-kpi__value--fire { color: var(--fire); }
.infra-kpi__value--green { color: #22C55E; }
.infra-kpi__value--blue { color: var(--blue); }
.infra-kpi__value--red { color: #EF4444; }

/* ---------- CARDS ---------- */
.infra-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.2s;
}
.infra-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}
.infra-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.infra-card__title {
  font-size: 1rem;
  font-weight: 700;
}

/* ---------- PILLS ---------- */
.infra-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.infra-pill--fire { background: rgba(255,140,0,0.15); color: #FF8C00; }
.infra-pill--green { background: rgba(34,197,94,0.15); color: #22C55E; }
.infra-pill--blue { background: rgba(59,130,246,0.15); color: #3B82F6; }
.infra-pill--red { background: rgba(239,68,68,0.15); color: #EF4444; }
.infra-pill--dim { background: rgba(136,136,160,0.15); color: #8888A0; }

/* ---------- SECTION ---------- */
.infra-section {
  margin-bottom: 24px;
}
.infra-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.infra-section__title {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-head);
}

/* ---------- ACTIVITY FEED ---------- */
.infra-feed {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.infra-feed__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 0.82rem;
  transition: background 0.2s;
}
.infra-feed__item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.infra-feed__time {
  color: var(--text-muted);
  min-width: 80px;
  font-size: 0.75rem;
}
.infra-feed__actor {
  font-weight: 600;
  min-width: 120px;
}
.infra-feed__action {
  color: var(--fire);
}

/* ---------- TENANT GRID ---------- */
.infra-tenant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ---------- AGENT WORKSPACE ---------- */
.agent-workspace {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* Session List (Left Panel) */
.agent-sessions {
  width: 260px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.agent-sessions__header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.agent-sessions__new-btn {
  width: 100%;
  padding: 10px;
  background: var(--grad-fire);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 8px;
}
.agent-sessions__search {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
}
.agent-sessions__search::placeholder { color: var(--text-muted); }
.agent-sessions__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.agent-sessions__item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.2s;
  border: 1px solid transparent;
}
.agent-sessions__item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.agent-sessions__item.active {
  background: rgba(255, 140, 0, 0.06);
  border-color: rgba(255, 140, 0, 0.2);
}
.agent-sessions__item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-sessions__item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.agent-sessions__item-status {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
}
.agent-sessions__item-status--active { background: #22C55E; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.agent-sessions__item-status--completed { background: var(--text-muted); }
.agent-sessions__item-status--failed { background: #EF4444; }
.agent-sessions__item-status--blocked { background: #EF4444; }

/* Chat Interface (Center Panel) */
.agent-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.agent-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
.agent-chat__project {
  font-weight: 700;
  font-size: 0.95rem;
}
.agent-chat__tenant {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.agent-chat__end-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.agent-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.agent-chat__welcome {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.agent-chat__welcome-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fire);
  margin-bottom: 12px;
  font-family: var(--font-head);
}
.agent-chat__welcome-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 500px;
  margin: 0 auto 24px;
}
.agent-chat__quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.agent-chat__quick-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.agent-chat__quick-btn:hover {
  border-color: var(--fire);
  color: var(--fire);
  background: rgba(255, 140, 0, 0.05);
}

/* Chat Messages */
.chat-msg {
  max-width: 85%;
  animation: chatFadeIn 0.3s ease;
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg--user {
  align-self: flex-end;
}
.chat-msg--user .chat-msg__bubble {
  background: rgba(255, 140, 0, 0.08);
  border: 1px solid rgba(255, 140, 0, 0.15);
  border-radius: 16px 16px 4px 16px;
}
.chat-msg--agent {
  align-self: flex-start;
}
.chat-msg--agent .chat-msg__bubble {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
}
.chat-msg--system {
  align-self: center;
  max-width: 100%;
}
.chat-msg--system .chat-msg__bubble {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
}
.chat-msg__bubble {
  padding: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.6;
}
.chat-msg__bubble pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 8px 0;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.chat-msg__bubble code {
  background: rgba(255, 140, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
.chat-msg__time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.chat-msg__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  padding: 0 4px;
}
.chat-msg--user .chat-msg__label { color: var(--fire); text-align: right; }
.chat-msg--agent .chat-msg__label { color: var(--blue); }

/* Step indicators inline in chat */
.chat-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.chat-step__icon { width: 16px; text-align: center; }
.chat-step--done .chat-step__icon { color: #22C55E; }
.chat-step--running .chat-step__icon { color: var(--fire); }
.chat-step--pending .chat-step__icon { color: var(--text-muted); }
.chat-step--failed .chat-step__icon { color: #EF4444; }

/* Chat Input */
.agent-chat__input {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
.agent-chat__textarea {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.agent-chat__textarea:focus {
  outline: none;
  border-color: var(--fire);
}
.agent-chat__textarea::placeholder { color: var(--text-muted); }
.agent-chat__send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--grad-fire);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: box-shadow 0.2s;
}
.agent-chat__send:hover {
  box-shadow: 0 0 20px rgba(255, 140, 0, 0.3);
}
.agent-chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Details Panel (Right) */
.agent-details {
  width: 280px;
  border-left: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}
.agent-details__section {
  margin-bottom: 20px;
}
.agent-details__section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.agent-details__item {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 3px 0;
}
.agent-details__danger {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-head);
}
.agent-details__step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ---------- EMPTY STATE ---------- */
.infra-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ---------- LOADING ---------- */
.infra-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.infra-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--fire);
  border-radius: 50%;
  animation: infraSpin 0.8s linear infinite;
}
@keyframes infraSpin { to { transform: rotate(360deg); } }

/* ---------- BUTTONS ---------- */
.infra-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  border: none;
}
.infra-btn--primary {
  background: var(--grad-fire);
  color: #fff;
}
.infra-btn--primary:hover { box-shadow: 0 0 20px rgba(255,140,0,0.2); }
.infra-btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.infra-btn--ghost:hover { border-color: var(--fire); color: var(--fire); }
.infra-btn--danger {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: #EF4444;
}
.infra-btn--sm { padding: 5px 12px; font-size: 0.78rem; }

/* ---------- BUDGET BAR ---------- */
.infra-budget-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.infra-budget-bar__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s var(--ease);
}

/* ---------- TABLE ---------- */
.infra-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.infra-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.infra-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
}
.infra-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- NEW SESSION MODAL ---------- */
.infra-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: infraFadeIn 0.2s ease;
}
@keyframes infraFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.infra-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 480px;
  max-width: 90vw;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.infra-modal__title {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-head);
  margin-bottom: 20px;
}
.infra-modal__field {
  margin-bottom: 16px;
}
.infra-modal__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}
.infra-modal__select,
.infra-modal__textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
}
.infra-modal__textarea { resize: vertical; min-height: 80px; }
.infra-modal__select:focus,
.infra-modal__textarea:focus { outline: none; border-color: var(--fire); }
.infra-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .infra-sidebar { width: 56px; }
  .infra-sidebar__item span:not(.infra-sidebar__icon) { display: none; }
  .infra-sidebar__logo span { display: none; }
  .infra-sidebar__section-label { display: none; }
  .infra-sidebar__badge { display: none; }
  .infra-sidebar__footer { display: none; }
  .infra-main { margin-left: 56px; }
  .agent-sessions { width: 0; display: none; }
  .agent-details { width: 0; display: none; }
}
