/* ============================================================================
   DRM › Šaltiniai page — page-scoped styles
   ----------------------------------------------------------------------------
   File layout:
     1. Page shell
     2. Top bar (title + search + add button)
     3. Two-column grid (left + right table side by side)
     4. Table head + rows
     5. Channels cell + "Daugiau" toggle
     6. Modal (create / edit DRM šaltinis)
     7. Responsive — mobile card layout + modal full-width
   ============================================================================ */


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

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


/* ============================ 2. Toolbar — packages pattern ============================ */
.drm-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

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

.drm-title-count {
  color: var(--grey4txt);
  font-weight: 400;
  font-size: 16px;
  margin-left: 4px;
}

/* Search field — grid input + icon, white card */
.drm-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;
}

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

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

/* "+ Naujas DRM" button */
.drm-add {
  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;
  transition: background 0.15s ease;
}

.drm-add:hover {
  background: var(--white);
}


/* ============================ 3. Two-column grid ============================ */
.drm-scroll {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.drm-scroll::-webkit-scrollbar { display: none; }

.drm-grid {
  display: block; /* single merged table now occupies the full width */
}


/* ============================ 4. Table — packages pattern ============================ */
.drm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px 2px;
  table-layout: fixed;
}

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

.drm-table thead th:last-child {
  box-shadow: none;
}

.drm-table thead th:first-child {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.drm-table thead th:last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

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

/* Body rows */
.drm-table tbody tr {
  cursor: pointer;
}

.drm-table tbody tr td {
  padding: 14px 16px;
  vertical-align: top;
  color: var(--dark4txt);
  background: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
}

.drm-table tbody tr.is-alt td {
  background: rgba(255, 255, 255, 0.3);
}

.drm-table tbody tr:hover td {
  background: var(--white);
}

.drm-table tbody td.drm-cell-id {
  width: 50px;
  color: var(--grey4txt);
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.drm-table tbody td.drm-cell-channels {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

.drm-table th:nth-child(1) { width: 50px; }
.drm-table th:nth-child(2) { width: auto; }
.drm-table th:nth-child(3) { width: 88px; }
.drm-table th:nth-child(4) { width: 220px; }
.drm-table td:nth-child(3) { width: 88px; }
.drm-table td:nth-child(4) { width: 220px; }

.drm-mobile-head,
.drm-mobile-channels {
  display: none;
}


/* ============================ 5. Channels cell + Daugiau ============================ */
.drm-channels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.drm-channels-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.drm-channels-list li {
  color: #334386;
  font-size: 13px;
  line-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drm-channels:not(.is-open) .drm-channels-list li:nth-child(n+2) {
  display: none;
}

.drm-channels-more {
  align-self: flex-start;
  padding: 2px 4px;
  margin-top: 4px;
  border: 1px solid var(--text-color);
  border-radius: var(--radius-sm);
  background: var(--button-bg-color);
  color: var(--text-color);
  font: inherit;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.drm-channels-more:hover {
  background: var(--white);
}


/* ============================ 6. Modal ============================ */
.drm-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: var(--font-body);
}

.drm-modal.is-open {
  display: flex;
}

.drm-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 34, 0.38);
}

.drm-modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(720px, 100vw - 48px);
  max-height: calc(100vh - 48px);
  padding: 24px 26px 22px;
  border-radius: 16px;
  background: var(--dark4txt) url("../../assets/images/app-bg.png") center / cover no-repeat;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.drm-modal.drm-modal-instance {
  background: transparent;
  pointer-events: none;
}

.drm-modal.drm-modal-instance .drm-modal-overlay {
  display: none;
}

.drm-modal.drm-modal-instance .drm-modal-card {
  pointer-events: auto;
}

.drm-modal.drm-modal-instance .drm-modal-head {
  cursor: move;
  -webkit-user-select: none;
  user-select: none;
}

.drm-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--white);
}

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

.drm-modal-eyebrow {
  font-size: 13px;
  opacity: 0.9;
}

.drm-modal-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 28px;
  line-height: 30px;
  font-weight: 700;
}

.drm-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  flex: 0 0 40px;
}

.drm-modal-close img {
  width: 18px;
  height: 18px;
}

.drm-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 22px 24px;
  border-radius: 14px;
  background: var(--panel-bg);
}

.drm-modal-body::-webkit-scrollbar { display: none; }

.drm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

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

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

.drm-input::placeholder {
  color: var(--grey4txt);
}

.drm-stepper-row {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.drm-stepper {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  height: 44px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: var(--white);
}

.drm-stepper button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  color: var(--dark4txt);
  background: rgba(123, 85, 203, 0.12);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.drm-stepper button:hover {
  background: rgba(123, 85, 203, 0.24);
}

.drm-stepper output {
  color: var(--dark4txt);
  font-weight: 500;
  text-align: center;
}

.drm-modal-actions {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.drm-modal-save {
  height: 44px;
  padding: 0 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--button-bg-color);
  color: var(--dark4txt);
  border: 1px solid var(--white);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.drm-modal-save:hover {
  background: var(--white);
}


/* ============================================================================
   7. Responsive
   ============================================================================ */

/* ---- ≤ 1024px : single-column table layout ---- */
@media (max-width: 1400px) {
  .drm-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
}



/* ---- ≤ 700px : mobile card layout ---- */
@media (max-width: 700px) {
  .app-shell[data-page="drm"] .content-shell,
  .app-shell[data-page="drm-keys"] .content-shell {
    overflow: auto;
  }
  .drm-page {
    height: auto;
    grid-template-rows: auto auto;
  }

  .drm-scroll {
    overflow: visible;
  }

  .drm-table,
  .drm-table thead,
  .drm-table tbody,
  .drm-table tr,
  .drm-table td {
    display: block;
    width: 100%;
  }

  .drm-table thead {
    display: none;
  }

  .drm-table tbody tr {
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.77);
    overflow: hidden;
    padding: 0;
  }
  .drm-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.35);
}
  .drm-table tbody td {
    padding: 0;
    background: transparent;
    border-radius: 0 !important;
  }

  td.drm-mobile-head {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 100px;
    gap: 0;
    padding: 0;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  }

  .drm-mobile-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 12px;
  }

  .drm-mobile-cell + .drm-mobile-cell {
    border-left: 1px solid rgba(0, 0, 0, 0.08);
  }

  .drm-mobile-label {
    font-size: 11px;
    color: var(--grey4txt);
    line-height: 14px;
  }

  .drm-mobile-value {
    font-size: 14px;
    color: var(--dark4txt);
    line-height: 18px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  td.drm-mobile-channels {
    display: block;
    padding: 8px 12px 10px;
  }

  .drm-mobile-channels-label {
    font-size: 11px;
    color: var(--grey4txt);
    line-height: 14px;
    margin-bottom: 4px;
    display: block;
  }

  td.drm-mobile-channels .drm-channels-list li {
    color: var(--blue4link);
    font-size: 13px;
    line-height: 18px;
  }

  /* Hide desktop cells in mobile view */
  .drm-table tbody td.drm-cell-id,
  .drm-table tbody td.drm-cell-name,
  .drm-table tbody td.drm-cell-archive,
  .drm-table tbody td.drm-cell-channels {
    display: none;
  }
  .drm-mobile-head{
    padding: 0px !important;
  }
}
/* ---- ≤ 620px : toolbar wraps — title + plus button on row 1, search on row 2 ---- */
@media (max-width: 620px) {
  .drm-topbar {
    gap: 10px 12px;
  }

  .drm-add {
    margin-left: auto;
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .drm-add-text {
    display: none;
  }

  .drm-add-plus {
    font-size: 22px;
    font-weight: 500;
    line-height: 1;
  }

  .drm-search {
    order: 3;
    flex: 0 0 100%;
  }
}
/* ---- ≤ 600px : modal full-screen (both new & edit) ---- */
@media (max-width: 600px) {
  .drm-modal {
    padding: 0;
  }

  .drm-modal-card {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 18px 18px 16px;
  }

  .drm-modal.drm-modal-instance .drm-modal-card {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .drm-modal.drm-modal-instance .drm-modal-head {
    cursor: default;
  }

  .drm-modal-title {
    font-size: 22px;
    line-height: 26px;
  }
  .drm-modal-body {
    padding: 16px;
  }
  .drm-stepper-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}
