/* stylelint-disable no-descending-specificity, declaration-block-single-line-max-declarations */

/* ====== STRUKTURA PANELU ====== */


.admin-panel-container {
  display: flex;
  gap: 2rem;
  padding: 2rem;
  font-family: Inter, sans-serif;
  background-color: #f8f9fb;
  margin-top: 80px; /* Adjust this value to match the height of the main header bar */
}

/* Lewa kolumna: lista użytkowników, menu */
.admin-sidebar {
  width: 280px;
  background-color: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 10px rgb(0 0 0 / 5%);
}

/* Prawa kolumna: szczegóły użytkownika */
.admin-content {
  flex: 1;
  background-color: #fff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 10px rgb(0 0 0 / 5%);
}

/* ====== TYPOGRAFIA I NAGŁÓWKI ====== */

.panel-heading {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.label {
  font-weight: 500;
  margin-top: 0.5rem;
  margin-bottom: 0.3rem;
  display: block;
  color: #333;
}

/* ====== INPUTY, BUTTONY, FORMULARZE ====== */

.input-field,
.select-field {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.checkbox-field {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.button-primary {
  background-color: #366eff;
  color: white;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s;
}

.button-primary:hover {
  background-color: #1e50d4;
}

.button-secondary {
  background-color: #e6e6e6;
  color: #333;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.button-secondary:hover {
  background-color: #d4d4d4;
}

/* ====== TABELA UŻYTKOWNIKÓW ====== */

.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.user-table th,
.user-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.user-table tr:hover {
  background-color: #f2f2f2;
  cursor: pointer;
}

.user-table tr.active {
  background-color: #e7f0ff;
}

/* ====== KARTY, ZAKŁADKI, MODUŁY ====== */

.tab-nav {
  display: flex;
  gap: 1rem;
  border-bottom: 2px solid #f0f0f0;
  margin-bottom: 1rem;
}

.tab-nav .tab {
  padding: 0.5rem 1rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-nav .tab.active {
  border-color: #366eff;
  color: #366eff;
}

/* Zakładki: ukryj nieaktywne treści */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Sekcja z checkboxami dla modułów */

.module-checkbox-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Stylizacja pojedynczego modułu */
.modules-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  background-color: #f9f9fb;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  font-family: Inter, sans-serif;
  column-gap: 0.75rem;
}

.modules-item:hover {
  border-color: #366eff;
  box-shadow: 0 2px 6px rgb(54 110 255 / 10%);
  background-color: #fff;
}

.modules-item input[type="checkbox"] {
  margin-top: 0.2rem;
  transform: scale(1.2);
  cursor: pointer;
  accent-color: #366eff;
}

.modules-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #222;
}

.modules-desc {
  font-size: 0.875rem;
  color: #666;
  line-height: 1.3;
}

/* Ulepszony grid dla modułów */
.modules-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* ====== LOADER ====== */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgb(248 249 251 / 75%); /* matches .admin-panel-container bg with opacity */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loader {
  border: 4px solid #e6e6e6;
  border-top: 4px solid #366eff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-text {
  margin-top: 1rem;
  font-size: 1rem;
  color: #333;
  font-weight: 500;
}

/* Inline spinner (lekki) */
.inline-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #e6e6e6;
  border-top-color: #366eff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

/* Stylizacja dla skróconych pól w sidebarze (short-field) */
.short-field {
  width: 90%;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  background-color: #f9f9f9;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.short-field:focus {
  outline: none;
  border-color: #366eff;
  box-shadow: 0 0 0 2px rgb(54 110 255 / 15%);
  background-color: #fff;
}

/* ——— CREATE MODULE: COMPACT FORM (matching Modules tab) ——— */
.create-module-form,
#tab-create-module .module-form {
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
  font-family: Inter, sans-serif;
  box-shadow: 0 2px 10px rgb(0 0 0 / 4%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Pola i etykiety — mniejsze, ściśnięte */
.create-module-form label,
#tab-create-module .module-form label {
  font-weight: 600;
  margin: 0.25rem 0 0.15rem;
  color: #222;
  display: block;
  font-size: 0.92rem;
}

.create-module-form input,
.create-module-form select,
.create-module-form textarea,
#tab-create-module .module-form .input-field,
#tab-create-module .module-form .select-field,
#tab-create-module .module-form textarea,
#tab-create-module .module-form input,
#tab-create-module .module-form select {
  width: 100%;
  padding: 0.45rem 0.6rem;           /* ciaśniej */
  border-radius: 8px;
  border: 1px solid #d4d4d8;
  font-size: 0.95rem;                /* mniejsza czcionka */
  margin-bottom: 0.6rem;             /* ciaśniej */
  font-family: inherit;
  background-color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  box-sizing: border-box;
  min-height: 36px;                  /* mniejsze, ale czytelne */
}

/* Focus zgodny z modułami */
.create-module-form input:focus,
.create-module-form select:focus,
.create-module-form textarea:focus,
#tab-create-module .module-form .input-field:focus,
#tab-create-module .module-form .select-field:focus,
#tab-create-module .module-form textarea:focus,
#tab-create-module .module-form input:focus,
#tab-create-module .module-form select:focus {
  outline: none;
  border-color: #366eff;
  box-shadow: 0 0 0 2px rgb(54 110 255 / 15%);
}

/* Krótsze textarea */
.create-module-form textarea,
#tab-create-module .module-form textarea {
  min-height: 70px;
  resize: vertical;
}

/* Gridy jak w sekcji modułów */
.create-module-form .field-inline,
#tab-create-module .module-form .field-inline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;                       /* ciaśniej */
}

/* Dla par/krotek (2 kolumny) można nadpisać na 2 kolumny w HTML klasą .cols-2 */
.create-module-form .field-inline.cols-2,
#tab-create-module .module-form .field-inline.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.create-module-form .subfield,
#tab-create-module .module-form .subfield { min-width: 0; }

/* Hint pod slugiem */
#tab-create-module .module-form .hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
}

/* Przyciski jak w zakładce Moduły */
.create-module-form .button-primary,
#tab-create-module .module-form .button-primary {
  background-color: #366eff;
  color: #fff;
  padding: 0.5rem 1rem;              /* ciaśniej */
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s;
}

.create-module-form .button-primary:hover,
.create-module-form .button-primary:focus,
#tab-create-module .module-form .button-primary:hover,
#tab-create-module .module-form .button-primary:focus {
  background-color: #1e50d4;
}

#tab-create-module .module-form .button-secondary {
  background-color: #eef1f7;
  color: #1f2937;
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}

#tab-create-module .module-form .actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.3rem;
}

#tab-create-module .module-form .form-info {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: #374151;
}

/* Podgląd modułu — spójny z kartami modułów (scoped) */
#tab-create-module .module-preview { position: sticky; top: 8px; }

#tab-create-module .module-card {
  --dash-accent: #177BFE;

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 6%);
  padding: 16px;
  outline: 1px solid rgb(0 0 0 / 6%);
}
#tab-create-module .module-card:hover { box-shadow: 0 12px 28px rgb(0 0 0 / 8%); }
#tab-create-module .module-header { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }

#tab-create-module .module-icon {
  width: 83.2px; height: 83.2px; border-radius: 16px;
  background: linear-gradient(135deg, rgb(23 123 254 / 15%), rgb(23 123 254 / 6%));
  display: grid; place-items: center; flex: 0 0 auto;
  font-size: 40px; /* emoji fallback */
  color: var(--dash-accent);
}
#tab-create-module .module-icon svg { width: 46.8px; height: 46.8px; color: var(--dash-accent); }
#tab-create-module .module-title { font-weight: 700; color: #1f2937; line-height: 1.15; }
#tab-create-module .module-key { font-size: 12px; color: #6b7280; }
#tab-create-module .module-desc { font-size: 13px; color: #394150; line-height: 1.35; min-height: 34px; text-align: center; }
#tab-create-module .module-metas { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#tab-create-module .badge { font-size: 11px; padding: 4px 8px; border-radius: 999px; border: 1px solid rgb(0 0 0 / 6%); background: #f8fafc; color: #111827; }
#tab-create-module .badge.accent { border-color: rgb(23 123 254 / 25%); background: rgb(23 123 254 / 8%); color: #0b4ea9; }
#tab-create-module .badge.ok { border-color: rgb(16 185 129 / 25%); background: rgb(16 185 129 / 8%); color: #0c8a64; }
#tab-create-module .badge.warn { border-color: rgb(245 158 11 / 25%); background: rgb(245 158 11 / 10%); color: #8a5b03; }
#tab-create-module .badge.danger { border-color: rgb(239 68 68 / 25%); background: rgb(239 68 68 / 10%); color: #8a1320; }
#tab-create-module .module-actions { display: flex; gap: 8px; margin-top: 6px; justify-content: center; }
#tab-create-module .btn { font-size: 13px; font-weight: 600; border: none; border-radius: 8px; padding: 8px 12px; cursor: not-allowed; background: #eef2ff; color: #243b80; }
#tab-create-module .btn.primary { background: var(--dash-accent); color: #fff; }
#tab-create-module .btn.ghost { background: transparent; color: #0b4ea9; border: 1px solid rgb(23 123 254 / 25%); }

/* Usunięte stare selektory podglądu (zachowane jako komentarz referencyjny)
#tab-create-module .module-card-accent {}
#tab-create-module .module-card-header {}
*/

/* Grid layout formularz + podgląd */
.create-module-grid {
  display:grid;
  grid-template-columns: 1.1fr 1fr; /* lekko węższa kolumna z podglądem */
  gap: 16px;                        /* ciaśniej */
  align-items:flex-start;
}

@media (width <= 1100px) {
  .create-module-grid { grid-template-columns: 1fr; }
}

@media (width <= 600px) {
  .create-module-form,
  #tab-create-module .module-form { padding: 0.75rem 0.5rem; }

  .create-module-form input,
  .create-module-form select,
  .create-module-form textarea,
  #tab-create-module .module-form .input-field,
  #tab-create-module .module-form .select-field,
  #tab-create-module .module-form textarea,
  #tab-create-module .module-form input,
  #tab-create-module .module-form select {
    font-size: 0.94rem;
    padding: 0.45rem 0.55rem;
    min-height: 34px;
  }

  .create-module-form .field-inline,
  #tab-create-module .module-form .field-inline {
    grid-template-columns: 1fr;
  }
}

/* ====== MODUŁY: kolumna Akcje, przyciski, rozmiary ====== */
.modules-actions-cell {
  white-space: nowrap;
  vertical-align: middle;
}

.modules-actions-cell .module-row-actions {
  display: inline-flex;
  gap: 6px;
}

/* Przyciski w tabeli – kompaktowe */
.modules-table .button-secondary,
.modules-table .button-primary {
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
  border-radius: 6px;
  line-height: 1;
}

/* Globalny stan disabled – spójność UI */
.button-primary[disabled],
.button-primary:disabled,
.button-secondary[disabled],
.button-secondary:disabled {
  opacity: .6;
  cursor: not-allowed;
  filter: grayscale(10%);
}

/* Tabela modułów – delikatniejsze komórki */
.modules-table th,
.modules-table td {
  padding: 0.6rem 0.75rem;
  vertical-align: top;
}

/* Opcjonalne szerokości kolumn (dopasuj wg potrzeb) */
.modules-table th:nth-child(1) { width: 34px; }      /* Włącz */
.modules-table th:nth-child(2) { width: 18%; }       /* Moduł */
.modules-table th:nth-child(3) { width: 28%; }       /* Opis */
.modules-table th:nth-child(4) { width: 12%; }       /* Aktywowany */
.modules-table th:nth-child(5) { width: 12%; }       /* Wygasa */
.modules-table th:nth-child(6) { width: 12%; }       /* Dezaktywacja */
.modules-table th:nth-child(9) { width: 12%; }       /* Akcje */

/* ====== PERMISSIONS (dynamic) ====== */
#tab-permissions .role-perm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin: 8px 0 10px;
}

#tab-permissions .perm-search {
  flex: 1 1 260px;
  min-width: 220px;
  max-width: 520px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #d4d4d8;
  font-size: 0.95rem;
  background-color: #fff;
}

#tab-permissions .role-perm-toolbar .button-secondary {
  padding: 0.45rem 0.7rem;
}

#tab-permissions .role-perm-toolbar .counter {
  margin-left: auto;
  font-size: 0.9rem;
  color: #374151;
}

#tab-permissions #role-module-list.mod-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#tab-permissions .mod-group {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

#tab-permissions .mod-group .group-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #eef2ff;
  background: #f9fbff;
  border-radius: 10px 10px 0 0;
}

#tab-permissions .mod-group .group-title {
  font-weight: 700;
  color: #1f2937;
}
#tab-permissions .mod-group .group-actions { margin-left: auto; display: inline-flex; gap: 6px; }
#tab-permissions .mod-group .group-count { font-size: 12px; opacity: .7; margin-left: 6px; }

#tab-permissions .mod-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 8px;
  padding: 10px;
}

@media (width <= 900px) {
  #tab-permissions .mod-grid { grid-template-columns: 1fr; }
}

#tab-permissions .mod-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fbfbfe;
  padding: 10px;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}

#tab-permissions .mod-card:hover {
  border-color: #366eff;
  box-shadow: 0 2px 8px rgb(54 110 255 / 8%);
  background: #fff;
}

#tab-permissions .mod-card input[type="checkbox"] {
  margin-top: 2px;
  transform: scale(1.15);
  accent-color: #366eff;
  cursor: pointer;
}

/* ====== MODULE BLOCKS BUILDER (drag & drop) ====== */
.module-blocks-builder {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  align-items: start;
  margin-top: 12px;
}
.module-blocks-builder .blocks-left { position: sticky; top: 8px; align-self: start; }
.module-blocks-builder .builder-hint { font-size: 12px; color: #556; opacity: .75; margin-top: 8px; }

.blocks-palette {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.block-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  transition: border-color .2s, background-color .2s, transform .06s;
}
.block-palette-item:hover { border-color: #366eff; background: #f1f5ff; }
.block-palette-item:active { cursor: grabbing; transform: scale(.99); }
.block-palette-item img { width: 20px; height: 20px; opacity: .85; }
.block-palette-item span { font-weight: 600; color: #1f2937; font-size: 14px; }

.blocks-right { display: grid; gap: 10px; }

.blocks-canvas {
  min-height: 140px;
  padding: 10px;
  border: 2px dashed #e5e7eb;
  border-radius: 12px;
  background: #fff;
  transition: border-color .2s, background-color .2s;
}
.blocks-canvas.drag-over { border-color: #366eff; background: #f8fbff; }

/* Element wstawiany podczas przeciągania */
.drop-placeholder { height: 10px; margin: 4px 0; border: 2px dashed #366eff; border-radius: 4px; background: rgb(54 110 255 / 6%); }

/* Blok na kanwie (dodatkowo do inline-styles z JS) */
.block-item { cursor: default; }
.block-item.dragging { opacity: .6; }
.block-drag-handle { cursor: grab; font-weight: 700; padding: 0 6px; }
.block-drag-handle:active { cursor: grabbing; }

.blocks-config { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px; }
.blocks-actions { display: flex; gap: 10px; align-items: center; }

@media (width <= 1000px) {
  .module-blocks-builder { grid-template-columns: 1fr; }
  .module-blocks-builder .blocks-left { position: static; }
}

/* ====== CREATE MODULE WIZARD ====== */
#tab-create-module .wizard-stepper {
  display: flex;
  gap: 8px;
  margin: 8px 0 10px;
}

#tab-create-module .wizard-stepper .step {
  appearance: none;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #1f2937;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

#tab-create-module .wizard-stepper .step[aria-selected="true"],
#tab-create-module .wizard-stepper .step.active {
  background: #366eff;
  color: #fff;
  border-color: #366eff;
}
#tab-create-module .wizard-pages { margin-top: 6px; }
#tab-create-module .wizard-step-pane { display: none; }
#tab-create-module .wizard-step-pane.active { display: block; }
#tab-create-module .wizard-nav { display: flex; gap: 8px; justify-content: space-between; margin-top: 10px; }

#tab-create-module .wizard-nav .button-primary,
#tab-create-module .wizard-nav .button-secondary { padding: 0.5rem 1rem; }

/* Step 1: Module Card Preview rail */
#tab-create-module .module-card-preview-rail { position: sticky; top: 8px; align-self: start; }

/* Tiny progress bar inside preview card */
#tab-create-module .module-progress { height: 6px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
#tab-create-module .module-progress-bar { height: 100%; width: 0%; background: var(--dash-accent, #177BFE); }

/* Pomocnicze */
.hidden { display: none !important; }