/* Delaware Cockpit IA — Design System v4.0 */

/* ── Delaware Brand Palette ────────────────────────────────── */
:root {
  --red:        #c42828;   /* Primary Red   */
  --red-dark:   #941914;   /* Sub Red 2     */
  --red-mid:    #ef463c;   /* Dot Red       */
  --red-light:  #ee7684;   /* Sub Red 1     */
  --red-bg:     #fff5f5;

  --teal:   #72c4bf;
  --purple: #ad9bcb;

  --ink:     #3c3c3c;      /* Text Gray     */
  --ink-mid: #6b7280;
  --ink-low: #9ca3af;

  --line:   #e5e7eb;
  --bg:     #f5f5f5;       /* Light Gray    */
  --surface:#ffffff;

  --r-sm:  8px;
  --r-md: 14px;
  --r-lg: 20px;

  --ease:   .18s ease;
  --spring: .32s cubic-bezier(.34,1.56,.64,1);
}

/* ── Reset ─────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { -webkit-font-smoothing:antialiased; }
body { font-family:'Inter',sans-serif; color:var(--ink); background:var(--bg); min-height:100vh; }
a    { text-decoration:none; color:inherit; }
button { font-family:inherit; cursor:pointer; }
ul { list-style:none; }
img,svg { display:block; }

/* ════════════════════════════════════════════════════════════
   PORTAL (index.html)
   ════════════════════════════════════════════════════════════ */

.portal-body { background: var(--bg); }

/* ── Header ─────────────────────────────────────────────────── */
.p-header {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.p-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Delaware SVG logo */
.dw-logo { display:flex; align-items:center; line-height:1; }
.dw-logo svg { overflow:visible; }

.p-header-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.p-header-product {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-mid);
  white-space: nowrap;
  letter-spacing: .02em;
}

/* Search */
.p-search {
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 14px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 99px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.p-search:focus-within {
  border-color: var(--red-mid);
  box-shadow: 0 0 0 3px rgba(196,40,40,.07);
  background: var(--surface);
}
.p-search svg   { color: var(--ink-low); flex-shrink:0; }
.p-search input {
  flex: 1; border: none; background: transparent;
  outline: none; font-size: .85rem; font-family: inherit; color: var(--ink);
}
.p-search input::placeholder { color: var(--ink-low); }

.p-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.p-admin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-mid);
  padding: 6px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--line);
  transition: all var(--ease);
}
.p-admin-btn:hover { border-color: var(--red-light); color: var(--red); }

.p-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.p-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.p-username {
  font-size: .82rem; font-weight: 600; color: var(--ink);
  white-space: nowrap; display: none;
}
@media(min-width:640px) { .p-username { display: block; } }

.p-logout-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 600; color: var(--ink-mid);
  padding: 6px 11px; border-radius: 99px;
  border: 1.5px solid var(--line); background: transparent;
  cursor: pointer; font-family: inherit; transition: all var(--ease);
  white-space: nowrap;
}
.p-logout-btn:hover { border-color: #fecaca; color: #ef4444; }

/* ── Category nav ───────────────────────────────────────────── */
.p-cat-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 60px;
  z-index: 90;
}
.p-cat-nav::-webkit-scrollbar { display: none; }

.p-cat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 99px;
  font-size: .82rem;
  font-weight: 600;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-mid);
  white-space: nowrap;
  transition: all var(--ease);
  cursor: pointer;
  flex-shrink: 0;
}
.p-cat-pill:hover { border-color: var(--red-light); color: var(--red); }
.p-cat-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ── Main content ───────────────────────────────────────────── */
.p-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}

/* ── Section ────────────────────────────────────────────────── */
.p-section { margin-bottom: 40px; }

.p-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-low);
  margin-bottom: 12px;
  padding-left: 2px;
}

/* ── App grid ───────────────────────────────────────────────── */
.p-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

/* ── App link (the card IS the link — no button) ────────────── */
.app-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--spring);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.app-link:hover {
  border-color: var(--red-light);
  box-shadow: 0 6px 20px rgba(196,40,40,.08);
  transform: translateY(-2px);
}

.app-link:hover .app-link-arrow { opacity: 1; transform: translateX(0); }

.app-link-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
  transition: background var(--ease);
}
.app-link:hover .app-link-icon { background: var(--red-bg); }

.app-link-img  { width: 30px; height: 30px; object-fit: contain; }
.app-link-emoji{ line-height: 1; }

.app-link-body { flex: 1; min-width: 0; }

.app-link-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-link-desc {
  font-size: .75rem;
  color: var(--ink-mid);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-link-arrow {
  color: var(--red);
  opacity: 0;
  transform: translateX(-6px);
  transition: all var(--ease);
  flex-shrink: 0;
}

/* Tags */
.app-link-tag {
  font-size: .58rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.tag-new  { background: var(--red-bg);  color: var(--red); }
.tag-beta { background: #f5f3ff; color: #7c3aed; }

/* Empty state */
.p-empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--ink-low);
}
.p-empty svg { margin: 0 auto 14px; opacity: .3; }
.p-empty p   { font-size: .9rem; margin-bottom: 10px; }
.p-empty a   { color: var(--red); font-weight: 600; font-size: .85rem; }

/* ════════════════════════════════════════════════════════════
   ADMIN (admin.html)
   ════════════════════════════════════════════════════════════ */

.admin-body { background: var(--bg); min-height: 100vh; }

.admin-shell { display: flex; min-height: 100vh; }

/* Admin sidebar — Sub Red 2 (#941914) da paleta Delaware */
.admin-sb {
  width: 220px;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  background: var(--red-dark);   /* #941914 */
  display: flex;
  flex-direction: column;
}

.admin-sb-brand {
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

/* Admin logo — white version (red dot + white text) */
.admin-sb-brand .dw-logo-white svg text { fill: #fff; }

.admin-logo-wrap {
  display: flex;
  align-items: center;
  gap: 0;
}

.admin-sb-tag {
  font-size: .6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.4);
  margin-top: 4px;
}

.admin-sb-nav { flex: 1; padding: 10px; }

.admin-sb-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 13px; margin-bottom: 2px;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  font-size: .84rem; font-weight: 500;
  color: rgba(255,255,255,.55);
  cursor: pointer; transition: all var(--ease); text-align: left;
}
.admin-sb-item:hover  { background: rgba(0,0,0,.2); color: #fff; }
.admin-sb-item.active { background: rgba(0,0,0,.25); color: #fff; }

.admin-sb-footer {
  padding: 14px 10px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.admin-back {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: var(--r-sm);
  font-size: .82rem; font-weight: 500;
  color: rgba(255,255,255,.45); transition: all var(--ease);
}
.admin-back:hover { background: rgba(0,0,0,.15); color: rgba(255,255,255,.8); }

/* Admin main */
.admin-main { margin-left: 220px; display: flex; flex-direction: column; min-height: 100vh; }

.admin-topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 28px; gap: 6px;
  position: sticky; top: 0; z-index: 90;
}
.admin-topbar-title    { font-size: 1rem; font-weight: 700; color: var(--ink); }
.admin-topbar-subtitle { font-size: .8rem; color: var(--ink-low); }

.admin-content { padding: 28px; flex: 1; }

/* ── Panel ──────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.panel-head {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--bg);
}
.panel-ico {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--red-bg); color: var(--red);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.panel-title { font-size: .95rem; font-weight: 700; color: var(--ink); }
.panel-sub   { font-size: .78rem; color: var(--ink-low); margin-top: 2px; }
.panel-body  { padding: 24px; }

/* ── Form ───────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field     { display: flex; flex-direction: column; gap: 6px; }
.field.full{ grid-column: span 2; }
.field label{ font-size: .75rem; font-weight: 600; color: var(--ink-mid); }
.field input,.field select {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  font-size: .875rem; font-family: inherit;
  color: var(--ink); background: var(--surface); outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input:focus,.field select:focus {
  border-color: var(--red-mid);
  box-shadow: 0 0 0 3px rgba(196,40,40,.07);
}
.field input::placeholder { color: var(--ink-low); }

/* Icon picker */
.icon-wrap { background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
.icon-grid  {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px; max-height: 150px; overflow-y: auto;
}
.icon-item {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid transparent;
  border-radius: var(--r-sm); cursor: pointer; transition: all var(--ease);
}
.icon-item svg { width: 20px; height: 20px; color: var(--red); }
.icon-item:hover    { border-color: var(--red-light); transform: scale(1.1); }
.icon-item.selected { border-color: var(--red); background: var(--red-bg); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: .85rem; font-weight: 600;
  padding: 10px 18px; border-radius: var(--r-sm); border: none;
  cursor: pointer; transition: all var(--ease); white-space: nowrap;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); box-shadow: 0 4px 14px rgba(196,40,40,.3); transform: translateY(-1px); }
.btn-ghost   { background: transparent; color: var(--ink-mid); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink-low); color: var(--ink); }
.btn-danger  { background: #fef2f2; color: #ef4444; border: 1.5px solid #fecaca; font-size: .75rem; padding: 6px 11px; }
.btn-danger:hover { background: #fee2e2; }
.btn-edit    { background: #f0f9ff; color: #0284c7; border: 1.5px solid #bae6fd; font-size: .75rem; padding: 6px 11px; display:flex; align-items:center; gap:4px; }
.btn-edit:hover  { background: #e0f2fe; }

.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.inline-row { display: flex; gap: 12px; align-items: flex-end; }
.inline-row .field { flex: 1; }

/* Structure list */
.cat-block {
  background: var(--bg); border: 1.5px solid var(--line);
  border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 10px;
}
.cat-block-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cat-block-name {
  font-size: .88rem; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.cat-block-name::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); display: block;
}

.app-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 6px;
}
.app-row-name { flex: 1; font-size: .82rem; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-row-url  { font-size: .7rem; color: var(--ink-low); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.no-apps      { font-size: .78rem; color: var(--ink-low); padding: 4px 2px; font-style: italic; }

.divider { border: none; border-top: 1.5px solid var(--line); margin: 20px 0; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: var(--r-md);
  font-size: .83rem; font-weight: 500;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  transform: translateY(70px); opacity: 0;
  transition: all .28s cubic-bezier(.34,1.56,.64,1);
  max-width: 320px;
}
.toast.ok   { border-left: 4px solid var(--teal); }
.toast.err  { border-left: 4px solid var(--red-mid); }
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Responsive ─────────────────────────────────────────────── */
@media(max-width:768px){
  .p-header { padding: 0 16px; gap: 12px; }
  .p-header-product { display: none; }
  .p-header-sep { display: none; }
  .p-cat-nav { padding: 10px 16px; }
  .p-content { padding: 20px 16px 40px; }
  .p-apps-grid { grid-template-columns: 1fr; }

  .admin-sb { transform: translateX(-100%); transition: transform var(--ease); }
  .admin-sb.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: span 1; }
  .inline-row { flex-direction: column; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-low); }
