/* ============================================================================
   EPG page — page-scoped styles
   ----------------------------------------------------------------------------
   File layout:
     1. Page shell
     2. Toolbar (title with sub-URL + search + new button)
     3. Single-table card (header + rows + refresh/trash actions)
     4. Refresh + delete buttons
     5. Responsive — all @media queries consolidated at the end
   ============================================================================ */


/* ============================ 1. Page shell ============================ */
.app-shell[data-page="epg"] .content-shell {
  overflow: hidden;
}

.epg-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  height: 100%;
  min-height: 0;
}

.epg-table-shell {
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
}

.epg-table-shell::-webkit-scrollbar {
  display: none;
}


/* ============================ 2. Toolbar ============================ */
.epg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.epg-title {
  margin: 0;
  color: var(--dark4txt);
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 500;
  line-height: 26px;
  flex: 0 0 auto;
}

/* Sub-URL inside the title (e.g. "EPG pultas http://nl3.namai.tv:16664/epg/") */
.epg-title-sub {
  color: var(--grey4txt);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
}

/* Search field — same look as packages */
.epg-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  height: 42px;
  padding: 0 12px 0 16px;
  border-radius: var(--radius-sm);
  background: var(--white);
  flex: 1 1 280px;
  min-width: 0;
}

.epg-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--grey4txt);
  background: transparent;
  font: inherit;
}

.epg-search img {
  width: 24px;
  height: 24px;
}

.epg-new-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--white);
  border-radius: var(--radius-sm);
  color: var(--dark4txt);
  background: var(--button-bg-color);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.epg-new-btn:hover {
  background: var(--white);
}


/* ============================ 3. Table ============================ */
.epg-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px 2px;
}

.epg-table thead.epg-table-head th {
  padding: 12px 16px;
  color: var(--dark4txt);
  background: var(--white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  box-shadow: 2px 0 0 0 var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.epg-table thead.epg-table-head th:first-child {
  width: 70px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.epg-table thead.epg-table-head th:nth-child(3),
.epg-table thead.epg-table-head th:nth-child(4) {
  width: 150px;
}

.epg-table thead.epg-table-head th:nth-child(5) {
  width: 180px;
}

.epg-table thead.epg-table-head th:nth-child(6) {
  width: 160px;
}

.epg-table thead.epg-table-head th:nth-child(7),
.epg-table thead.epg-table-head th:last-child {
  width: 60px;
}

.epg-table thead.epg-table-head th:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.epg-table-gap td {
  height: 10px;
  padding: 0;
  background: transparent !important;
  border-radius: 0 !important;
}

.epg-row td {
  padding: 14px 16px;
  color: var(--dark4txt);
  background: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 500;
  vertical-align: middle;
}

.epg-row.is-alt td {
  background: rgba(255, 255, 255, 0.3);
}

.epg-row:hover td {
  background: var(--white);
}

.epg-row td:first-child {
  width: 70px;
  color: var(--grey4txt);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.epg-row td:nth-child(7) {
  width: 60px;
  text-align: center;
}

/* Delete button cell */
.epg-row td:last-child {
  width: 60px;
  text-align: center;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}


/* ============================ 4. Action buttons (refresh + delete) ============================ */
.epg-refresh,
.epg-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.epg-refresh img,
.epg-delete svg {
  width: 22px;
  height: 22px;
}

.epg-delete svg path {
  transition: fill 120ms ease;
}

.epg-delete:hover svg path {
  fill: var(--accent-pink, #e3173b);
}

.epg-row>td:nth-child(3),
.epg-row>td:nth-child(4),
.epg-row>td:nth-child(6) {
  text-align: center;
}

/* ============================================================================
   6. EPG Edit / Add Modal — shared design, separate templates
   ============================================================================ */
.epg-modal .info-modal-card {
  width: min(768px, 100vw - 48px);
  max-height: calc(100vh - 48px);
}

.epg-modal-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.epg-modal-title-block .info-modal-eyebrow {
  font-size: 14px;
  opacity: 1;
  font-weight: 400;
}

.epg-modal-name {
  font-family: var(--font-heading);
  font-size: 28px;
  line-height: 32px;
  font-weight: 700;
}

.epg-modal .info-modal-head {
  cursor: move;
  -webkit-user-select: none;
  user-select: none;
}

.epg-modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.epg-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epg-modal-field>span {
  font-size: 14px;
  color: var(--dark4txt);
}

.epg-modal-field>input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--white);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--dark4txt);
  font: inherit;
  outline: 0;
}

.epg-modal-field>input::placeholder {
  color: var(--grey4txt);
}

.epg-modal-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}

.epg-modal-field-row>span {
  font-size: 14px;
  color: var(--dark4txt);
  flex: 0 0 auto;
}

.epg-modal-field-row>input {
  flex: 0 0 220px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--white);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--dark4txt);
  font: inherit;
  text-align: right;
  outline: 0;
}

.epg-modal-field-row>input::placeholder {
  color: var(--grey4txt);
  text-align: left;
}

.epg-modal-field-row>.epg-modal-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark4txt);
}

.epg-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  padding-top: 8px;
}

.epg-modal-refresh,
.epg-modal-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--white);
  border-radius: var(--radius-sm);
  background: var(--button-bg-color);
  color: var(--dark4txt);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.epg-modal-refresh:hover,
.epg-modal-save:hover {
  background: var(--white);
}

.epg-modal-refresh img {
  width: 16px;
  height: 16px;
}

.info-modal-accordions {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  color: var(--dark4txt);
}

/* ============================================================================
   5. Responsive — at ≤ 1024px each row collapses to a 3-row card layout per
   the user's spec:
     • Row 1 → child 2 (Adresas) + child 7 (refresh)
     • Row 2 → child 1 (ID) + child 3 (Kanalų kiekis) + child 4 (Naudojama live kanaluose)
     • Row 3 → child 5 (Atnaujintas) + child 6 (Atnaujinimo trukmė) + child 8 (delete)
   ============================================================================ */
@media (max-width: 1400px) {

  /* Hide the desktop header row — the mobile card layout uses ::before labels */
  .epg-table thead.epg-table-head,
  .epg-table-gap {
    display: none;
  }

  /* Each row becomes a 3-row × 3-col card */
  .epg-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 0px;
    row-gap: 0px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.6);
  }

  .epg-row.is-alt {
    background: rgba(255, 255, 255, 0.3);
  }

  .epg-row>td {
    padding: 10px 14px;
    background: transparent !important;
    border-radius: 0 !important;
    border-top: 2px solid rgba(3, 5, 34, 0.06);
    color: var(--dark4txt);
    font-size: 14px;
    line-height: 16px;
  }

  .epg-row>td:nth-child(2) {
    grid-column: 1 / 3 !important;
    grid-row: 1 !important;
    border-top: 0;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .epg-row>td:nth-child(7) {
    grid-column: 3 / 4 !important;
    grid-row: 1 !important;
    border-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 10px;
    width: auto;
  }

  .epg-row>td:nth-child(1) {
    grid-column: 1 / 2 !important;
    grid-row: 2 !important;
    color: var(--dark4txt);
    font-weight: 500;
    width: 50px;
  }

  .epg-row>td:nth-child(3) {
    grid-column: 1 / 3 !important;
    grid-row: 2 !important;
    width: auto;
    border: 2px solid rgba(3, 5, 34, 0.06);
    border-bottom: 0px;
    margin-left: 50px;
  }

  .epg-row>td:nth-child(4) {
    grid-column: 3 / 4 !important;
    grid-row: 2 !important;
    width: auto;
  }

  .epg-row>td:nth-child(5) {
    grid-column: 1 / 2 !important;
    grid-row: 3 !important;
    width: auto;
  }

  .epg-row>td:nth-child(6) {
    grid-column: 2 / 3 !important;
    grid-row: 3 !important;
    width: auto;
    border: 2px solid rgba(3, 5, 34, 0.06);
    border-bottom: 0px;
  }

  .epg-row>td:last-child {
    grid-column: 3 / 4 !important;
    grid-row: 3 !important;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 10px;
  }

  .epg-row>td:nth-child(1)::before {
    content: "ID";
  }

  .epg-row>td:nth-child(3)::before {
    content: "Kanalų kiekis";
  }

  .epg-row>td:nth-child(4)::before {
    content: "Naudojama live kanaluose";
  }

  .epg-row>td:nth-child(5)::before {
    content: "Atnaujintas";
  }

  .epg-row>td:nth-child(6)::before {
    content: "Atnaujinimo trukmė";
  }

  .epg-row>td:nth-child(1)::before,
  .epg-row>td:nth-child(3)::before,
  .epg-row>td:nth-child(4)::before,
  .epg-row>td:nth-child(5)::before,
  .epg-row>td:nth-child(6)::before {
    display: block;
    margin-bottom: 4px;
    color: var(--grey4txt);
    font-size: 13px;
    font-weight: 400;
    line-height: 15px;
  }
}

/* ---- ≤ 600px : toolbar tweaks (mirrors packages) ---- */
@media (max-width: 600px) {
  .epg-title {
    flex: 1 1 100%;
  }

  .epg-title-sub {
    display: none;
  }

  .epg-search {
    flex: 1 1 0;
    min-width: 0;
  }

  .epg-new-btn .epg-new-text {
    display: none;
  }

  .epg-new-btn {
    min-width: 42px;
    padding: 0 14px;
  }

  .epg-modal {
    padding: 0;
  }

  .epg-modal .info-modal-card {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .epg-modal-field-row {
    flex-wrap: wrap;
  }

  .epg-modal-field-row>input {
    flex: 1 1 100%;
    text-align: left;
  }
}

@media (max-width: 494px) {
  .epg-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);

  }

  .epg-row>td:last-child {
    width: stretch;
    margin-left: auto;
    padding-right: 2px;
  }

  .epg-row>td:nth-child(6) {
    width: max-content;
    padding: 12px 8px;
  }

}