/* Roles Screen Styles - UI Kit Compatible */

.roles-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 16px;
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

.role-card {
  background: linear-gradient(180deg, rgba(10, 19, 35, 0.96) 0%, rgba(7, 13, 24, 0.98) 100%);
  border: 1px solid rgba(111, 201, 255, 0.15);
  border-radius: 20px;
  padding: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

.role-card,
.role-card * {
    min-width: 0;
    overflow-wrap: anywhere;
}

.role-card:hover {
  border-color: rgba(111, 201, 255, 0.28);
}

.role-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin-bottom: 6px;
}

.role-checkbox-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-name {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-primary);
}

.role-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.role-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.role-meta-key {
  min-width: 72px;
  color: var(--text-disabled);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.role-meta-val {
  color: var(--text-secondary);
}

.role-cache-info {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-disabled);
  margin-bottom: 10px;
}

.role-cache-info a {
  color: var(--accent-primary);
  text-decoration: none;
  opacity: 0.7;
  transition: var(--transition);
}

.role-cache-info a:hover {
  opacity: 1;
  text-decoration: underline;
}

.role-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.role-actions .card-action-refresh,
.role-actions .card-action-delete {
  flex: 0 0 104px;
  width: 104px;
  justify-content: center;
}

.role-card.indexing .role-actions {
  width: 100%;
}

.role-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-faint);
  display: flex;
  gap: 8px;
}

/* Checkbox Styles */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-box {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--bg-void);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.checkbox-box:hover {
  border-color: var(--accent-primary);
}

.checkbox-box.checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: var(--glow-sm);
}

.checkbox-mark {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 1px;
  opacity: 0;
  transition: var(--transition);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.checkbox-box.checked .checkbox-mark {
  opacity: 1;
}

.checkbox-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

/* Button Styles */
.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-mid);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-active);
  color: var(--accent-bright);
  box-shadow: var(--glow-sm);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0a2a4a, #0d3560);
  color: var(--accent-bright);
  border: 1px solid var(--border-active);
  box-shadow: var(--glow-sm), inset 0 1px 0 rgba(0,200,255,0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0d3560, #103f72);
  box-shadow: var(--glow-md);
  color: var(--accent-pulse);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-mid);
}

.btn-secondary:hover {
  border-color: var(--border-active);
  color: var(--accent-bright);
  box-shadow: var(--glow-sm);
}

.btn-danger {
  background: rgba(255, 51, 85, 0.08);
  color: var(--accent-red);
  border: 1px solid rgba(255, 51, 85, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 51, 85, 0.18);
  color: #ff6b7a;
  box-shadow: 0 0 18px rgba(255, 51, 85, 0.45);
  border-color: rgba(255, 51, 85, 0.55);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 10px;
}

.btn-amber {
  background: linear-gradient(135deg, #4a2a0a, #60350d);
  color: var(--accent-amber);
  border: 1px solid rgba(255, 140, 0, 0.4);
  box-shadow: var(--glow-amber), inset 0 1px 0 rgba(255,140,0,0.1);
}

.btn-amber:hover {
  background: linear-gradient(135deg, #60350d, #723f10);
  box-shadow: 0 0 16px rgba(255, 140, 0, 0.5);
  color: #ffaa00;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--glow-lg);
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.modal-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  border: none;
  background: transparent;
  transition: var(--transition);
}

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

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

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-faint);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: normal;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  transition: var(--transition);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(0, 180, 255, 0.1);
}

.form-group select {
  cursor: pointer;
}

/* Empty State */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Glass Card Effect */
.glass-card {
  background: rgba(10, 22, 40, 0.4);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  transition: var(--transition);
  border-radius: 18px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background: var(--text-disabled);
  transition: var(--transition);
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(0, 180, 255, 0.2);
  border-color: var(--accent-primary);
  box-shadow: var(--glow-sm);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(18px);
  background: var(--accent-bright);
  box-shadow: 0 0 8px rgba(0, 180, 255, 0.6);
}

.toggle-slider:hover {
  border-color: var(--border-active);
}

/* Auto-refresh time picker styles (mirrors knowledge-base auto-reindex) */
.role-auto-refresh-row .role-meta-val {
    grid-column: 1 / -1;
    width: 100%;
}

.role-auto-refresh-toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    color: var(--text-secondary);
    line-height: 1.25;
}

.role-auto-refresh-switch {
    cursor: pointer;
    transform: scale(0.78);
    transform-origin: left center;
    margin-right: -8px;
    flex: 0 0 auto;
}

.role-auto-refresh-label {
    flex: 1 1 118px;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.role-auto-refresh-time-wrap {
    flex: 0 0 auto;
    display: inline-grid;
    grid-template-columns: 88px max-content;
    align-items: center;
    gap: 8px;
    padding-left: 28px;
    width: max-content;
    max-width: 100%;
    min-width: min(100%, 188px);
}

.role-auto-refresh-time-select,
.role-auto-refresh-time-select.ui-kit-select {
    flex: 0 0 88px;
    width: 88px !important;
    min-width: 88px;
    max-width: 88px;
}

.role-auto-refresh-time-select .ui-kit-select__trigger {
    width: 88px;
    min-height: 26px;
    height: 26px;
    padding: 3px 7px;
    border-radius: 4px;
    border-color: rgba(0, 210, 255, 0.35);
    background: rgba(4, 17, 31, 0.74);
    font-size: 11px;
}

.role-auto-refresh-time-select .ui-kit-select__menu {
    z-index: 13000;
    max-height: 210px;
    padding: 5px;
    border-radius: 8px;
}

.role-auto-refresh-time-select .ui-kit-select__option {
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 11px;
}

.role-auto-refresh-time-select:has(select:disabled) {
    opacity: 0.45;
    pointer-events: none;
}

.role-auto-refresh-zone {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 1px 6px;
    border: 1px solid rgba(0, 255, 180, 0.24);
    border-radius: 4px;
    background: rgba(0, 255, 180, 0.07);
    color: var(--accent-green);
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
}
