/* Project styles layered on top of PicoCSS. */
:root { --pico-font-size: 100%; }

/* ---- Navigation: language dropdown + hamburger ---- */
.nav-right { display: flex; align-items: center; gap: .6rem; }
.nav-right > li { padding: 0; }

/* Language selector: compact dropdown (text names, no flags) */
.lang-select {
  width: auto; margin: 0; line-height: 1.2;
  padding: .35rem 1.8rem .35rem .6rem; font-size: .85rem;
}

/* Hamburger: hidden on desktop, clean box on mobile, no PicoCSS caret */
.nav-hamburger { display: none; }
.nav-hamburger .dropdown { margin: 0; }
.nav-hamburger summary {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.6rem; height: 2.6rem; padding: 0; font-size: 1.4rem; line-height: 1;
  border: 1px solid var(--pico-muted-border-color); border-radius: 10px;
  cursor: pointer; list-style: none; background: var(--pico-card-background-color);
}
.nav-hamburger summary::-webkit-details-marker { display: none; }
.nav-hamburger summary::after { content: none !important; background: none !important; }

/* Collapse nav to hamburger early enough for tablets (iPad Air portrait = 820px) */
@media (max-width: 1024px) {
  .nav-desktop { display: none !important; }
  .nav-hamburger { display: block; }
}

@media (max-width: 768px) {
  /* ---- Stacked "card" tables on small screens ---- */
  table.responsive thead { display: none; }
  table.responsive,
  table.responsive tbody,
  table.responsive tr,
  table.responsive td { display: block; width: 100%; }
  table.responsive tr {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 12px; padding: .6rem .8rem; margin-bottom: .9rem;
    background: var(--pico-card-background-color);
  }
  table.responsive td {
    display: flex; align-items: center; gap: 1rem;
    padding: .35rem 0; border: none !important;
  }
  table.responsive td::before {
    content: attr(data-label);
    flex: 0 0 38%; font-weight: 600; color: var(--pico-muted-color);
    white-space: nowrap;
  }
  table.responsive td[data-label=""]::before { content: none; }
  /* Controls take the remaining width, not a squished sliver */
  table.responsive td > input,
  table.responsive td > select,
  table.responsive td > form,
  table.responsive td > details { flex: 1 1 auto; margin: 0; min-width: 0; }
  table.responsive td[data-label=""] { flex-wrap: wrap; gap: .5rem; }
}

/* ---- Subscription dashboard card ---- */
.sub-card { border-radius: 14px; }
.sub-card__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
}
.plan-name { font-size: 1.5rem; font-weight: 700; }
.plan-price { margin-left: .5rem; color: var(--pico-muted-color); }
.sub-card__body { margin-top: .75rem; }
.expiry { margin: .25rem 0; }
.days { font-weight: 600; margin: .25rem 0; }
.days--ok   { color: var(--pico-color-green-500); }
.days--warn { color: #d9a300; }
.days--late { color: var(--pico-color-red-500); }
.manager { margin-top: .75rem; color: var(--pico-muted-color); }
.sub-card__foot { margin-top: 1rem; }
.pending { color: #d9a300; font-weight: 600; }
.renew-box summary { width: fit-content; }

/* ---- Status badge ---- */
.badge {
  display: inline-block; padding: .25rem .7rem; border-radius: 999px;
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge--active    { background: rgba(46,160,67,.18);  color: var(--pico-color-green-500); }
.badge--expired   { background: rgba(220,53,69,.18);  color: var(--pico-color-red-500); }
.badge--suspended { background: rgba(217,163,0,.18);  color: #d9a300; }
.badge--cancelled { background: rgba(120,120,120,.2); color: var(--pico-muted-color); }

/* ---- Library picker summary (plans) ---- */
.lib-sum {
  white-space: nowrap; font-size: .9rem; cursor: pointer;
  list-style: none; display: inline-flex; align-items: center; gap: .35rem;
}
.lib-sum::-webkit-details-marker { display: none; }
.lib-sum::after { content: none !important; background: none !important; }
.lib-sum::before {
  content: "▸"; font-size: .75rem; color: var(--pico-muted-color);
  transition: transform .15s ease;
}
details[open] > .lib-sum::before { transform: rotate(90deg); }

/* ---- Inline validate form (requests table) ---- */
.inline-validate { display: flex; gap: .4rem; margin: 0; align-items: center; }
.inline-validate input { margin: 0; }
.inline-validate button { margin: 0; white-space: nowrap; }

/* ---- Audit feed (compact, mobile-friendly) ---- */
.audit-feed { list-style: none; padding: 0; margin: 0; }
.audit-feed li { list-style: none; border-bottom: 1px solid #2a2a30; }
.audit-item > summary {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  padding: .5rem 0; cursor: pointer; list-style: none;
}
.audit-item > summary::-webkit-details-marker { display: none; }
.audit-item > summary::before {
  content: "\25B8"; flex: 0 0 auto; opacity: .5; font-size: .75rem;
  transition: transform .15s; line-height: 1.4;
}
.audit-item[open] > summary::before { transform: rotate(90deg); }
.af-main { flex: 1 1 auto; min-width: 0; font-size: .92rem; line-height: 1.4; }
.af-target { color: var(--pico-primary); font-weight: 600; }
.af-detail { opacity: .65; font-size: .85em; }
.af-when { flex: 0 0 auto; font-size: .78rem; opacity: .55; white-space: nowrap; }
.af-body {
  margin: 0 0 .6rem 1.1rem; padding-left: .6rem; font-size: .85rem;
  border-left: 2px solid var(--pico-muted-border-color, #2a2a30);
}
.af-body code { font-size: .9em; opacity: .8; }
@media (max-width: 768px) {
  .af-when { flex-basis: 100%; margin: .1rem 0 0 1.25rem; }
}

/* ---- Plex sign-in button ---- */
.btn-plex {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; background: #e5a00d; color: #1f1f1f; border: 1px solid #e5a00d;
  font-weight: 700; padding: .8rem 1rem;
}
.btn-plex:hover, .btn-plex:focus { background: #cc8f0c; border-color: #cc8f0c; color: #1f1f1f; }
.btn-plex svg { width: 1.05rem; height: 1.05rem; fill: currentColor; flex: 0 0 auto; }

/* ---- Compact action buttons (tables) ---- */
.row-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: nowrap; }
.row-actions > *, .row-actions form, .row-actions .btn-sm { margin: 0 !important; display: inline-flex; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; white-space: nowrap; line-height: 1.4; height: auto; }
.btn-red {
  border-color: #e5484d !important;
  color: #e5484d !important;
}
.btn-red:hover, .btn-red:focus {
  background: #e5484d !important; color: #fff !important;
}

/* ---- Suspension banner (user home) ---- */
.suspend-banner {
  border-left: 4px solid #e5484d; background: rgba(229, 72, 77, .10);
  border-radius: 8px; padding: .7rem .9rem; margin: 0 0 1rem;
}
.suspend-banner strong { color: #e5484d; }
.suspend-banner p { margin: .3rem 0 0; }

/* ---- Payment history (user home) ---- */
.pay-history { margin-top: 1rem; }
.pay-history summary { cursor: pointer; font-weight: 600; }
.pay-history table { margin-top: .5rem; font-size: .9rem; }

/* ---- Homepage launcher tiles ---- */
.launch {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem; margin: 0 0 1.5rem;
}
.launch-tile {
  display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: 14px;
  background: var(--pico-card-background-color); color: var(--pico-color);
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.launch-tile:hover, .launch-tile:focus-visible {
  transform: translateY(-3px); border-color: #e5a00d;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .35); outline: none;
}
.launch-tile svg { width: 2rem; height: 2rem; flex: 0 0 auto; fill: currentColor; }
.launch-tile__txt { display: flex; flex-direction: column; line-height: 1.3; }
.launch-tile__txt strong { font-size: 1.05rem; color: var(--pico-color); }
.launch-tile__txt small { color: var(--pico-muted-color); }
.launch-tile--plex { color: #e5a00d; }
.launch-tile--seer { color: #6366f1; }
@media (prefers-reduced-motion: no-preference) {
  .launch-tile { animation: tile-in .35s ease backwards; }
  .launch-tile:nth-child(2) { animation-delay: .08s; }
  @keyframes tile-in { from { opacity: 0; transform: translateY(10px); } }
}

/* ---- Pill navigation ---- */
.nav-desktop { display: flex; flex-wrap: wrap; gap: .9rem; align-items: center; }
.nav-desktop li { padding: 0; margin: 0; }
.nav-desktop li a.active,
.nav-hamburger ul li a.active { color: var(--pico-primary); font-weight: 600; }

/* ---- Users table: toolbar (search / filters / sort) ---- */
.users-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0 .4rem; }
.users-toolbar input[type="search"] { flex: 3 1 16rem; margin: 0; }
.users-toolbar select { flex: 1 1 8rem; margin: 0; }
.users-count { color: var(--pico-muted-color); font-size: .85rem; margin: .1rem 0 .8rem; }

/* Contact column folds plex email + notify + telegram into one cell */
.contact-cell { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.contact-cell span { overflow: hidden; text-overflow: ellipsis; }
.contact-cell small { color: var(--pico-muted-color); font-size: .8rem; }

/* Compact inline controls so the table fits a scaled 14" FHD (~1280px) */
#usersTable td form select,
#usersTable .name-input { margin: 0; padding: .35rem .5rem; font-size: .85rem; }
.plex-handle { font-family: var(--pico-font-family-monospace, monospace);
  font-size: .85rem; color: var(--pico-muted-color); }
@media (min-width: 769px) {
  #usersTable td form select { max-width: 11rem; }
  #usersTable .name-input { max-width: 12rem; }
  #usersTable { font-size: .92rem; }
  /* Dense rows: browse ~100 users in one page without endless scroll */
  #usersTable th, #usersTable td { padding-top: .4rem; padding-bottom: .4rem; }
  #usersTable .btn-sm { padding: .25rem .6rem; font-size: .8rem; }
}
@media (max-width: 768px) {
  .contact-cell { flex: 1 1 auto; }  /* take remaining width in card layout */
}
