/* ========= Branding ========= */
.tm-branding-link{
  display:flex;
  align-items:center;
  gap:10px;
}
.tm-branding-logo{
  height:34px;
  width:auto;
}

/* ========= Admin index: cards + clean layout ========= */
body.tm-admin-index #content-main > div{
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 12px 0;
  background: rgba(255,255,255,.03);
  overflow: hidden;
}

body.tm-admin-index #content-main table{
  width: 100%;
  border-collapse: collapse;
}

body.tm-admin-index #content-main th,
body.tm-admin-index #content-main td{
  padding: 8px 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

body.tm-admin-index #content-main tr:hover td,
body.tm-admin-index #content-main tr:hover th{
  background: rgba(255,255,255,.04);
}

body.tm-admin-index #content-main table caption{
  display: block;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* ========= Toolbar ========= */
body.tm-admin-index .tm-admin-toolbar{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  margin: 0 0 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0;
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

body.tm-admin-index .tm-admin-toolbar input[type="search"]{
  padding: 8px 34px 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.04);
  color: inherit;
  min-width: 240px;
  outline: none;
}

/* ========= Search wrap + clear button ========= */
body.tm-admin-index .tm-search-wrap{
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 240px;
  flex: 0 1 auto;
}

body.tm-admin-index .tm-search-clear{
  position:absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.25);
  color: inherit;
  cursor: pointer;
  display:none;
  align-items:center;
  justify-content:center;
  line-height: 1;
  padding: 0;
  user-select:none;
}

body.tm-admin-index .tm-search-clear.is-on{
  display:inline-flex;
}

/* ========= Small counter pill ========= */
body.tm-admin-index .tm-count-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  user-select:none;
}

/* ========= Recent dropdown ========= */
body.tm-admin-index .tm-recent-wrap{
  position: relative;
  display: inline-flex;
  align-items: center;
}

body.tm-admin-index .tm-recent-menu{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 320px;
  max-width: 520px;
  max-height: 320px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,15,25,.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  display:none;
  padding: 6px;
  z-index: 99;
}

body.tm-admin-index .tm-recent-menu.is-on{
  display:block;
}

body.tm-admin-index .tm-recent-item{
  display:block;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

body.tm-admin-index .tm-recent-item:hover{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}

body.tm-admin-index .tm-recent-empty{
  padding: 10px;
  opacity: .8;
  font-size: 12px;
}

/* ========= App header ========= */
body.tm-admin-index .app-collapsible__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  user-select:none;
  padding: 6px 8px;
  border-radius: 10px;
  min-width: 0;
  flex-wrap: nowrap;
  width: 100%;
  box-sizing: border-box;
}

body.tm-admin-index .app-collapsible__head:hover{
  background: rgba(255,255,255,.06);
}

body.tm-admin-index .app-collapsible__title{
  font-weight: 800;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

body.tm-admin-index .app-collapsible__title:hover{
  background: rgba(255,255,255,.06);
  text-decoration: underline;
}

body.tm-admin-index .app-collapsible__actions{
  display:flex;
  gap:8px;
  align-items:center;
  flex: 0 0 auto;
  max-width: 55%;
}

body.tm-admin-index .app-collapsible__btn,
body.tm-admin-index .app-collapsible__pin{
  font-size: 12px;
  padding: 2px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}

body.tm-admin-index .app-collapsible__pin.is-on{
  background: rgba(255,255,255,.10);
}

body.tm-admin-index .app-collapsible__models.is-collapsed{
  display:none;
}

/* ========= Favorites highlight ========= */
body.tm-admin-index .app-is-favorite{
  border-color: rgba(255,215,0,.35) !important;
}

/* ========= Focus banner ========= */
body.tm-admin-index .tm-focus-banner{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  margin: 0 0 12px;
  display:none;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

body.tm-admin-index .tm-focus-banner.is-on{
  display:flex;
}

/* ========= GLOBAL FOCUS ========= */
body.tm-admin-focus .module.app-list .app.tm-app-other{
  display:none !important;
}
body.tm-admin-focus #nav-sidebar .app-nav.tm-app-other{
  display:none !important;
}

/* ========= AUTO CURRENT-APP SIDEBAR ========= */
body.tm-admin-app-only .module.app-list .app.tm-app-other{
  display:none !important;
}
body.tm-admin-app-only #nav-sidebar .app-nav.tm-app-other{
  display:none !important;
}

/* ========= Pills ========= */
body.tm-admin .tm-admin-focus-pill,
body.tm-admin .tm-admin-app-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  margin-left: 10px;
  font-size: 12px;
  line-height: 1.2;
  max-width: 55vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: middle;
}

body.tm-admin .tm-admin-focus-pill a,
body.tm-admin .tm-admin-app-pill a{
  text-decoration: underline;
}

/* ========= Responsive pills ========= */
@media (max-width: 900px){
  body.tm-admin .tm-admin-focus-pill,
  body.tm-admin .tm-admin-app-pill{
    max-width: 78vw;
  }
}

@media (max-width: 640px){
  #header{
    flex-wrap: wrap;
    align-items: flex-start;
  }

  #header #branding{
    display:flex;
    align-items:flex-start;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
  }

  body.tm-admin .tm-admin-focus-pill,
  body.tm-admin .tm-admin-app-pill{
    margin-left: 0;
    max-width: 100%;
    width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 14px;
  }

  body.tm-admin .tm-admin-focus-pill strong,
  body.tm-admin .tm-admin-app-pill strong{
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  body.tm-admin .tm-admin-focus-pill a,
  body.tm-admin .tm-admin-app-pill a{
    white-space: nowrap;
  }
}

/* ========= ONLY WHEN NEEDED: long names wrap ========= */
body.tm-admin-index .app-collapsible__head.tm-wrap{
  flex-wrap: wrap;
  align-items: flex-start;
  width: 100%;
}

body.tm-admin-index .app-collapsible__head.tm-wrap .app-collapsible__actions{
  order: 1;
  margin-left: auto;
  max-width: 100%;
  width: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 6px;
  column-gap: 6px;
}

body.tm-admin-index .app-collapsible__head.tm-wrap .app-collapsible__title{
  order: 2;
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.15;
  padding: 6px 6px;
  box-sizing: border-box;
}

/* ========= Mobile ========= */
@media (max-width: 640px){
  body.tm-admin-index .app-collapsible__head{
    padding: 10px 8px;
    gap: 6px;
  }

  body.tm-admin-index .app-collapsible__actions{
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
    column-gap: 6px;
  }

  body.tm-admin-index .app-collapsible__btn,
  body.tm-admin-index .app-collapsible__pin{
    font-size: 12px;
    padding: 4px 10px;
  }

  body.tm-admin-index .tm-admin-toolbar{
    gap: 8px;
    padding: 10px 0;
  }

  body.tm-admin-index .tm-search-wrap{
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  body.tm-admin-index .tm-admin-toolbar input[type="search"]{
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  body.tm-admin-index .tm-admin-toolbar > *{
    flex: 0 1 auto;
  }

  body.tm-admin-index .tm-admin-toolbar button{
    max-width: 100%;
  }

  body.tm-admin-index .tm-recent-wrap{
    width: auto;
  }

  body.tm-admin-index .tm-recent-menu{
    left: auto;
    right: 0;
    min-width: min(92vw, 420px);
    max-width: min(92vw, 520px);
  }

  body.tm-admin-index .tm-focus-banner{
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
  }

  body.tm-admin-index .tm-focus-banner > div{
    flex: 1 1 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ========= Ultra small ========= */
@media (max-width: 420px){
  body.tm-admin-index .app-collapsible__btn,
  body.tm-admin-index .app-collapsible__pin{
    padding: 4px 8px;
    font-size: 12px;
  }

  body.tm-admin-index .tm-admin-toolbar{
    gap: 6px;
  }

  body.tm-admin-index .tm-count-pill{
    width: 100%;
    justify-content: center;
  }
}

/* ========= Reduce motion ========= */
body.tm-reduce-motion *{
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* ========= Scroll-to-top ========= */
body.tm-admin .tm-scrolltop{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display:none;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.35);
  color: inherit;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  max-width: calc(100vw - 32px);
}

body.tm-admin .tm-scrolltop.is-on{
  display:inline-flex;
}

@media (max-width: 420px){
  body.tm-admin .tm-scrolltop{
    right: 10px;
    bottom: 10px;
  }
}

/* ========= Logo animation ========= */
@keyframes tm_admin_flip {
  0%   { transform: rotateY(0); }
  50%  { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}

body.tm-admin-index #site-name .tm-admin-logo-spin{
  display: inline-block;
  border-radius: 10px;
  transform-style: preserve-3d;
  animation: tm_admin_flip 7s ease-in-out infinite;
  will-change: transform;
}

body.tm-admin-index #site-name a:hover .tm-admin-logo-spin{
  animation-duration: 2s;
}

@media (prefers-reduced-motion: reduce){
  body.tm-admin-index #site-name .tm-admin-logo-spin{
    animation: none !important;
  }
}

/* ========= Admin forms/lists responsiveness ========= */
body.tm-admin .submit-row{
  flex-wrap: wrap;
  gap: 8px;
}

body.tm-admin .submit-row input,
body.tm-admin .submit-row a{
  max-width: 100%;
}

/* ========= Prevent sidebar horizontal scroll ========= */
@media (max-width: 640px){
  body.tm-admin #nav-sidebar{
    max-width: 100%;
  }

  body.tm-admin #content{
    min-width: 0;
  }

  body.tm-admin #content-main{
    min-width: 0;
  }
}