/* Admin UI styling */

:root {
  --red: #e10600;
  --red-dark: #b00500;
  --bg: #f3f4f7;
  --panel: #ffffff;
  --surface-alt: #f9fafb;
  --text: #101828;
  --muted: #6b7280;
  --muted-strong: #475467;
  --border: #e5e7eb;
  --border-strong: rgba(15, 23, 42, 0.12);
  --radius: 14px;
  --shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
  --sidebar-bg: linear-gradient(165deg, #1f2937 0%, #111827 55%, #0f172a 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: rgba(255, 255, 255, 0.82);
  --sidebar-muted: rgba(255, 255, 255, 0.55);
  --success: #16a34a;
  --warning: #f97316;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI,
    Roboto, Helvetica, Arial;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

/* Inputs */
.input,
.textarea,
.select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 11px 14px;
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: rgba(225, 6, 0, 0.5);
  box-shadow: 0 0 0 3px rgba(225, 6, 0, 0.1);
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.input-sm {
  padding: 8px 12px;
  font-size: 14px;
  height: 38px;
  border-radius: 10px;
}

/* Image upload field */
.image-field {
  display: grid;
  gap: 10px;
}

.image-preview {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

.image-preview-img {
  max-height: 160px;
  width: auto;
  object-fit: contain;
}

.image-placeholder {
  font-size: 13px;
  text-align: center;
}

.image-path {
  font-size: 13px;
  word-break: break-all;
}

.image-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.image-status {
  font-size: 13px;
  min-height: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  background: var(--red);
  color: #fff;
  border: 1.5px solid var(--red);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease;
}

.btn:hover {
  background: var(--red-dark);
  box-shadow: 0 12px 20px rgba(225, 6, 0, 0.18);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.btn-ghost {
  background: rgba(225, 6, 0, 0.08);
  color: var(--red);
  border: 1.5px solid rgba(225, 6, 0, 0.25);
}

.btn-ghost:hover {
  background: rgba(225, 6, 0, 0.15);
  box-shadow: none;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 10px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1.5px dashed rgba(225, 6, 0, 0.5);
  background: rgba(225, 6, 0, 0.08);
  color: var(--red);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.upload-btn:hover {
  background: rgba(225, 6, 0, 0.15);
  border-color: rgba(225, 6, 0, 0.7);
}

.upload-btn input {
  display: none;
}

.upload-btn.btn-sm {
  padding: 8px 12px;
  font-size: 14px;
}

/* Auth screen */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(420px, 94vw);
  background: var(--panel);
  border-radius: 18px;
  padding: 36px 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.auth-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(225, 6, 0, 0.1);
  padding: 6px;
}

.auth-card h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

/* Layout shell */
.app {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.app.sidebar-open {
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
  position: relative;
  z-index: 3;
  border-right: 1px solid var(--sidebar-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
}

.brand .brand-title {
  display: block;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand .brand-subtitle {
  display: block;
  font-size: 12px;
  color: var(--sidebar-muted);
}

.nav {
  display: grid;
  gap: 6px;
  padding: 18px 16px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease,
    border-color 0.2s ease;
}

.nav-link .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.nav-link .nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.14);
}

.nav-text {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 16px 0;
  border-top: 1px solid var(--sidebar-border);
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.app.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Main area */
.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#section-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.section-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-inline {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.csv-controls {
  row-gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-strong);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-text {
  min-height: 20px;
  font-size: 13px;
  color: var(--muted-strong);
}

.status-text.success {
  color: var(--success);
}

.status-text.error {
  color: var(--warning);
}

.topbar-icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.topbar-icon-btn svg {
  width: 24px;
  height: 24px;
}

.topbar-icon-btn:hover {
  background: var(--surface-alt);
  transform: translateY(-1px);
}

/* Content area */
.content {
  padding: 28px 26px 32px;
  overflow: auto;
}

.placeholder {
  font-size: 15px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}

/* Cards / editor blocks */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 18px;
}

.item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.item + .item {
  margin-top: 12px;
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  font-weight: 700;
  font-size: 15px;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.item-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease,
    border-color 0.15s ease;
  padding: 0;
}

.icon-button:hover {
  color: var(--red);
}

.icon-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

.icon-button:focus-visible {
  outline: none;
  border-color: rgba(225, 6, 0, 0.45);
  box-shadow: 0 0 0 3px rgba(225, 6, 0, 0.12);
}

.icon-delete {
  border-color: var(--border);
}

.icon-delete:hover {
  background: rgba(225, 6, 0, 0.08);
  border-color: rgba(225, 6, 0, 0.4);
}

.btn-icon-only {
  padding: 8px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  gap: 0;
}

.btn-icon-only .btn-icon {
  width: 18px;
  height: 18px;
}

.btn-icon-only .btn-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Grid helpers */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-2 > .field-span-2 {
  grid-column: 1 / -1;
}

.team-editor .grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.team-editor > div > .item:not(.item-compact) {
  border: none;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.team-editor > div > .item .item-head {
  margin-bottom: 18px;
}

.team-editor > div > .item .item-title {
  font-size: 18px;
  color: var(--muted-strong);
}

.team-editor fieldset.fieldset {
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.team-editor legend.legend {
  padding: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted-strong);
}

.team-editor legend.legend .toggle-view {
  margin-right: 0;
}

.team-editor .scroll-area {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  padding-right: 6px;
  max-height: 380px;
  overflow-y: auto;
}

.team-editor .scroll-trainings {
  max-height: 260px;
}

.team-editor fieldset.fieldset > .btn {
  margin-top: 4px;
  align-self: flex-start;
}

.card-pad .btn-add {
  margin-top: 18px;
}

.team-editor fieldset.fieldset > .btn-add {
  margin-top: 6px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

fieldset.fieldset {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
}

legend.legend {
  padding: 0 8px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.legend-label {
  font-weight: 600;
  flex: 1;
}

.legend .toggle-view {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, background-color 0.15s ease,
    color 0.15s ease;
}

.legend .toggle-view:hover {
  border-color: rgba(225, 6, 0, 0.35);
}

.toggle-view.is-active {
  background: rgba(225, 6, 0, 0.08);
  color: var(--red);
  border-color: rgba(225, 6, 0, 0.25);
}

.toggle-view.is-active:hover {
  background: rgba(225, 6, 0, 0.12);
}

.item-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.item-list .item {
  margin: 0;
}

.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.compact-grid .item {
  margin: 0;
}

.item-compact {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  box-shadow: 0 12px 25px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.item-compact.compact-no-thumb {
  grid-template-columns: minmax(0, 1fr);
}

.item-compact .item-footer {
  grid-column: 1 / -1;
  margin-top: 10px;
  justify-content: flex-end;
}

.item-compact:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12);
}

.item-compact:focus-visible {
  outline: 2px solid rgba(225, 6, 0, 0.45);
  outline-offset: 3px;
}

.compact-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--surface-alt);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compact-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compact-text {
  display: grid;
  gap: 4px;
  grid-column: 2;
}

.item-compact.compact-no-thumb .compact-text {
  grid-column: 1;
}

.compact-title {
  font-weight: 600;
  color: var(--muted-strong);
}

.compact-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.compact-meta {
  font-size: 12px;
  color: var(--muted);
}

.compact-actions {
  margin-top: 8px;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1200;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  width: min(720px, 100%);
  max-height: 92vh;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}

.modal-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.modal-heading .modal-title {
  margin: 0;
}

.modal-heading .modal-subtitle {
  margin-top: 0;
}

.modal-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  color: var(--text);
}

.modal-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.modal-subtitle.hidden {
  display: none;
}

.modal-close {
  margin-left: auto;
  color: var(--muted);
  flex-shrink: 0;
}

.modal-close:hover {
  color: var(--red);
}

.modal-body {
  padding: 24px 26px;
  overflow-y: auto;
  flex: 1;
}

.modal-body .grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px 16px;
  padding: 20px 26px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.modal-footer.has-nav {
  justify-content: space-between;
}

.modal-nav {
  display: flex;
  gap: 10px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-danger {
  color: var(--red);
  border-color: rgba(225, 6, 0, 0.4);
}

.btn-danger:hover {
  background: rgba(225, 6, 0, 0.08);
  box-shadow: none;
}

@media (max-width: 640px) {
  .modal-dialog {
    width: 100%;
    border-radius: 16px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 18px;
    padding-right: 18px;
  }
}
}

.scroll-area {
  max-height: 440px;
  overflow-y: auto;
  padding-right: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.scroll-trainings {
  height: 260px;
  overflow-y: auto;
  padding-right: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

/* Responsive */
@media (max-width: 1200px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .topbar-icon-btn {
    display: inline-flex;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .topbar-right {
    justify-content: flex-start;
  }

  .panel-inline {
    width: 100%;
    flex-wrap: wrap;
  }

  .actions {
    width: 100%;
    justify-content: space-between;
  }

  .actions .btn {
    flex: 1;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .scroll-area {
    max-height: 55vh;
  }

  .scroll-trainings {
    height: 45vh;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 22px 18px 26px;
  }

  .panel-inline {
    padding: 12px 14px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .btn,
  .btn-ghost,
  .btn-outline {
    width: 100%;
  }
}

/* Scrollbars */
.scroll-area::-webkit-scrollbar,
.scroll-trainings::-webkit-scrollbar {
  width: 8px;
}

.scroll-area::-webkit-scrollbar-thumb,
.scroll-trainings::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 10px;
}

.scroll-area::-webkit-scrollbar-track,
.scroll-trainings::-webkit-scrollbar-track {
  background: transparent;
}
