/* Components: toolbars, cards, sections, page headers, tabs, env list, modal */

/* Flash messages */
.flash{
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: flash-slide-in 0.3s ease-out;
}
@keyframes flash-slide-in{
  from{ opacity:0; transform: translateY(-10px); }
  to{ opacity:1; transform: translateY(0); }
}
.flash.notice{
  background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(34,197,94,0.08));
  border-color: rgba(34,197,94,0.5);
  color: #86efac;
}
.flash.alert{
  background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.08));
  border-color: rgba(239,68,68,0.5);
  color: #fca5a5;
}
.flash.error{
  background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.08));
  border-color: rgba(239,68,68,0.5);
  color: #fca5a5;
}

/* Session toolbar */
.session-bar{ display:flex; align-items:center; gap:16px; margin-bottom: 0; }
.session-bar .select{ 
  flex:1; 
  min-width:0; 
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* In-card header toolbar */
.toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap: wrap;
}
.toolbar p{ margin:0; }
.toolbar .session-bar{ flex:0 0 auto; max-width:100%; }
.toolbar .session-bar .select{
  flex: 0 0 auto;
  width: auto;
  min-width: 220px;
  max-width: 420px;
}
.toolbar .session-bar .btn{ flex:0 0 auto; }
@media (max-width: 720px){
  .toolbar{ flex-wrap:wrap; }
  .toolbar .session-bar{ width:100%; flex-wrap: wrap; gap:10px; }
  .toolbar .session-bar .select{ min-width: 0; width:100%; flex: 1 1 auto; }
  .toolbar .session-bar .btn{ width:100%; }
}

/* Modal (generic) */
.modal-overlay{ position:fixed; inset:0; background: rgba(4,8,18,0.5); backdrop-filter: blur(6px) saturate(140%); display:none; align-items:center; justify-content:center; z-index:1000; }
.modal-overlay[aria-hidden="true"]{ display:none }
.modal-overlay[aria-hidden="false"], .modal-overlay.show{ display:flex }
.modal{
  width:min(520px, 92vw);
  padding:20px; border-radius:14px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(16,23,44,0.86), rgba(13,20,40,0.7));
  box-shadow: var(--glow);
}
.modal h3{ margin:0 0 12px; font-size:18px; }
.modal .actions{ display:flex; gap:10px; justify-content:flex-end; }
.modal form{ display:grid; gap:12px; }

/* Sections, grid, and cards */
.section{ padding: 8px 0 84px; }
.section h2{ text-align:center; font-family: Orbitron, Inter, sans-serif; font-size: clamp(22px, 3vw, 28px); letter-spacing:0.4px; margin-bottom: 18px; }
.grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px){ .grid{ grid-template-columns: 1fr; } }
.card{ position:relative; padding:22px; border-radius:16px; background: linear-gradient(180deg, rgba(16,23,44,0.7), rgba(13,20,40,0.55)); border:1px solid var(--border); box-shadow: var(--shadow); transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; overflow:hidden; }
.card:hover{ transform: translateY(-3px); box-shadow: var(--glow); border-color: rgba(99,102,241,0.45); }
.card .icon{ width:44px; height:44px; border-radius:12px; display:grid; place-items:center; margin-bottom:10px; background: radial-gradient(120% 120% at 0% 0%, rgba(168,85,247,0.22), transparent 60%),
 radial-gradient(120% 120% at 100% 0%, rgba(6,182,212,0.22), transparent 60%),
 linear-gradient(180deg, rgba(23,32,56,0.85), rgba(18,26,48,0.6));
 border:1px solid rgba(99,102,241,0.4);
 box-shadow: 0 0 0 1px rgba(255,255,255,0.03) inset;
}
.card h3{ margin:6px 0 6px; font-size:18px; letter-spacing:0.3px; }
.card p{ margin:0; color:var(--muted); line-height:1.6 }

/* Create App card (dashboard) */
.create-card{ max-width: 780px; margin: 10px auto 24px; }
.create-card h3{ margin: 0 0 2px; font-size: 20px; }
.create-card .actions{ display:flex; gap:10px; justify-content:flex-start; }
.create-card::before{ content:""; position:absolute; inset:-1px; border-radius:inherit; pointer-events:none;
  background: conic-gradient(from 180deg at 50% 50%, rgba(99,102,241,0.35), rgba(168,85,247,0.35), rgba(6,182,212,0.35), rgba(99,102,241,0.35));
  filter: blur(18px); opacity:0; transition: opacity .25s ease; }
.create-card:focus-within::before{ opacity:.85; }

/* Desktop sizing for the Create App card */
@media (min-width: 1024px){
  .create-card{ max-width: 1040px; padding: 28px; }
  .create-card h3{ font-size: 24px; }
  #new-app-message{ min-height: 160px; }
  .section form {
    max-width: 820px;
}

}

/* Page + App header (compact) */
.page{ margin: 10px 0 0; }
.page > .card{ margin-top: 16px; }
.app-header{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin: 4px 0 12px; flex-wrap: nowrap; }
.app-header .title{ display:flex; align-items:center; gap:12px; min-width:0; flex:1 1 auto; }
.app-header .actions{ min-width:0; }
.app-header .title .back{ flex:0 0 auto; }
.app-header .back{ padding:8px 12px; }
.app-header .icon{ width:36px; height:36px; border-radius:10px; display:grid; place-items:center; margin:0; flex:0 0 auto;
  background: radial-gradient(120% 120% at 0% 0%, rgba(168,85,247,0.18), transparent 60%),
              radial-gradient(120% 120% at 100% 0%, rgba(6,182,212,0.18), transparent 60%),
              linear-gradient(180deg, rgba(23,32,56,0.7), rgba(18,26,48,0.55));
  border:1px solid rgba(99,102,241,0.35);
}
.app-header h1{ font-size: 22px; letter-spacing:0.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.app-header .actions{ display:flex; gap:8px; flex-wrap:nowrap; white-space: nowrap; overflow-x:auto; }
.app-header .actions > *{ flex:0 0 auto; }
@media (max-width: 720px){
  .app-header{ flex-direction: row; align-items: center; gap:10px; }
  .app-header .title{ width:auto; }
  .app-header h1{ font-size:20px; }
  .app-header .actions{ width:auto; justify-content:flex-end; overflow-x:auto; }
  .app-header .actions .stack{ flex-wrap: nowrap; }
  .app-header .actions small{ display:none; }
  /* Slightly tighter buttons on mobile */
  .btn{ padding:10px 14px; }
  /* Stack environment row contents and make Visit full-width for easier tapping */
  .env-row{ flex-direction: column; align-items: stretch; gap:10px; }
  .env-row .btn{ width:100%; }
}

/* Tabs */
.tabs{ display:flex; gap:8px; margin-bottom:12px; border-bottom:1px solid var(--border); padding-bottom:8px; }

/* App Environments */
.env-list{ margin-top:10px; display:grid; gap:10px; }
.env-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:12px 14px; border:1px solid var(--border); border-radius:12px;
  background: linear-gradient(180deg, rgba(17,25,46,0.6), rgba(13,20,40,0.45));
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.env-row:hover{ transform: translateY(-1px); box-shadow: var(--glow); border-color: rgba(99,102,241,0.35); }
.env-info{ display:flex; align-items:center; gap:10px; min-width:0; font-size:15px; }
.env-dot{
  width:10px; height:10px; border-radius:999px;
  background:
    radial-gradient(120% 120% at 50% 30%, rgba(168,85,247,0.8), transparent 60%),
    radial-gradient(120% 120% at 50% 70%, rgba(6,182,212,0.7), transparent 60%);
  border:1px solid rgba(99,102,241,0.5);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
  flex:0 0 auto;
}
.env-name{ font-weight:600; letter-spacing:0.2px; }
.env-sep{ color: var(--muted); }
.env-status{ color: var(--muted); }

/* Tags used in app cards and elsewhere */
.tag{ display:inline-flex; align-items:center; gap:10px; padding:8px 12px; border:1px solid var(--border); border-radius:999px; background: linear-gradient(180deg, rgba(13,20,40,0.65), rgba(10,15,30,0.35)); box-shadow: var(--shadow); font-size:13px; color:var(--muted); }
.tag-dot{ width:8px; height:8px; border-radius:50%; background: linear-gradient(90deg,var(--grad-1),var(--grad-2),var(--grad-3)); box-shadow: var(--glow); }

/* Environment tags block inside cards */
.env-tags{ margin-top:10px; display:flex; gap:8px; flex-wrap:wrap; }

/* Mobile tweaks for dashboard cards */
@media (max-width: 720px){
  .card{ padding:18px; }
  .create-card .actions{ flex-direction: column; }
  .create-card .actions .btn{ width:100%; }
  /* Make Visit buttons full-width for easier tapping */
  .env-tags .btn{ width:100%; }
}

/* Avatar button + floating menu (header) */
.avatar{ display:inline-grid; place-items:center; border-radius:999px; font-weight:700; font-size:13px; color:#e6eaff;
  background: linear-gradient(180deg, rgba(23,32,56,0.9), rgba(18,26,48,0.7));
  border:1px solid rgba(99,102,241,0.45); box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset; }
.avatar-btn{ padding:0; border:0; background:transparent; cursor:pointer; display:inline-flex; align-items:center; }
details.menu{ position:relative; }
details.menu > summary{ list-style:none; }
details.menu > summary::-webkit-details-marker{ display:none }
.menu .menu-list{ position:absolute; right:0; top: calc(100% + 10px); min-width: 260px; padding:10px; border-radius:14px; z-index: 200;
  background: linear-gradient(180deg, rgba(16,23,44,0.96), rgba(13,20,40,0.86));
  border:1px solid var(--border); box-shadow: var(--glow); display:block; }
.menu .menu-header{ display:flex; align-items:center; gap:10px; padding:8px 10px 12px; }
.menu .menu-header .name{ font-weight:700; }
.menu .menu-list hr{ border:0; border-top:1px solid var(--border); margin:6px 0 8px; }
.menu .menu-list .menu-item{ display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%;
  padding:10px 12px; border-radius:10px; text-decoration:none; color:var(--text); background:transparent; border:1px solid transparent; }
.menu .menu-list .menu-item:hover{ background: linear-gradient(180deg, rgba(17,25,46,0.6), rgba(13,20,40,0.45)); border-color: rgba(99,102,241,0.35); }
.menu .menu-list .menu-item.danger{ color:#ff9595; border-color: rgba(255,149,149,0.2); }
.menu .menu-list form.button_to{ margin:0; }

.green-text{ color: #00ff32; }
