﻿/* === BASE WRAPPER === */
#roles {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  font: 15px/1.5 system-ui, sans-serif;
  background: var(--fishes);
  border-radius: 20px;
  position: relative;
}

/* === HEADER === */
.roles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1em;
}

.names {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
}

.roles-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: rgb(var(--text));
  margin: 0;
}

/* === ACTION BUTTONS === */
.roles-actions {
  display: flex;
  gap: 6px;
}

.roles-actions .nc-btn {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: all .25s ease;
  background: rgba(var(--acc1), .2);
  color: rgb(var(--acc1));
}

.roles-actions .nc-btn.primary {
  background: rgb(var(--acc1));
  color: #fff;
}

.roles-actions .nc-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* === SEARCH FIELD === */
#roles-search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(var(--acc1), .3);
  border-radius: 8px;
  margin-bottom: 16px;
  font: inherit;
  background: rgba(255, 255, 255, .5);
  outline: none;
  transition: border-color .25s ease;
}

#roles-search:focus {
  border-color: rgb(var(--acc1));
}

/* === GRID STRUCTURE === */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 30px;
}

.letter-block {
  background: rgb(var(--acc7), .3);
  border-radius: 10px;
  padding: 10px 14px;
  max-height: 420px;
  overflow-y: auto;
}

.letter-block h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
  border-bottom: 2px solid rgb(var(--acc2));
  width: fit-content;
  padding-right: 4px;
  color: var(--text900, #222);
}

/* === FANDOM & NAMES === */
.fandom {
  margin-bottom: .6em;
}

.fandom h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 6px 0 4px 0;
  color: rgb(var(--text));
  display: flex;
  align-items: center;
  gap: 4px;
}

.names a {
  text-decoration: none;
  color: rgb(var(--acc1));
  line-height: 1.6;
  font-family: var(--font);
  font-size: 14px;
  text-transform: lowercase;
}

.names a:hover {
  text-decoration: underline;
}

/* === ROLE ITEM === */
.role-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 6px;
  position: relative;
}

.edit-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  background: none;
  border: none;
  font-size: 13px;
  color: rgb(var(--white));
  cursor: pointer;
}

.role-item:hover .edit-btn {
  opacity: 1;
  pointer-events: auto;
}

/* === CAST SETTINGS === */
.cast-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cast-star {
  margin-left: 6px;
  color: rgb(var(--acc1));
  text-decoration: none;
  font-size: 1.1em;
  transition: transform .2s ease;
}

.cast-star:hover {
  transform: scale(1.2);
}

.edit-cast {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: rgb(var(--acc1));
  opacity: 0;
  transform: scale(.8);
  transition: opacity .25s ease, transform .25s ease;
}

.cast-title:hover .edit-cast {
  opacity: 1;
  transform: scale(1);
}

/* ===================================================== */
/* =================== MODAL SYSTEM ==================== */
/* ===================================================== */

.nc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s ease;
}

.nc-modal-backdrop.visible {
  display: flex;
  opacity: 1;
}

.nc-modal {
  width: 400px;
  max-width: 90%;
  background: var(--fishes);
  border-radius: 16px;
  box-shadow: 0 0 18px rgba(0,0,0,.4);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateY(8px);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}

.nc-modal-backdrop.visible .nc-modal {
  transform: translateY(0);
  opacity: 1;
}

.nc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nc-field label {
  font-size: 13px;
  opacity: .8;
}

.nc-modal input,
.nc-modal select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid rgb(var(--acc1) / .3);
  border-radius: 6px;
  background: rgba(255,255,255,.05);
  color: rgb(var(--text));
  outline: none;
  transition: border-color .25s ease;
}

.nc-modal input:focus,
.nc-modal select:focus {
  border-color: rgb(var(--acc1));
}

#roles-id-hint {
  font-size: 13px;
  color: #b22;
  min-height: 1em;
}

.nc-modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  gap: 8px;
}

.nc-modal-actions button {
  flex: 1;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-weight: 500;
  transition: all .25s ease;
}

.nc-modal-actions .primary {
  background: rgb(var(--acc1));
  color: #fff;
}

.nc-modal-actions .warn {
  background: rgba(200, 70, 70, .8);
  color: #fff;
}

.nc-modal-actions button:hover {
  filter: brightness(1.1);
}

/* === ADAPTIVE === */
@media (max-width: 800px) {
  .roles-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .roles-grid { grid-template-columns: 1fr; }
  #roles { padding: 10px; }
  .roles-header { 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 8px; 
  }
}